| 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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 }; | 134 }; |
| 135 | 135 |
| 136 // Not used for UMA. | 136 // Not used for UMA. |
| 137 enum class StartSituation { | 137 enum class StartSituation { |
| 138 UNKNOWN, | 138 UNKNOWN, |
| 139 DURING_STARTUP, | 139 DURING_STARTUP, |
| 140 EXISTING_PROCESS, | 140 EXISTING_PROCESS, |
| 141 NEW_PROCESS | 141 NEW_PROCESS |
| 142 }; | 142 }; |
| 143 | 143 |
| 144 // Used for UMA. Append only. |
| 145 // This enum describes how an activated worker was found and prepared (i.e., |
| 146 // reached the RUNNING status) in order to dispatch a fetch event to. |
| 147 enum class WorkerPreparationType { |
| 148 UNKNOWN, |
| 149 // The worker was already starting up. We waited for it to finish. |
| 150 STARTING, |
| 151 // The worker was already running. |
| 152 RUNNING, |
| 153 // The worker was stopping. We waited for it to stop, and then started it |
| 154 // up. |
| 155 STOPPING, |
| 156 // The worker was in the stopped state. We started it up, and startup |
| 157 // required a new process to be created. |
| 158 START_IN_NEW_PROCESS, |
| 159 // The worker was in the stopped state. We started it up, and it used an |
| 160 // existing process. |
| 161 START_IN_EXISTING_PROCESS, |
| 162 // The worker was in the stopped state. We started it up, and this occurred |
| 163 // during browser startup. |
| 164 START_DURING_STARTUP, |
| 165 // Add new types here. |
| 166 NUM_TYPES |
| 167 }; |
| 168 |
| 144 // Not used for UMA. | 169 // Not used for UMA. |
| 145 enum class LoadSource { NETWORK, HTTP_CACHE, SERVICE_WORKER_STORAGE }; | 170 enum class LoadSource { NETWORK, HTTP_CACHE, SERVICE_WORKER_STORAGE }; |
| 146 | 171 |
| 147 // Converts an event type to a string. Used for tracing. | 172 // Converts an event type to a string. Used for tracing. |
| 148 static const char* EventTypeToString(EventType event_type); | 173 static const char* EventTypeToString(EventType event_type); |
| 149 | 174 |
| 150 // If the |url| is not a special site, returns Site::OTHER. | 175 // If the |url| is not a special site, returns Site::OTHER. |
| 151 static Site SiteFromURL(const GURL& url); | 176 static Site SiteFromURL(const GURL& url); |
| 152 | 177 |
| 153 // Returns true when the event is for a navigation hint. | 178 // Returns true when the event is for a navigation hint. |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 EventType purpose, | 211 EventType purpose, |
| 187 bool is_installed); | 212 bool is_installed); |
| 188 | 213 |
| 189 // Records the time taken to successfully start a worker. |is_installed| | 214 // Records the time taken to successfully start a worker. |is_installed| |
| 190 // indicates whether the version has been installed. | 215 // indicates whether the version has been installed. |
| 191 static void RecordStartWorkerTime(base::TimeDelta time, | 216 static void RecordStartWorkerTime(base::TimeDelta time, |
| 192 bool is_installed, | 217 bool is_installed, |
| 193 StartSituation start_situation, | 218 StartSituation start_situation, |
| 194 EventType purpose); | 219 EventType purpose); |
| 195 | 220 |
| 196 // Records the time taken to prepare an activated Service Worker for a main | 221 // Records metrics for the preparation of an activated Service Worker for a |
| 197 // frame fetch. | 222 // main frame navigation. |
| 198 static void RecordActivatedWorkerPreparationTimeForMainFrame( | 223 CONTENT_EXPORT static void RecordActivatedWorkerPreparationForMainFrame( |
| 199 base::TimeDelta time, | 224 base::TimeDelta time, |
| 200 EmbeddedWorkerStatus initial_worker_status, | 225 EmbeddedWorkerStatus initial_worker_status, |
| 201 StartSituation start_situation); | 226 StartSituation start_situation, |
| 227 bool did_navigation_preload); |
| 202 | 228 |
| 203 // Records the result of trying to stop a worker. | 229 // Records the result of trying to stop a worker. |
| 204 static void RecordWorkerStopped(StopStatus status); | 230 static void RecordWorkerStopped(StopStatus status); |
| 205 | 231 |
| 206 // Records the time taken to successfully stop a worker. | 232 // Records the time taken to successfully stop a worker. |
| 207 static void RecordStopWorkerTime(base::TimeDelta time); | 233 static void RecordStopWorkerTime(base::TimeDelta time); |
| 208 | 234 |
| 209 static void RecordActivateEventStatus(ServiceWorkerStatusCode status, | 235 static void RecordActivateEventStatus(ServiceWorkerStatusCode status, |
| 210 bool is_shutdown); | 236 bool is_shutdown); |
| 211 static void RecordInstallEventStatus(ServiceWorkerStatusCode status); | 237 static void RecordInstallEventStatus(ServiceWorkerStatusCode status); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 bool is_installed, | 324 bool is_installed, |
| 299 bool is_main_script); | 325 bool is_main_script); |
| 300 | 326 |
| 301 private: | 327 private: |
| 302 DISALLOW_IMPLICIT_CONSTRUCTORS(ServiceWorkerMetrics); | 328 DISALLOW_IMPLICIT_CONSTRUCTORS(ServiceWorkerMetrics); |
| 303 }; | 329 }; |
| 304 | 330 |
| 305 } // namespace content | 331 } // namespace content |
| 306 | 332 |
| 307 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_METRICS_H_ | 333 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_METRICS_H_ |
| OLD | NEW |