OLD | NEW |
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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 EXISTING_PROCESS, | 129 EXISTING_PROCESS, |
130 NEW_PROCESS | 130 NEW_PROCESS |
131 }; | 131 }; |
132 | 132 |
133 // Not used for UMA. | 133 // Not used for UMA. |
134 enum class LoadSource { NETWORK, HTTP_CACHE, SERVICE_WORKER_STORAGE }; | 134 enum class LoadSource { NETWORK, HTTP_CACHE, SERVICE_WORKER_STORAGE }; |
135 | 135 |
136 // Converts an event type to a string. Used for tracing. | 136 // Converts an event type to a string. Used for tracing. |
137 static const char* EventTypeToString(EventType event_type); | 137 static const char* EventTypeToString(EventType event_type); |
138 | 138 |
| 139 // Returns true when the event is for a navigation hint. |
| 140 static bool IsNavigationHintEvent(EventType event_type); |
| 141 |
139 // Excludes NTP scope from UMA for now as it tends to dominate the stats and | 142 // Excludes NTP scope from UMA for now as it tends to dominate the stats and |
140 // makes the results largely skewed. Some metrics don't follow this policy | 143 // makes the results largely skewed. Some metrics don't follow this policy |
141 // and hence don't call this function. | 144 // and hence don't call this function. |
142 static bool ShouldExcludeSiteFromHistogram(Site site); | 145 static bool ShouldExcludeSiteFromHistogram(Site site); |
143 static bool ShouldExcludeURLFromHistogram(const GURL& url); | 146 static bool ShouldExcludeURLFromHistogram(const GURL& url); |
144 | 147 |
145 // Used for ServiceWorkerDiskCache. | 148 // Used for ServiceWorkerDiskCache. |
146 static void CountInitDiskCacheResult(bool result); | 149 static void CountInitDiskCacheResult(bool result); |
147 static void CountReadResponseResult(ReadResponseResult result); | 150 static void CountReadResponseResult(ReadResponseResult result); |
148 static void CountWriteResponseResult(WriteResponseResult result); | 151 static void CountWriteResponseResult(WriteResponseResult result); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 static void RecordActivateEventStatus(ServiceWorkerStatusCode status, | 194 static void RecordActivateEventStatus(ServiceWorkerStatusCode status, |
192 bool is_shutdown); | 195 bool is_shutdown); |
193 static void RecordInstallEventStatus(ServiceWorkerStatusCode status); | 196 static void RecordInstallEventStatus(ServiceWorkerStatusCode status); |
194 | 197 |
195 // Records how much of dispatched events are handled while a Service | 198 // Records how much of dispatched events are handled while a Service |
196 // Worker is awake (i.e. after it is woken up until it gets stopped). | 199 // Worker is awake (i.e. after it is woken up until it gets stopped). |
197 static void RecordEventHandledRatio(EventType event, | 200 static void RecordEventHandledRatio(EventType event, |
198 size_t handled_events, | 201 size_t handled_events, |
199 size_t fired_events); | 202 size_t fired_events); |
200 | 203 |
| 204 // Records the precision of the speculative launch of Service Workers for |
| 205 // each navigation hint type when the worker is stopped. If there was no |
| 206 // main/sub frame fetch event fired on the worker, |frame_fetch_event_fired| |
| 207 // is false. This means that the speculative launch wasn't helpful. |
| 208 static void RecordNavigationHintPrecision(EventType start_worker_purpose, |
| 209 bool frame_fetch_event_fired); |
| 210 |
201 // Records how often a dispatched event times out. | 211 // Records how often a dispatched event times out. |
202 static void RecordEventTimeout(EventType event); | 212 static void RecordEventTimeout(EventType event); |
203 | 213 |
204 // Records the amount of time spent handling an event. | 214 // Records the amount of time spent handling an event. |
205 static void RecordEventDuration(EventType event, | 215 static void RecordEventDuration(EventType event, |
206 base::TimeDelta time, | 216 base::TimeDelta time, |
207 bool was_handled); | 217 bool was_handled); |
208 | 218 |
209 // Records the result of dispatching a fetch event to a service worker. | 219 // Records the result of dispatching a fetch event to a service worker. |
210 static void RecordFetchEventStatus(bool is_main_resource, | 220 static void RecordFetchEventStatus(bool is_main_resource, |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 static void RecordStartStatusAfterFailure(int failure_count, | 262 static void RecordStartStatusAfterFailure(int failure_count, |
253 ServiceWorkerStatusCode status); | 263 ServiceWorkerStatusCode status); |
254 | 264 |
255 private: | 265 private: |
256 DISALLOW_IMPLICIT_CONSTRUCTORS(ServiceWorkerMetrics); | 266 DISALLOW_IMPLICIT_CONSTRUCTORS(ServiceWorkerMetrics); |
257 }; | 267 }; |
258 | 268 |
259 } // namespace content | 269 } // namespace content |
260 | 270 |
261 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_METRICS_H_ | 271 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_METRICS_H_ |
OLD | NEW |