| 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 #include "content/browser/service_worker/service_worker_metrics.h" | 5 #include "content/browser/service_worker/service_worker_metrics.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 case ServiceWorkerMetrics::EventType::FETCH_SUB_FRAME: | 60 case ServiceWorkerMetrics::EventType::FETCH_SUB_FRAME: |
| 61 return "_FETCH_SUB_FRAME"; | 61 return "_FETCH_SUB_FRAME"; |
| 62 case ServiceWorkerMetrics::EventType::FETCH_SHARED_WORKER: | 62 case ServiceWorkerMetrics::EventType::FETCH_SHARED_WORKER: |
| 63 return "_FETCH_SHARED_WORKER"; | 63 return "_FETCH_SHARED_WORKER"; |
| 64 case ServiceWorkerMetrics::EventType::FETCH_SUB_RESOURCE: | 64 case ServiceWorkerMetrics::EventType::FETCH_SUB_RESOURCE: |
| 65 return "_FETCH_SUB_RESOURCE"; | 65 return "_FETCH_SUB_RESOURCE"; |
| 66 case ServiceWorkerMetrics::EventType::UNKNOWN: | 66 case ServiceWorkerMetrics::EventType::UNKNOWN: |
| 67 return "_UNKNOWN"; | 67 return "_UNKNOWN"; |
| 68 case ServiceWorkerMetrics::EventType::FOREIGN_FETCH: | 68 case ServiceWorkerMetrics::EventType::FOREIGN_FETCH: |
| 69 return "_FOREIGN_FETCH"; | 69 return "_FOREIGN_FETCH"; |
| 70 case ServiceWorkerMetrics::EventType::FETCH_WAITUNTIL: |
| 71 return "_FETCH_WAITUNTIL"; |
| 70 case ServiceWorkerMetrics::EventType::NUM_TYPES: | 72 case ServiceWorkerMetrics::EventType::NUM_TYPES: |
| 71 NOTREACHED() << static_cast<int>(event_type); | 73 NOTREACHED() << static_cast<int>(event_type); |
| 72 } | 74 } |
| 73 return "_UNKNOWN"; | 75 return "_UNKNOWN"; |
| 74 } | 76 } |
| 75 | 77 |
| 76 std::string GetWorkerPreparationSuffix( | 78 std::string GetWorkerPreparationSuffix( |
| 77 EmbeddedWorkerStatus initial_worker_status, | 79 EmbeddedWorkerStatus initial_worker_status, |
| 78 ServiceWorkerMetrics::StartSituation start_situation) { | 80 ServiceWorkerMetrics::StartSituation start_situation) { |
| 79 switch (initial_worker_status) { | 81 switch (initial_worker_status) { |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 case EventType::FETCH_SUB_FRAME: | 181 case EventType::FETCH_SUB_FRAME: |
| 180 return "Fetch Sub Frame"; | 182 return "Fetch Sub Frame"; |
| 181 case EventType::FETCH_SHARED_WORKER: | 183 case EventType::FETCH_SHARED_WORKER: |
| 182 return "Fetch Shared Worker"; | 184 return "Fetch Shared Worker"; |
| 183 case EventType::FETCH_SUB_RESOURCE: | 185 case EventType::FETCH_SUB_RESOURCE: |
| 184 return "Fetch Subresource"; | 186 return "Fetch Subresource"; |
| 185 case EventType::UNKNOWN: | 187 case EventType::UNKNOWN: |
| 186 return "Unknown"; | 188 return "Unknown"; |
| 187 case EventType::FOREIGN_FETCH: | 189 case EventType::FOREIGN_FETCH: |
| 188 return "Foreign Fetch"; | 190 return "Foreign Fetch"; |
| 191 case EventType::FETCH_WAITUNTIL: |
| 192 return "Fetch WaitUntil"; |
| 189 case EventType::NUM_TYPES: | 193 case EventType::NUM_TYPES: |
| 190 break; | 194 break; |
| 191 } | 195 } |
| 192 NOTREACHED() << "Got unexpected event type: " << static_cast<int>(event_type); | 196 NOTREACHED() << "Got unexpected event type: " << static_cast<int>(event_type); |
| 193 return "error"; | 197 return "error"; |
| 194 } | 198 } |
| 195 | 199 |
| 196 bool ServiceWorkerMetrics::ShouldExcludeSiteFromHistogram(Site site) { | 200 bool ServiceWorkerMetrics::ShouldExcludeSiteFromHistogram(Site site) { |
| 197 return site == ServiceWorkerMetrics::Site::NEW_TAB_PAGE; | 201 return site == ServiceWorkerMetrics::Site::NEW_TAB_PAGE; |
| 198 } | 202 } |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 410 case EventType::FETCH_SHARED_WORKER: | 414 case EventType::FETCH_SHARED_WORKER: |
| 411 case EventType::FETCH_SUB_RESOURCE: | 415 case EventType::FETCH_SUB_RESOURCE: |
| 412 if (was_handled) { | 416 if (was_handled) { |
| 413 UMA_HISTOGRAM_MEDIUM_TIMES("ServiceWorker.FetchEvent.HasResponse.Time", | 417 UMA_HISTOGRAM_MEDIUM_TIMES("ServiceWorker.FetchEvent.HasResponse.Time", |
| 414 time); | 418 time); |
| 415 } else { | 419 } else { |
| 416 UMA_HISTOGRAM_MEDIUM_TIMES("ServiceWorker.FetchEvent.Fallback.Time", | 420 UMA_HISTOGRAM_MEDIUM_TIMES("ServiceWorker.FetchEvent.Fallback.Time", |
| 417 time); | 421 time); |
| 418 } | 422 } |
| 419 break; | 423 break; |
| 424 case EventType::FETCH_WAITUNTIL: |
| 425 UMA_HISTOGRAM_MEDIUM_TIMES("ServiceWorker.FetchEvent.WaitUntil.Time", |
| 426 time); |
| 427 break; |
| 420 case EventType::FOREIGN_FETCH: | 428 case EventType::FOREIGN_FETCH: |
| 421 if (was_handled) { | 429 if (was_handled) { |
| 422 UMA_HISTOGRAM_MEDIUM_TIMES( | 430 UMA_HISTOGRAM_MEDIUM_TIMES( |
| 423 "ServiceWorker.ForeignFetchEvent.HasResponse.Time", time); | 431 "ServiceWorker.ForeignFetchEvent.HasResponse.Time", time); |
| 424 } else { | 432 } else { |
| 425 UMA_HISTOGRAM_MEDIUM_TIMES( | 433 UMA_HISTOGRAM_MEDIUM_TIMES( |
| 426 "ServiceWorker.ForeignFetchEvent.Fallback.Time", time); | 434 "ServiceWorker.ForeignFetchEvent.Fallback.Time", time); |
| 427 } | 435 } |
| 428 break; | 436 break; |
| 429 case EventType::SYNC: | 437 case EventType::SYNC: |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 609 } else if (failure_count == 2) { | 617 } else if (failure_count == 2) { |
| 610 UMA_HISTOGRAM_ENUMERATION("ServiceWorker.StartWorker.AfterFailureStreak_2", | 618 UMA_HISTOGRAM_ENUMERATION("ServiceWorker.StartWorker.AfterFailureStreak_2", |
| 611 status, SERVICE_WORKER_ERROR_MAX_VALUE); | 619 status, SERVICE_WORKER_ERROR_MAX_VALUE); |
| 612 } else if (failure_count == 3) { | 620 } else if (failure_count == 3) { |
| 613 UMA_HISTOGRAM_ENUMERATION("ServiceWorker.StartWorker.AfterFailureStreak_3", | 621 UMA_HISTOGRAM_ENUMERATION("ServiceWorker.StartWorker.AfterFailureStreak_3", |
| 614 status, SERVICE_WORKER_ERROR_MAX_VALUE); | 622 status, SERVICE_WORKER_ERROR_MAX_VALUE); |
| 615 } | 623 } |
| 616 } | 624 } |
| 617 | 625 |
| 618 } // namespace content | 626 } // namespace content |
| OLD | NEW |