| 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 case ServiceWorkerMetrics::EventType::FETCH_SUB_FRAME: | 59 case ServiceWorkerMetrics::EventType::FETCH_SUB_FRAME: |
| 60 return "_FETCH_SUB_FRAME"; | 60 return "_FETCH_SUB_FRAME"; |
| 61 case ServiceWorkerMetrics::EventType::FETCH_SHARED_WORKER: | 61 case ServiceWorkerMetrics::EventType::FETCH_SHARED_WORKER: |
| 62 return "_FETCH_SHARED_WORKER"; | 62 return "_FETCH_SHARED_WORKER"; |
| 63 case ServiceWorkerMetrics::EventType::FETCH_SUB_RESOURCE: | 63 case ServiceWorkerMetrics::EventType::FETCH_SUB_RESOURCE: |
| 64 return "_FETCH_SUB_RESOURCE"; | 64 return "_FETCH_SUB_RESOURCE"; |
| 65 case ServiceWorkerMetrics::EventType::UNKNOWN: | 65 case ServiceWorkerMetrics::EventType::UNKNOWN: |
| 66 return "_UNKNOWN"; | 66 return "_UNKNOWN"; |
| 67 case ServiceWorkerMetrics::EventType::FOREIGN_FETCH: | 67 case ServiceWorkerMetrics::EventType::FOREIGN_FETCH: |
| 68 return "_FOREIGN_FETCH"; | 68 return "_FOREIGN_FETCH"; |
| 69 case ServiceWorkerMetrics::EventType::FETCH_WAITUNTIL: |
| 70 return "_FETCH_WAITUNTIL"; |
| 69 case ServiceWorkerMetrics::EventType::NUM_TYPES: | 71 case ServiceWorkerMetrics::EventType::NUM_TYPES: |
| 70 NOTREACHED() << static_cast<int>(event_type); | 72 NOTREACHED() << static_cast<int>(event_type); |
| 71 } | 73 } |
| 72 return "_UNKNOWN"; | 74 return "_UNKNOWN"; |
| 73 } | 75 } |
| 74 | 76 |
| 75 // Use this for histograms with dynamically generated names, which | 77 // Use this for histograms with dynamically generated names, which |
| 76 // otherwise can't use the UMA_HISTOGRAM macro without code duplication. | 78 // otherwise can't use the UMA_HISTOGRAM macro without code duplication. |
| 77 void RecordSuffixedTimeHistogram(const std::string& name, | 79 void RecordSuffixedTimeHistogram(const std::string& name, |
| 78 const std::string& suffix, | 80 const std::string& suffix, |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 case EventType::FETCH_SUB_FRAME: | 153 case EventType::FETCH_SUB_FRAME: |
| 152 return "Fetch Sub Frame"; | 154 return "Fetch Sub Frame"; |
| 153 case EventType::FETCH_SHARED_WORKER: | 155 case EventType::FETCH_SHARED_WORKER: |
| 154 return "Fetch Shared Worker"; | 156 return "Fetch Shared Worker"; |
| 155 case EventType::FETCH_SUB_RESOURCE: | 157 case EventType::FETCH_SUB_RESOURCE: |
| 156 return "Fetch Subresource"; | 158 return "Fetch Subresource"; |
| 157 case EventType::UNKNOWN: | 159 case EventType::UNKNOWN: |
| 158 return "Unknown"; | 160 return "Unknown"; |
| 159 case EventType::FOREIGN_FETCH: | 161 case EventType::FOREIGN_FETCH: |
| 160 return "Foreign Fetch"; | 162 return "Foreign Fetch"; |
| 163 case EventType::FETCH_WAITUNTIL: |
| 164 return "Fetch WaitUntil"; |
| 161 case EventType::NUM_TYPES: | 165 case EventType::NUM_TYPES: |
| 162 break; | 166 break; |
| 163 } | 167 } |
| 164 NOTREACHED() << "Got unexpected event type: " << static_cast<int>(event_type); | 168 NOTREACHED() << "Got unexpected event type: " << static_cast<int>(event_type); |
| 165 return "error"; | 169 return "error"; |
| 166 } | 170 } |
| 167 | 171 |
| 168 bool ServiceWorkerMetrics::ShouldExcludeSiteFromHistogram(Site site) { | 172 bool ServiceWorkerMetrics::ShouldExcludeSiteFromHistogram(Site site) { |
| 169 return site == ServiceWorkerMetrics::Site::NEW_TAB_PAGE; | 173 return site == ServiceWorkerMetrics::Site::NEW_TAB_PAGE; |
| 170 } | 174 } |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 case EventType::FETCH_SHARED_WORKER: | 374 case EventType::FETCH_SHARED_WORKER: |
| 371 case EventType::FETCH_SUB_RESOURCE: | 375 case EventType::FETCH_SUB_RESOURCE: |
| 372 if (was_handled) { | 376 if (was_handled) { |
| 373 UMA_HISTOGRAM_MEDIUM_TIMES("ServiceWorker.FetchEvent.HasResponse.Time", | 377 UMA_HISTOGRAM_MEDIUM_TIMES("ServiceWorker.FetchEvent.HasResponse.Time", |
| 374 time); | 378 time); |
| 375 } else { | 379 } else { |
| 376 UMA_HISTOGRAM_MEDIUM_TIMES("ServiceWorker.FetchEvent.Fallback.Time", | 380 UMA_HISTOGRAM_MEDIUM_TIMES("ServiceWorker.FetchEvent.Fallback.Time", |
| 377 time); | 381 time); |
| 378 } | 382 } |
| 379 break; | 383 break; |
| 384 case EventType::FETCH_WAITUNTIL: |
| 385 UMA_HISTOGRAM_MEDIUM_TIMES("ServiceWorker.FetchEvent.WaitUntil.Time", |
| 386 time); |
| 387 break; |
| 380 case EventType::FOREIGN_FETCH: | 388 case EventType::FOREIGN_FETCH: |
| 381 if (was_handled) { | 389 if (was_handled) { |
| 382 UMA_HISTOGRAM_MEDIUM_TIMES( | 390 UMA_HISTOGRAM_MEDIUM_TIMES( |
| 383 "ServiceWorker.ForeignFetchEvent.HasResponse.Time", time); | 391 "ServiceWorker.ForeignFetchEvent.HasResponse.Time", time); |
| 384 } else { | 392 } else { |
| 385 UMA_HISTOGRAM_MEDIUM_TIMES( | 393 UMA_HISTOGRAM_MEDIUM_TIMES( |
| 386 "ServiceWorker.ForeignFetchEvent.Fallback.Time", time); | 394 "ServiceWorker.ForeignFetchEvent.Fallback.Time", time); |
| 387 } | 395 } |
| 388 break; | 396 break; |
| 389 case EventType::SYNC: | 397 case EventType::SYNC: |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 569 } else if (failure_count == 2) { | 577 } else if (failure_count == 2) { |
| 570 UMA_HISTOGRAM_ENUMERATION("ServiceWorker.StartWorker.AfterFailureStreak_2", | 578 UMA_HISTOGRAM_ENUMERATION("ServiceWorker.StartWorker.AfterFailureStreak_2", |
| 571 status, SERVICE_WORKER_ERROR_MAX_VALUE); | 579 status, SERVICE_WORKER_ERROR_MAX_VALUE); |
| 572 } else if (failure_count == 3) { | 580 } else if (failure_count == 3) { |
| 573 UMA_HISTOGRAM_ENUMERATION("ServiceWorker.StartWorker.AfterFailureStreak_3", | 581 UMA_HISTOGRAM_ENUMERATION("ServiceWorker.StartWorker.AfterFailureStreak_3", |
| 574 status, SERVICE_WORKER_ERROR_MAX_VALUE); | 582 status, SERVICE_WORKER_ERROR_MAX_VALUE); |
| 575 } | 583 } |
| 576 } | 584 } |
| 577 | 585 |
| 578 } // namespace content | 586 } // namespace content |
| OLD | NEW |