Bug 1566758 - Added telemetry for use of IDBFactory.open(name, options) discriminated by principal types r=ttung,asuth

Differential Revision: https://phabricator.services.mozilla.com/D40180

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Simon Giesecke 2019-08-19 14:22:09 +00:00
Родитель 7037b258ba
Коммит 0153998ccc
2 изменённых файлов: 69 добавлений и 0 удалений

Просмотреть файл

@ -56,6 +56,51 @@ namespace {
const char kPrefIndexedDBEnabled[] = "dom.indexedDB.enabled"; const char kPrefIndexedDBEnabled[] = "dom.indexedDB.enabled";
Telemetry::LABELS_IDB_CUSTOM_OPEN_WITH_OPTIONS_COUNT IdentifyPrincipalType(
const mozilla::ipc::PrincipalInfo& aPrincipalInfo) {
switch (aPrincipalInfo.type()) {
case PrincipalInfo::TSystemPrincipalInfo:
return Telemetry::LABELS_IDB_CUSTOM_OPEN_WITH_OPTIONS_COUNT::system;
case PrincipalInfo::TContentPrincipalInfo: {
const ContentPrincipalInfo& info =
aPrincipalInfo.get_ContentPrincipalInfo();
nsCOMPtr<nsIURI> uri;
if (NS_WARN_IF(NS_FAILED(NS_NewURI(getter_AddRefs(uri), info.spec())))) {
// This could be discriminated as an extra error value, but this is
// extremely unlikely to fail, so we just misuse ContentOther
return Telemetry::LABELS_IDB_CUSTOM_OPEN_WITH_OPTIONS_COUNT::
content_other;
}
// TODO Are there constants defined for the schemes somewhere?
if (uri->SchemeIs("file")) {
return Telemetry::LABELS_IDB_CUSTOM_OPEN_WITH_OPTIONS_COUNT::
content_file;
}
if (uri->SchemeIs("http") || uri->SchemeIs("https")) {
return Telemetry::LABELS_IDB_CUSTOM_OPEN_WITH_OPTIONS_COUNT::
content_http_https;
}
if (uri->SchemeIs("moz-extension")) {
return Telemetry::LABELS_IDB_CUSTOM_OPEN_WITH_OPTIONS_COUNT::
content_moz_ext;
}
if (uri->SchemeIs("about")) {
return Telemetry::LABELS_IDB_CUSTOM_OPEN_WITH_OPTIONS_COUNT::
content_about;
}
return Telemetry::LABELS_IDB_CUSTOM_OPEN_WITH_OPTIONS_COUNT::
content_other;
}
case PrincipalInfo::TExpandedPrincipalInfo:
return Telemetry::LABELS_IDB_CUSTOM_OPEN_WITH_OPTIONS_COUNT::expanded;
default:
return Telemetry::LABELS_IDB_CUSTOM_OPEN_WITH_OPTIONS_COUNT::other;
}
}
} // namespace } // namespace
struct IDBFactory::PendingRequestInfo { struct IDBFactory::PendingRequestInfo {
@ -440,6 +485,10 @@ already_AddRefed<IDBOpenDBRequest> IDBFactory::Open(
} }
} }
const auto principalType = IdentifyPrincipalType(*mPrincipalInfo);
Telemetry::AccumulateCategorical(principalType);
return OpenInternal(aCx, return OpenInternal(aCx,
/* aPrincipal */ nullptr, aName, aOptions.mVersion, /* aPrincipal */ nullptr, aName, aOptions.mVersion,
aOptions.mStorage, aOptions.mStorage,

Просмотреть файл

@ -15693,5 +15693,25 @@
"n_buckets": 100, "n_buckets": 100,
"releaseChannelCollection": "opt-out", "releaseChannelCollection": "opt-out",
"description": "How many milliseconds it took to load a hyphenation resource." "description": "How many milliseconds it took to load a hyphenation resource."
},
"IDB_CUSTOM_OPEN_WITH_OPTIONS_COUNT": {
"record_in_processes": ["main", "content"],
"products": ["firefox", "fennec", "geckoview"],
"bug_numbers": [1566758],
"alert_emails": ["sgiesecke@mozilla.com"],
"expires_in_version": "74",
"kind": "categorical",
"labels": [
"system",
"content_file",
"content_http_https",
"content_moz_ext",
"content_about",
"content_other",
"expanded",
"other"
],
"releaseChannelCollection": "opt-out",
"description": "Tracking the use of the custom IDBFactory.open overload accepting an options dictionary in one of the categories."
} }
} }