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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 | 65 |
66 // Used for UMA. Append-only. | 66 // Used for UMA. Append-only. |
67 enum class StopStatus { | 67 enum class StopStatus { |
68 NORMAL, | 68 NORMAL, |
69 DETACH_BY_REGISTRY, | 69 DETACH_BY_REGISTRY, |
70 TIMEOUT, | 70 TIMEOUT, |
71 // Add new types here. | 71 // Add new types here. |
72 NUM_TYPES | 72 NUM_TYPES |
73 }; | 73 }; |
74 | 74 |
75 enum EventType { | 75 // Used for UMA. Append-only. |
76 EVENT_TYPE_FETCH, | 76 enum class EventType { |
| 77 ACTIVATE, |
| 78 INSTALL, |
| 79 FETCH, |
| 80 SYNC, |
| 81 NOTIFICATION_CLICK, |
| 82 PUSH, |
| 83 GEOFENCING, |
| 84 SERVICE_PORT_CONNECT, |
77 // Add new events to record here. | 85 // Add new events to record here. |
78 | 86 |
79 NUM_EVENT_TYPES | 87 NUM_TYPES |
80 }; | 88 }; |
81 | 89 |
82 // Used for UMA. Append only. | 90 // Used for UMA. Append only. |
83 enum class Site { OTHER, NEW_TAB_PAGE, NUM_TYPES }; | 91 enum class Site { OTHER, NEW_TAB_PAGE, NUM_TYPES }; |
84 | 92 |
85 // Excludes NTP scope from UMA for now as it tends to dominate the stats and | 93 // Excludes NTP scope from UMA for now as it tends to dominate the stats and |
86 // makes the results largely skewed. Some metrics don't follow this policy | 94 // makes the results largely skewed. Some metrics don't follow this policy |
87 // and hence don't call this function. | 95 // and hence don't call this function. |
88 static bool ShouldExcludeSiteFromHistogram(Site site); | 96 static bool ShouldExcludeSiteFromHistogram(Site site); |
89 static bool ShouldExcludeURLFromHistogram(const GURL& url); | 97 static bool ShouldExcludeURLFromHistogram(const GURL& url); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 | 132 |
125 static void RecordActivateEventStatus(ServiceWorkerStatusCode status); | 133 static void RecordActivateEventStatus(ServiceWorkerStatusCode status); |
126 static void RecordInstallEventStatus(ServiceWorkerStatusCode status); | 134 static void RecordInstallEventStatus(ServiceWorkerStatusCode status); |
127 | 135 |
128 // Records how much of dispatched events are handled while a Service | 136 // Records how much of dispatched events are handled while a Service |
129 // Worker is awake (i.e. after it is woken up until it gets stopped). | 137 // Worker is awake (i.e. after it is woken up until it gets stopped). |
130 static void RecordEventHandledRatio(EventType event, | 138 static void RecordEventHandledRatio(EventType event, |
131 size_t handled_events, | 139 size_t handled_events, |
132 size_t fired_events); | 140 size_t fired_events); |
133 | 141 |
| 142 // Records how often a dispatched event times out. |
| 143 static void RecordEventTimeout(EventType event); |
| 144 |
134 // Records the result of dispatching a fetch event to a service worker. | 145 // Records the result of dispatching a fetch event to a service worker. |
135 static void RecordFetchEventStatus(bool is_main_resource, | 146 static void RecordFetchEventStatus(bool is_main_resource, |
136 ServiceWorkerStatusCode status); | 147 ServiceWorkerStatusCode status); |
137 | 148 |
138 // Records the amount of time spent handling a fetch event with the given | 149 // Records the amount of time spent handling a fetch event with the given |
139 // result. | 150 // result. |
140 static void RecordFetchEventTime(ServiceWorkerFetchEventResult result, | 151 static void RecordFetchEventTime(ServiceWorkerFetchEventResult result, |
141 const base::TimeDelta& time); | 152 const base::TimeDelta& time); |
142 | 153 |
143 // Records result of a ServiceWorkerURLRequestJob that was forwarded to | 154 // Records result of a ServiceWorkerURLRequestJob that was forwarded to |
(...skipping 15 matching lines...) Expand all Loading... |
159 // previous event ended). | 170 // previous event ended). |
160 static void RecordTimeBetweenEvents(const base::TimeDelta& time); | 171 static void RecordTimeBetweenEvents(const base::TimeDelta& time); |
161 | 172 |
162 private: | 173 private: |
163 DISALLOW_IMPLICIT_CONSTRUCTORS(ServiceWorkerMetrics); | 174 DISALLOW_IMPLICIT_CONSTRUCTORS(ServiceWorkerMetrics); |
164 }; | 175 }; |
165 | 176 |
166 } // namespace content | 177 } // namespace content |
167 | 178 |
168 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_METRICS_H_ | 179 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_METRICS_H_ |
OLD | NEW |