Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1302)

Unified Diff: content/browser/service_worker/service_worker_metrics.cc

Issue 2250623003: Keep ServiceWorkerMetrics::Site in ServiceWorkerVersion (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: diff from https://codereview.chromium.org/2251633002/#ps40001 Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/service_worker/service_worker_metrics.cc
diff --git a/content/browser/service_worker/service_worker_metrics.cc b/content/browser/service_worker/service_worker_metrics.cc
index 98d494384abb69ed02d37c48be498d951b932600..745d3241d99a7461b33abc8406b32aacc992642b 100644
--- a/content/browser/service_worker/service_worker_metrics.cc
+++ b/content/browser/service_worker/service_worker_metrics.cc
@@ -144,21 +144,6 @@ void RecordURLMetricOnUI(const GURL& url) {
"ServiceWorker.ControlledPageUrl", url);
}
-ServiceWorkerMetrics::Site SiteFromURL(const GURL& gurl) {
- // UIThreadSearchTermsData::GoogleBaseURLValue() returns the google base
- // URL, but not available in content layer.
- static const char google_like_scope_prefix[] = "https://www.google.";
- static const char ntp_scope_path[] = "/_/chrome/";
- if (base::StartsWith(gurl.spec(), google_like_scope_prefix,
- base::CompareCase::INSENSITIVE_ASCII) &&
- base::StartsWith(gurl.path(), ntp_scope_path,
- base::CompareCase::SENSITIVE)) {
- return ServiceWorkerMetrics::Site::NEW_TAB_PAGE;
- }
-
- return ServiceWorkerMetrics::Site::OTHER;
-}
-
enum EventHandledRatioType {
EVENT_HANDLED_NONE,
EVENT_HANDLED_SOME,
@@ -213,6 +198,27 @@ const char* ServiceWorkerMetrics::EventTypeToString(EventType event_type) {
return "error";
}
+ServiceWorkerMetrics::Site ServiceWorkerMetrics::SiteFromURL(
+ const GURL& url,
+ base::Optional<bool> has_fetch_handler) {
+ // UIThreadSearchTermsData::GoogleBaseURLValue() returns the google base
+ // URL, but not available in content layer.
+ static const char google_like_scope_prefix[] = "https://www.google.";
+ static const char ntp_scope_path[] = "/_/chrome/";
+ if (base::StartsWith(url.spec(), google_like_scope_prefix,
+ base::CompareCase::INSENSITIVE_ASCII) &&
+ base::StartsWith(url.path(), ntp_scope_path,
+ base::CompareCase::SENSITIVE)) {
+ return ServiceWorkerMetrics::Site::NEW_TAB_PAGE;
+ }
+
+ if (!has_fetch_handler)
+ return ServiceWorkerMetrics::Site::OTHER;
+ if (has_fetch_handler.value())
+ return ServiceWorkerMetrics::Site::WITH_FETCH_HANDLER;
+ return ServiceWorkerMetrics::Site::WITHOUT_FETCH_HANDLER;
+}
+
bool ServiceWorkerMetrics::IsNavigationHintEvent(EventType event_type) {
return event_type == EventType::NAVIGATION_HINT_LINK_MOUSE_DOWN ||
event_type == EventType::NAVIGATION_HINT_LINK_TAP_UNCONFIRMED ||
@@ -223,10 +229,6 @@ bool ServiceWorkerMetrics::ShouldExcludeSiteFromHistogram(Site site) {
return site == ServiceWorkerMetrics::Site::NEW_TAB_PAGE;
}
-bool ServiceWorkerMetrics::ShouldExcludeURLFromHistogram(const GURL& url) {
- return ShouldExcludeSiteFromHistogram(SiteFromURL(url));
-}
-
void ServiceWorkerMetrics::CountInitDiskCacheResult(bool result) {
UMA_HISTOGRAM_BOOLEAN("ServiceWorker.DiskCache.InitResult", result);
}
@@ -278,14 +280,10 @@ void ServiceWorkerMetrics::RecordDeleteAndStartOverResult(
result, NUM_DELETE_AND_START_OVER_RESULT_TYPES);
}
-void ServiceWorkerMetrics::CountControlledPageLoad(const GURL& url,
- bool has_fetch_handler,
+void ServiceWorkerMetrics::CountControlledPageLoad(Site site,
+ const GURL& url,
bool is_main_frame_load) {
- Site site = SiteFromURL(url);
- if (site == Site::OTHER) {
- site = (has_fetch_handler) ? Site::WITH_FETCH_HANDLER
- : Site::WITHOUT_FETCH_HANDLER;
- }
+ DCHECK_NE(site, Site::OTHER);
UMA_HISTOGRAM_ENUMERATION("ServiceWorker.PageLoad", static_cast<int>(site),
static_cast<int>(Site::NUM_TYPES));
if (is_main_frame_load) {

Powered by Google App Engine
This is Rietveld 408576698