Global Metrics
path: .metrics.nargs.sum
old: 0.0
new: 31.0
path: .metrics.nargs.average
old: null
new: 1.3478260869565215
path: .metrics.nom.functions
old: 0.0
new: 22.0
path: .metrics.nom.closures
old: 0.0
new: 1.0
path: .metrics.nom.total
old: 0.0
new: 23.0
path: .metrics.loc.cloc
old: 6.0
new: 7.0
path: .metrics.loc.ploc
old: 5.0
new: 203.0
path: .metrics.loc.lloc
old: 0.0
new: 75.0
path: .metrics.loc.sloc
old: 14.0
new: 243.0
path: .metrics.loc.blank
old: 3.0
new: 33.0
path: .metrics.mi.mi_visual_studio
old: 63.04704381807513
new: 15.750744780722115
path: .metrics.mi.mi_original
old: 107.81044492890848
new: 26.93377357503482
path: .metrics.mi.mi_sei
old: 122.49289774565132
new: -19.77495555706551
path: .metrics.nexits.sum
old: 0.0
new: 24.0
path: .metrics.nexits.average
old: null
new: 1.0434782608695652
path: .metrics.cyclomatic.sum
old: 2.0
new: 40.0
path: .metrics.cyclomatic.average
old: 1.0
new: 1.6
path: .metrics.cognitive.average
old: null
new: 0.9565217391304348
path: .metrics.cognitive.sum
old: 0.0
new: 22.0
path: .metrics.halstead.effort
old: 116.51128127343756
new: 214649.4709916889
path: .metrics.halstead.level
old: 0.4
new: 0.03162055335968379
path: .metrics.halstead.time
old: 6.47284895963542
new: 11924.970610649383
path: .metrics.halstead.length
old: 13.0
new: 915.0
path: .metrics.halstead.volume
old: 46.60451250937503
new: 6787.335051120597
path: .metrics.halstead.n1
old: 5.0
new: 23.0
path: .metrics.halstead.estimated_program_length
old: 31.26112492884004
new: 1171.041023102396
path: .metrics.halstead.difficulty
old: 2.5
new: 31.625
path: .metrics.halstead.n2
old: 7.0
new: 148.0
path: .metrics.halstead.vocabulary
old: 12.0
new: 171.0
path: .metrics.halstead.bugs
old: 0.00795165259133099
new: 1.1949928137563135
path: .metrics.halstead.N2
old: 7.0
new: 407.0
path: .metrics.halstead.N1
old: 6.0
new: 508.0
path: .metrics.halstead.purity_ratio
old: 2.40470191760308
new: 1.2798262547567167
Spaces Data
Minimal test - lines (19, 243)
path: .spaces[0].metrics.loc.lloc
old: 0.0
new: 75.0
path: .spaces[0].metrics.loc.cloc
old: 0.0
new: 1.0
path: .spaces[0].metrics.loc.blank
old: 0.0
new: 31.0
path: .spaces[0].metrics.loc.sloc
old: 1.0
new: 225.0
path: .spaces[0].metrics.loc.ploc
old: 1.0
new: 193.0
path: .spaces[0].metrics.mi.mi_original
old: 159.95690398326485
new: 28.568341595162153
path: .spaces[0].metrics.mi.mi_sei
old: 155.17000000000002
new: -25.35967044452928
path: .spaces[0].metrics.mi.mi_visual_studio
old: 93.54204911302038
new: 16.706632511790733
path: .spaces[0].metrics.halstead.n1
old: 2.0
new: 23.0
path: .spaces[0].metrics.halstead.N1
old: 2.0
new: 499.0
path: .spaces[0].metrics.halstead.n2
old: 2.0
new: 140.0
path: .spaces[0].metrics.halstead.level
old: 1.0
new: 0.030664768371481764
path: .spaces[0].metrics.halstead.volume
old: 8.0
new: 6584.460426191045
path: .spaces[0].metrics.halstead.bugs
old: 0.0013333333333333333
new: 1.19526925178497
path: .spaces[0].metrics.halstead.length
old: 4.0
new: 896.0
path: .spaces[0].metrics.halstead.vocabulary
old: 4.0
new: 163.0
path: .spaces[0].metrics.halstead.N2
old: 2.0
new: 397.0
path: .spaces[0].metrics.halstead.estimated_program_length
old: 4.0
new: 1102.1415473616066
path: .spaces[0].metrics.halstead.time
old: 0.4444444444444444
new: 11929.10876022826
path: .spaces[0].metrics.halstead.purity_ratio
old: 1.0
new: 1.230068691251793
path: .spaces[0].metrics.halstead.difficulty
old: 1.0
new: 32.61071428571429
path: .spaces[0].metrics.halstead.effort
old: 8.0
new: 214723.9576841087
path: .spaces[0].metrics.nexits.sum
old: 0.0
new: 24.0
path: .spaces[0].metrics.nexits.average
old: null
new: 1.0434782608695652
path: .spaces[0].metrics.cognitive.sum
old: 0.0
new: 22.0
path: .spaces[0].metrics.cognitive.average
old: null
new: 0.9565217391304348
path: .spaces[0].metrics.cyclomatic.sum
old: 1.0
new: 39.0
path: .spaces[0].metrics.cyclomatic.average
old: 1.0
new: 1.625
path: .spaces[0].metrics.nargs.sum
old: 0.0
new: 31.0
path: .spaces[0].metrics.nargs.average
old: null
new: 1.3478260869565215
path: .spaces[0].metrics.nom.functions
old: 0.0
new: 22.0
path: .spaces[0].metrics.nom.closures
old: 0.0
new: 1.0
path: .spaces[0].metrics.nom.total
old: 0.0
new: 23.0
Code
namespace mozilla {
namespace dom {
NS_IMPL_ISUPPORTS(ContentHandlerService, nsIHandlerService)
ContentHandlerService::ContentHandlerService() {}
nsresult ContentHandlerService::Init() {
if (!XRE_IsContentProcess()) {
return NS_ERROR_FAILURE;
}
ContentChild* cpc = ContentChild::GetSingleton();
mHandlerServiceChild = new HandlerServiceChild();
if (!cpc->SendPHandlerServiceConstructor(mHandlerServiceChild)) {
mHandlerServiceChild = nullptr;
}
return NS_OK;
}
void ContentHandlerService::nsIHandlerInfoToHandlerInfo(
nsIHandlerInfo* aInfo, HandlerInfo* aHandlerInfo) {
nsCString type;
aInfo->GetType(type);
nsCOMPtr mimeInfo = do_QueryInterface(aInfo);
bool isMIMEInfo = !!mimeInfo;
nsString description;
aInfo->GetDescription(description);
bool alwaysAskBeforeHandling;
aInfo->GetAlwaysAskBeforeHandling(&alwaysAskBeforeHandling);
nsCOMPtr app;
aInfo->GetPreferredApplicationHandler(getter_AddRefs(app));
nsString name;
nsString detailedDescription;
if (app) {
app->GetName(name);
app->GetDetailedDescription(detailedDescription);
}
HandlerApp happ(name, detailedDescription);
nsTArray happs;
nsCOMPtr apps;
aInfo->GetPossibleApplicationHandlers(getter_AddRefs(apps));
if (apps) {
unsigned int length;
apps->GetLength(&length);
for (unsigned int i = 0; i < length; i++) {
apps->QueryElementAt(i, NS_GET_IID(nsIHandlerApp), getter_AddRefs(app));
app->GetName(name);
app->GetDetailedDescription(detailedDescription);
happs.AppendElement(HandlerApp(name, detailedDescription));
}
}
nsTArray extensions;
if (isMIMEInfo) {
nsCOMPtr extensionsIter;
mimeInfo->GetFileExtensions(getter_AddRefs(extensionsIter));
if (extensionsIter) {
bool hasMore = false;
while (NS_SUCCEEDED(extensionsIter->HasMore(&hasMore)) && hasMore) {
nsAutoCString extension;
if (NS_SUCCEEDED(extensionsIter->GetNext(extension))) {
extensions.AppendElement(std::move(extension));
}
}
}
}
nsHandlerInfoAction action;
aInfo->GetPreferredAction(&action);
HandlerInfo info(type, isMIMEInfo, description, alwaysAskBeforeHandling,
std::move(extensions), happ, happs, action);
*aHandlerInfo = info;
}
NS_IMETHODIMP RemoteHandlerApp::GetName(nsAString& aName) {
aName.Assign(mAppChild.name());
return NS_OK;
}
NS_IMETHODIMP RemoteHandlerApp::SetName(const nsAString& aName) {
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP RemoteHandlerApp::GetDetailedDescription(
nsAString& aDetailedDescription) {
aDetailedDescription.Assign(mAppChild.detailedDescription());
return NS_OK;
}
NS_IMETHODIMP RemoteHandlerApp::SetDetailedDescription(
const nsAString& aDetailedDescription) {
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP RemoteHandlerApp::Equals(nsIHandlerApp* aHandlerApp,
bool* _retval) {
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP RemoteHandlerApp::LaunchWithURI(
nsIURI* aURI, BrowsingContext* aBrowsingContext) {
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMPL_ISUPPORTS(RemoteHandlerApp, nsIHandlerApp)
static inline void CopyHanderInfoTonsIHandlerInfo(
const HandlerInfo& info, nsIHandlerInfo* aHandlerInfo) {
HandlerApp preferredApplicationHandler = info.preferredApplicationHandler();
nsCOMPtr preferredApp(
new RemoteHandlerApp(preferredApplicationHandler));
aHandlerInfo->SetPreferredApplicationHandler(preferredApp);
nsCOMPtr possibleHandlers;
aHandlerInfo->GetPossibleApplicationHandlers(
getter_AddRefs(possibleHandlers));
possibleHandlers->AppendElement(preferredApp);
if (info.isMIMEInfo()) {
nsCOMPtr mimeInfo(do_QueryInterface(aHandlerInfo));
MOZ_ASSERT(mimeInfo,
"parent and child don't agree on whether this is a MIME info");
mimeInfo->SetFileExtensions(StringJoin(","_ns, info.extensions()));
}
}
ContentHandlerService::~ContentHandlerService() {}
NS_IMETHODIMP ContentHandlerService::AsyncInit() {
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP ContentHandlerService::Enumerate(nsISimpleEnumerator** _retval) {
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP ContentHandlerService::FillHandlerInfo(
nsIHandlerInfo* aHandlerInfo, const nsACString& aOverrideType) {
HandlerInfo info, returnedInfo;
nsIHandlerInfoToHandlerInfo(aHandlerInfo, &info);
mHandlerServiceChild->SendFillHandlerInfo(info, nsCString(aOverrideType),
&returnedInfo);
CopyHanderInfoTonsIHandlerInfo(returnedInfo, aHandlerInfo);
return NS_OK;
}
NS_IMETHODIMP ContentHandlerService::GetMIMEInfoFromOS(
nsIHandlerInfo* aHandlerInfo, const nsACString& aMIMEType,
const nsACString& aExtension, bool* aFound) {
nsresult rv = NS_ERROR_FAILURE;
HandlerInfo returnedInfo;
if (!mHandlerServiceChild->SendGetMIMEInfoFromOS(nsCString(aMIMEType),
nsCString(aExtension), &rv,
&returnedInfo, aFound)) {
return NS_ERROR_FAILURE;
}
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
CopyHanderInfoTonsIHandlerInfo(returnedInfo, aHandlerInfo);
return NS_OK;
}
NS_IMETHODIMP ContentHandlerService::Store(nsIHandlerInfo* aHandlerInfo) {
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP ContentHandlerService::Exists(nsIHandlerInfo* aHandlerInfo,
bool* _retval) {
HandlerInfo info;
nsIHandlerInfoToHandlerInfo(aHandlerInfo, &info);
mHandlerServiceChild->SendExists(info, _retval);
return NS_OK;
}
NS_IMETHODIMP ContentHandlerService::Remove(nsIHandlerInfo* aHandlerInfo) {
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
ContentHandlerService::ExistsForProtocolOS(const nsACString& aProtocolScheme,
bool* aRetval) {
if (!mHandlerServiceChild->SendExistsForProtocolOS(nsCString(aProtocolScheme),
aRetval)) {
return NS_ERROR_FAILURE;
}
return NS_OK;
}
NS_IMETHODIMP
ContentHandlerService::ExistsForProtocol(const nsACString& aProtocolScheme,
bool* aRetval) {
if (!mHandlerServiceChild->SendExistsForProtocol(nsCString(aProtocolScheme),
aRetval)) {
return NS_ERROR_FAILURE;
}
return NS_OK;
}
NS_IMETHODIMP ContentHandlerService::GetTypeFromExtension(
const nsACString& aFileExtension, nsACString& _retval) {
_retval.Assign(*mExtToTypeMap.LookupOrInsertWith(aFileExtension, [&] {
nsCString type;
mHandlerServiceChild->SendGetTypeFromExtension(nsCString(aFileExtension),
&type);
return MakeUnique(type);
}));
return NS_OK;
}
NS_IMETHODIMP ContentHandlerService::GetApplicationDescription(
const nsACString& aProtocolScheme, nsAString& aRetVal) {
nsresult rv = NS_ERROR_FAILURE;
nsAutoCString scheme(aProtocolScheme);
nsAutoString desc;
mHandlerServiceChild->SendGetApplicationDescription(scheme, &rv, &desc);
aRetVal.Assign(desc);
return rv;
}
} // namespace dom
} // namespace mozilla