Bug 1428320 - Ignore about: pages for indexedDB storage type telemetry. r=janv

MozReview-Commit-ID: 1Cx5hBsqyX1

--HG--
extra : rebase_source : 7bfe9fdefb413d84309943697f2159e107f5d05e
This commit is contained in:
Johann Hofmann 2018-01-05 12:52:07 +01:00
Родитель 9410573b5c
Коммит e5ffc51da5
1 изменённых файлов: 34 добавлений и 14 удалений

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

@ -453,23 +453,43 @@ IDBFactory::Open(JSContext* aCx,
{
if (!IsChrome() &&
aOptions.mStorage.WasPassed()) {
switch (aOptions.mStorage.Value()) {
case StorageType::Persistent: {
Telemetry::ScalarAdd(Telemetry::ScalarID::IDB_TYPE_PERSISTENT_COUNT, 1);
break;
bool ignore = false;
// Ignore internal usage on about: pages.
if (NS_IsMainThread()) {
nsCOMPtr<nsIPrincipal> principal = PrincipalInfoToPrincipal(*mPrincipalInfo);
if (principal) {
nsCOMPtr<nsIURI> uri;
nsresult rv = principal->GetURI(getter_AddRefs(uri));
if (NS_SUCCEEDED(rv) && uri) {
bool isAbout;
rv = uri->SchemeIs("about", &isAbout);
if (NS_SUCCEEDED(rv) && isAbout) {
ignore = true;
}
}
}
}
case StorageType::Temporary: {
Telemetry::ScalarAdd(Telemetry::ScalarID::IDB_TYPE_TEMPORARY_COUNT, 1);
break;
if (!ignore) {
switch (aOptions.mStorage.Value()) {
case StorageType::Persistent: {
Telemetry::ScalarAdd(Telemetry::ScalarID::IDB_TYPE_PERSISTENT_COUNT, 1);
break;
}
case StorageType::Temporary: {
Telemetry::ScalarAdd(Telemetry::ScalarID::IDB_TYPE_TEMPORARY_COUNT, 1);
break;
}
case StorageType::Default:
case StorageType::EndGuard_:
break;
default:
MOZ_CRASH("Invalid storage type!");
}
case StorageType::Default:
case StorageType::EndGuard_:
break;
default:
MOZ_CRASH("Invalid storage type!");
}
}