From e5ffc51da5fe13ff7a5dcd0003447c68e4778fbc Mon Sep 17 00:00:00 2001 From: Johann Hofmann Date: Fri, 5 Jan 2018 12:52:07 +0100 Subject: [PATCH] Bug 1428320 - Ignore about: pages for indexedDB storage type telemetry. r=janv MozReview-Commit-ID: 1Cx5hBsqyX1 --HG-- extra : rebase_source : 7bfe9fdefb413d84309943697f2159e107f5d05e --- dom/indexedDB/IDBFactory.cpp | 48 +++++++++++++++++++++++++----------- 1 file changed, 34 insertions(+), 14 deletions(-) diff --git a/dom/indexedDB/IDBFactory.cpp b/dom/indexedDB/IDBFactory.cpp index 5f2855e9d56d..2adff913662b 100644 --- a/dom/indexedDB/IDBFactory.cpp +++ b/dom/indexedDB/IDBFactory.cpp @@ -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 principal = PrincipalInfoToPrincipal(*mPrincipalInfo); + if (principal) { + nsCOMPtr 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!"); } }