OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_version.h" | 5 #include "content/browser/service_worker/service_worker_version.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <string> | 10 #include <string> |
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
471 if (update_timer_.IsRunning()) | 471 if (update_timer_.IsRunning()) |
472 update_timer_.Reset(); | 472 update_timer_.Reset(); |
473 } | 473 } |
474 | 474 |
475 int ServiceWorkerVersion::StartRequest( | 475 int ServiceWorkerVersion::StartRequest( |
476 ServiceWorkerMetrics::EventType event_type, | 476 ServiceWorkerMetrics::EventType event_type, |
477 const StatusCallback& error_callback) { | 477 const StatusCallback& error_callback) { |
478 OnBeginEvent(); | 478 OnBeginEvent(); |
479 DCHECK_EQ(RUNNING, running_status()) | 479 DCHECK_EQ(RUNNING, running_status()) |
480 << "Can only start a request with a running worker."; | 480 << "Can only start a request with a running worker."; |
| 481 DCHECK(event_type == ServiceWorkerMetrics::EventType::INSTALL || |
| 482 event_type == ServiceWorkerMetrics::EventType::ACTIVATE || |
| 483 event_type == ServiceWorkerMetrics::EventType::MESSAGE || |
| 484 status() == ACTIVATED) |
| 485 << "Event of type " << static_cast<int>(event_type) |
| 486 << " can only be dispatched to an active worker: " << status(); |
481 return AddRequest(error_callback, &custom_requests_, REQUEST_CUSTOM, | 487 return AddRequest(error_callback, &custom_requests_, REQUEST_CUSTOM, |
482 event_type); | 488 event_type); |
483 } | 489 } |
484 | 490 |
485 int ServiceWorkerVersion::StartRequestWithCustomTimeout( | 491 int ServiceWorkerVersion::StartRequestWithCustomTimeout( |
486 ServiceWorkerMetrics::EventType event_type, | 492 ServiceWorkerMetrics::EventType event_type, |
487 const StatusCallback& error_callback, | 493 const StatusCallback& error_callback, |
488 const base::TimeDelta& timeout, | 494 const base::TimeDelta& timeout, |
489 TimeoutBehavior timeout_behavior) { | 495 TimeoutBehavior timeout_behavior) { |
490 OnBeginEvent(); | 496 OnBeginEvent(); |
(...skipping 1487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1978 void ServiceWorkerVersion::OnBeginEvent() { | 1984 void ServiceWorkerVersion::OnBeginEvent() { |
1979 if (should_exclude_from_uma_ || running_status() != RUNNING || | 1985 if (should_exclude_from_uma_ || running_status() != RUNNING || |
1980 idle_time_.is_null()) { | 1986 idle_time_.is_null()) { |
1981 return; | 1987 return; |
1982 } | 1988 } |
1983 ServiceWorkerMetrics::RecordTimeBetweenEvents(base::TimeTicks::Now() - | 1989 ServiceWorkerMetrics::RecordTimeBetweenEvents(base::TimeTicks::Now() - |
1984 idle_time_); | 1990 idle_time_); |
1985 } | 1991 } |
1986 | 1992 |
1987 } // namespace content | 1993 } // namespace content |
OLD | NEW |