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 <limits> | 9 #include <limits> |
10 #include <map> | 10 #include <map> |
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 context_(context), | 310 context_(context), |
311 script_cache_map_(this, context), | 311 script_cache_map_(this, context), |
312 ping_controller_(new PingController(this)), | 312 ping_controller_(new PingController(this)), |
313 should_exclude_from_uma_( | 313 should_exclude_from_uma_( |
314 ServiceWorkerMetrics::ShouldExcludeSiteFromHistogram(site_for_uma_)), | 314 ServiceWorkerMetrics::ShouldExcludeSiteFromHistogram(site_for_uma_)), |
315 weak_factory_(this) { | 315 weak_factory_(this) { |
316 DCHECK_NE(kInvalidServiceWorkerVersionId, version_id); | 316 DCHECK_NE(kInvalidServiceWorkerVersionId, version_id); |
317 DCHECK(context_); | 317 DCHECK(context_); |
318 DCHECK(registration); | 318 DCHECK(registration); |
319 DCHECK(script_url_.is_valid()); | 319 DCHECK(script_url_.is_valid()); |
320 context_->AddLiveVersion(this); | |
321 embedded_worker_ = context_->embedded_worker_registry()->CreateWorker(); | 320 embedded_worker_ = context_->embedded_worker_registry()->CreateWorker(); |
322 embedded_worker_->AddListener(this); | 321 embedded_worker_->AddListener(this); |
| 322 context_->AddLiveVersion(this); |
323 } | 323 } |
324 | 324 |
325 ServiceWorkerVersion::~ServiceWorkerVersion() { | 325 ServiceWorkerVersion::~ServiceWorkerVersion() { |
326 in_dtor_ = true; | 326 in_dtor_ = true; |
327 | 327 |
328 // Record UMA if the worker was trying to start. One way we get here is if the | 328 // Record UMA if the worker was trying to start. One way we get here is if the |
329 // user closed the tab before the SW could start up. | 329 // user closed the tab before the SW could start up. |
330 if (!start_callbacks_.empty()) { | 330 if (!start_callbacks_.empty()) { |
331 // RecordStartWorkerResult must be the first element of start_callbacks_. | 331 // RecordStartWorkerResult must be the first element of start_callbacks_. |
332 StatusCallback record_start_worker_result = start_callbacks_[0]; | 332 StatusCallback record_start_worker_result = start_callbacks_[0]; |
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
861 void ServiceWorkerVersion::OnScriptLoaded() { | 861 void ServiceWorkerVersion::OnScriptLoaded() { |
862 if (IsInstalled(status())) | 862 if (IsInstalled(status())) |
863 UMA_HISTOGRAM_BOOLEAN("ServiceWorker.ScriptLoadSuccess", true); | 863 UMA_HISTOGRAM_BOOLEAN("ServiceWorker.ScriptLoadSuccess", true); |
864 } | 864 } |
865 | 865 |
866 void ServiceWorkerVersion::OnScriptLoadFailed() { | 866 void ServiceWorkerVersion::OnScriptLoadFailed() { |
867 if (IsInstalled(status())) | 867 if (IsInstalled(status())) |
868 UMA_HISTOGRAM_BOOLEAN("ServiceWorker.ScriptLoadSuccess", false); | 868 UMA_HISTOGRAM_BOOLEAN("ServiceWorker.ScriptLoadSuccess", false); |
869 } | 869 } |
870 | 870 |
| 871 void ServiceWorkerVersion::OnRegisteredToDevToolsManager() { |
| 872 FOR_EACH_OBSERVER(Listener, listeners_, OnDevToolsRoutingIdChanged(this)); |
| 873 } |
| 874 |
871 void ServiceWorkerVersion::OnReportException( | 875 void ServiceWorkerVersion::OnReportException( |
872 const base::string16& error_message, | 876 const base::string16& error_message, |
873 int line_number, | 877 int line_number, |
874 int column_number, | 878 int column_number, |
875 const GURL& source_url) { | 879 const GURL& source_url) { |
876 FOR_EACH_OBSERVER( | 880 FOR_EACH_OBSERVER( |
877 Listener, | 881 Listener, |
878 listeners_, | 882 listeners_, |
879 OnErrorReported( | 883 OnErrorReported( |
880 this, error_message, line_number, column_number, source_url)); | 884 this, error_message, line_number, column_number, source_url)); |
(...skipping 909 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1790 ServiceWorkerMetrics::RecordTimeBetweenEvents(base::TimeTicks::Now() - | 1794 ServiceWorkerMetrics::RecordTimeBetweenEvents(base::TimeTicks::Now() - |
1791 idle_time_); | 1795 idle_time_); |
1792 } | 1796 } |
1793 | 1797 |
1794 void ServiceWorkerVersion::FinishStartWorker(ServiceWorkerStatusCode status) { | 1798 void ServiceWorkerVersion::FinishStartWorker(ServiceWorkerStatusCode status) { |
1795 start_worker_first_purpose_ = base::nullopt; | 1799 start_worker_first_purpose_ = base::nullopt; |
1796 RunCallbacks(this, &start_callbacks_, status); | 1800 RunCallbacks(this, &start_callbacks_, status); |
1797 } | 1801 } |
1798 | 1802 |
1799 } // namespace content | 1803 } // namespace content |
OLD | NEW |