| 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 "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/metrics/histogram_macros.h" | 9 #include "base/metrics/histogram_macros.h" |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 1522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1533 !sync_callbacks_.IsEmpty() || | 1533 !sync_callbacks_.IsEmpty() || |
| 1534 !notification_click_callbacks_.IsEmpty() || | 1534 !notification_click_callbacks_.IsEmpty() || |
| 1535 !push_callbacks_.IsEmpty() || | 1535 !push_callbacks_.IsEmpty() || |
| 1536 !geofencing_callbacks_.IsEmpty() || | 1536 !geofencing_callbacks_.IsEmpty() || |
| 1537 !cross_origin_connect_callbacks_.IsEmpty() || | 1537 !cross_origin_connect_callbacks_.IsEmpty() || |
| 1538 !streaming_url_request_jobs_.empty(); | 1538 !streaming_url_request_jobs_.empty(); |
| 1539 } | 1539 } |
| 1540 | 1540 |
| 1541 void ServiceWorkerVersion::RecordStartWorkerResult( | 1541 void ServiceWorkerVersion::RecordStartWorkerResult( |
| 1542 ServiceWorkerStatusCode status) { | 1542 ServiceWorkerStatusCode status) { |
| 1543 base::TimeTicks start_time = start_time_; |
| 1544 ClearTick(&start_time_); |
| 1545 |
| 1546 // Failing to start a doomed worker isn't interesting and very common when |
| 1547 // update dooms because the script is byte-to-byte identical. |
| 1548 if (is_doomed_) |
| 1549 return; |
| 1550 |
| 1543 UMA_HISTOGRAM_ENUMERATION("ServiceWorker.StartWorker.Status", status, | 1551 UMA_HISTOGRAM_ENUMERATION("ServiceWorker.StartWorker.Status", status, |
| 1544 SERVICE_WORKER_ERROR_MAX_VALUE); | 1552 SERVICE_WORKER_ERROR_MAX_VALUE); |
| 1545 if (status == SERVICE_WORKER_OK && !start_time_.is_null()) { | 1553 if (status == SERVICE_WORKER_OK && !start_time.is_null()) { |
| 1546 UMA_HISTOGRAM_MEDIUM_TIMES("ServiceWorker.StartWorker.Time", | 1554 UMA_HISTOGRAM_MEDIUM_TIMES("ServiceWorker.StartWorker.Time", |
| 1547 GetTickDuration(start_time_)); | 1555 GetTickDuration(start_time)); |
| 1548 } | 1556 } |
| 1549 | 1557 |
| 1550 ClearTick(&start_time_); | |
| 1551 if (status != SERVICE_WORKER_ERROR_TIMEOUT) | 1558 if (status != SERVICE_WORKER_ERROR_TIMEOUT) |
| 1552 return; | 1559 return; |
| 1553 EmbeddedWorkerInstance::StartingPhase phase = | 1560 EmbeddedWorkerInstance::StartingPhase phase = |
| 1554 EmbeddedWorkerInstance::NOT_STARTING; | 1561 EmbeddedWorkerInstance::NOT_STARTING; |
| 1555 EmbeddedWorkerInstance::Status running_status = embedded_worker_->status(); | 1562 EmbeddedWorkerInstance::Status running_status = embedded_worker_->status(); |
| 1556 // Build an artifical JavaScript exception to show in the ServiceWorker | 1563 // Build an artifical JavaScript exception to show in the ServiceWorker |
| 1557 // log for developers; it's not user-facing so it's not a localized resource. | 1564 // log for developers; it's not user-facing so it's not a localized resource. |
| 1558 std::string message = "ServiceWorker startup timed out. "; | 1565 std::string message = "ServiceWorker startup timed out. "; |
| 1559 if (running_status != EmbeddedWorkerInstance::STARTING) { | 1566 if (running_status != EmbeddedWorkerInstance::STARTING) { |
| 1560 message.append("The worker had unexpected status: "); | 1567 message.append("The worker had unexpected status: "); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 1590 int request_id) { | 1597 int request_id) { |
| 1591 callbacks->Remove(request_id); | 1598 callbacks->Remove(request_id); |
| 1592 if (is_doomed_) { | 1599 if (is_doomed_) { |
| 1593 // The stop should be already scheduled, but try to stop immediately, in | 1600 // The stop should be already scheduled, but try to stop immediately, in |
| 1594 // order to release worker resources soon. | 1601 // order to release worker resources soon. |
| 1595 StopWorkerIfIdle(); | 1602 StopWorkerIfIdle(); |
| 1596 } | 1603 } |
| 1597 } | 1604 } |
| 1598 | 1605 |
| 1599 } // namespace content | 1606 } // namespace content |
| OLD | NEW |