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

Side by Side Diff: content/browser/service_worker/service_worker_metrics.h

Issue 2000063005: [WIP] Speculatively launch Service Workers on mouse/touch events. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_METRICS_H_ 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_METRICS_H_
6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_METRICS_H_ 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_METRICS_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 // GEOFENCING = 6, // Obsolete 88 // GEOFENCING = 6, // Obsolete
89 // SERVICE_PORT_CONNECT = 7, // Obsolete 89 // SERVICE_PORT_CONNECT = 7, // Obsolete
90 MESSAGE = 8, 90 MESSAGE = 8,
91 NOTIFICATION_CLOSE = 9, 91 NOTIFICATION_CLOSE = 9,
92 FETCH_MAIN_FRAME = 10, 92 FETCH_MAIN_FRAME = 10,
93 FETCH_SUB_FRAME = 11, 93 FETCH_SUB_FRAME = 11,
94 FETCH_SHARED_WORKER = 12, 94 FETCH_SHARED_WORKER = 12,
95 FETCH_SUB_RESOURCE = 13, 95 FETCH_SUB_RESOURCE = 13,
96 UNKNOWN = 14, // Used when event type is not known. 96 UNKNOWN = 14, // Used when event type is not known.
97 FOREIGN_FETCH = 15, 97 FOREIGN_FETCH = 15,
98 NAVIGATION_HINT_LINK_MOUSE_DOWN = 16,
99 NAVIGATION_HINT_LINK_TAP_UNCONFIRMED = 17,
100 NAVIGATION_HINT_LINK_TAP_DOWN = 18,
98 // Add new events to record here. 101 // Add new events to record here.
99 NUM_TYPES 102 NUM_TYPES
100 }; 103 };
101 104
102 // Used for UMA. Append only. 105 // Used for UMA. Append only.
103 enum class Site { 106 enum class Site {
104 OTHER, // Obsolete 107 OTHER, // Obsolete
105 NEW_TAB_PAGE, 108 NEW_TAB_PAGE,
106 WITH_FETCH_HANDLER, 109 WITH_FETCH_HANDLER,
107 WITHOUT_FETCH_HANDLER, 110 WITHOUT_FETCH_HANDLER,
108 NUM_TYPES 111 NUM_TYPES
109 }; 112 };
110 113
111 // Not used for UMA. 114 // Not used for UMA.
112 enum class StartSituation { 115 enum class StartSituation {
113 UNKNOWN, 116 UNKNOWN,
114 DURING_STARTUP, 117 DURING_STARTUP,
115 EXISTING_PROCESS, 118 EXISTING_PROCESS,
116 NEW_PROCESS 119 NEW_PROCESS
117 }; 120 };
118 121
119 // Not used for UMA. 122 // Not used for UMA.
120 enum class LoadSource { NETWORK, HTTP_CACHE, SERVICE_WORKER_STORAGE }; 123 enum class LoadSource { NETWORK, HTTP_CACHE, SERVICE_WORKER_STORAGE };
121 124
122 // Converts an event type to a string. Used for tracing. 125 // Converts an event type to a string. Used for tracing.
123 static const char* EventTypeToString(EventType event_type); 126 static const char* EventTypeToString(EventType event_type);
124 127
128 // Returns true when the event is for a navigation hint.
129 static bool IsNavigationHintEvent(EventType event_type);
130
125 // Excludes NTP scope from UMA for now as it tends to dominate the stats and 131 // Excludes NTP scope from UMA for now as it tends to dominate the stats and
126 // makes the results largely skewed. Some metrics don't follow this policy 132 // makes the results largely skewed. Some metrics don't follow this policy
127 // and hence don't call this function. 133 // and hence don't call this function.
128 static bool ShouldExcludeSiteFromHistogram(Site site); 134 static bool ShouldExcludeSiteFromHistogram(Site site);
129 static bool ShouldExcludeURLFromHistogram(const GURL& url); 135 static bool ShouldExcludeURLFromHistogram(const GURL& url);
130 136
131 // Used for ServiceWorkerDiskCache. 137 // Used for ServiceWorkerDiskCache.
132 static void CountInitDiskCacheResult(bool result); 138 static void CountInitDiskCacheResult(bool result);
133 static void CountReadResponseResult(ReadResponseResult result); 139 static void CountReadResponseResult(ReadResponseResult result);
134 static void CountWriteResponseResult(WriteResponseResult result); 140 static void CountWriteResponseResult(WriteResponseResult result);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 static void RecordActivateEventStatus(ServiceWorkerStatusCode status, 176 static void RecordActivateEventStatus(ServiceWorkerStatusCode status,
171 bool is_shutdown); 177 bool is_shutdown);
172 static void RecordInstallEventStatus(ServiceWorkerStatusCode status); 178 static void RecordInstallEventStatus(ServiceWorkerStatusCode status);
173 179
174 // Records how much of dispatched events are handled while a Service 180 // Records how much of dispatched events are handled while a Service
175 // Worker is awake (i.e. after it is woken up until it gets stopped). 181 // Worker is awake (i.e. after it is woken up until it gets stopped).
176 static void RecordEventHandledRatio(EventType event, 182 static void RecordEventHandledRatio(EventType event,
177 size_t handled_events, 183 size_t handled_events,
178 size_t fired_events); 184 size_t fired_events);
179 185
186 // Records the precision of the speculative launch of Service Workers for
187 // each navigation hint type when the worker is stopped. If there was no
188 // event fetched to the worker, |event_fired| is false. This means that the
189 // speculative launch was meaningless.
190 static void RecordNavigationHintPrecision(EventType start_worker_purpose,
191 bool event_fired);
192
180 // Records how often a dispatched event times out. 193 // Records how often a dispatched event times out.
181 static void RecordEventTimeout(EventType event); 194 static void RecordEventTimeout(EventType event);
182 195
183 // Records the amount of time spent handling an event. 196 // Records the amount of time spent handling an event.
184 static void RecordEventDuration(EventType event, 197 static void RecordEventDuration(EventType event,
185 base::TimeDelta time, 198 base::TimeDelta time,
186 bool was_handled); 199 bool was_handled);
187 200
188 // Records the result of dispatching a fetch event to a service worker. 201 // Records the result of dispatching a fetch event to a service worker.
189 static void RecordFetchEventStatus(bool is_main_resource, 202 static void RecordFetchEventStatus(bool is_main_resource,
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 static void RecordStartStatusAfterFailure(int failure_count, 244 static void RecordStartStatusAfterFailure(int failure_count,
232 ServiceWorkerStatusCode status); 245 ServiceWorkerStatusCode status);
233 246
234 private: 247 private:
235 DISALLOW_IMPLICIT_CONSTRUCTORS(ServiceWorkerMetrics); 248 DISALLOW_IMPLICIT_CONSTRUCTORS(ServiceWorkerMetrics);
236 }; 249 };
237 250
238 } // namespace content 251 } // namespace content
239 252
240 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_METRICS_H_ 253 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_METRICS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698