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