Chromium Code Reviews| 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/renderer/service_worker/embedded_worker_dispatcher.h" | 5 #include "content/renderer/service_worker/embedded_worker_dispatcher.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/metrics/histogram_macros.h" | 9 #include "base/metrics/histogram_macros.h" |
| 10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 70 params, base::MakeUnique<ServiceWorkerContextClient>( | 70 params, base::MakeUnique<ServiceWorkerContextClient>( |
| 71 params.embedded_worker_id, params.service_worker_version_id, | 71 params.embedded_worker_id, params.service_worker_version_id, |
| 72 params.scope, params.script_url, | 72 params.scope, params.script_url, |
| 73 params.worker_devtools_agent_route_id, nullptr)); | 73 params.worker_devtools_agent_route_id, nullptr)); |
| 74 RegisterWorker(params.embedded_worker_id, std::move(wrapper)); | 74 RegisterWorker(params.embedded_worker_id, std::move(wrapper)); |
| 75 } | 75 } |
| 76 | 76 |
| 77 void EmbeddedWorkerDispatcher::OnStopWorker(int embedded_worker_id) { | 77 void EmbeddedWorkerDispatcher::OnStopWorker(int embedded_worker_id) { |
| 78 TRACE_EVENT0("ServiceWorker", "EmbeddedWorkerDispatcher::OnStopWorker"); | 78 TRACE_EVENT0("ServiceWorker", "EmbeddedWorkerDispatcher::OnStopWorker"); |
| 79 WorkerWrapper* wrapper = workers_.Lookup(embedded_worker_id); | 79 WorkerWrapper* wrapper = workers_.Lookup(embedded_worker_id); |
| 80 // OnStopWorker is possible to be called twice. | |
| 81 if (!wrapper) { | |
| 82 LOG(WARNING) << "Got OnStopWorker for nonexistent worker"; | |
| 83 return; | |
| 84 } | |
| 80 DCHECK(wrapper); | 85 DCHECK(wrapper); |
|
nhiroki
2016/10/20 09:22:11
This DCHECK is obvious. Can you remove this?
shimazu
2016/10/21 01:17:02
Done.
| |
| 81 // This should eventually call WorkerContextDestroyed. (We may need to post | 86 // This should eventually call WorkerContextDestroyed. (We may need to post |
| 82 // a delayed task to forcibly abort the worker context if we find it | 87 // a delayed task to forcibly abort the worker context if we find it |
| 83 // necessary) | 88 // necessary) |
| 84 stop_worker_times_[embedded_worker_id] = base::TimeTicks::Now(); | 89 stop_worker_times_[embedded_worker_id] = base::TimeTicks::Now(); |
| 85 wrapper->worker()->terminateWorkerContext(); | 90 wrapper->worker()->terminateWorkerContext(); |
| 86 } | 91 } |
| 87 | 92 |
| 88 void EmbeddedWorkerDispatcher::OnResumeAfterDownload(int embedded_worker_id) { | 93 void EmbeddedWorkerDispatcher::OnResumeAfterDownload(int embedded_worker_id) { |
| 89 TRACE_EVENT0("ServiceWorker", | 94 TRACE_EVENT0("ServiceWorker", |
| 90 "EmbeddedWorkerDispatcher::OnResumeAfterDownload"); | 95 "EmbeddedWorkerDispatcher::OnResumeAfterDownload"); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 169 void EmbeddedWorkerDispatcher::RecordStopWorkerTimer(int embedded_worker_id) { | 174 void EmbeddedWorkerDispatcher::RecordStopWorkerTimer(int embedded_worker_id) { |
| 170 WorkerWrapper* wrapper = workers_.Lookup(embedded_worker_id); | 175 WorkerWrapper* wrapper = workers_.Lookup(embedded_worker_id); |
| 171 DCHECK(wrapper); | 176 DCHECK(wrapper); |
| 172 // This should eventually call WorkerContextDestroyed. (We may need to post | 177 // This should eventually call WorkerContextDestroyed. (We may need to post |
| 173 // a delayed task to forcibly abort the worker context if we find it | 178 // a delayed task to forcibly abort the worker context if we find it |
| 174 // necessary) | 179 // necessary) |
| 175 stop_worker_times_[embedded_worker_id] = base::TimeTicks::Now(); | 180 stop_worker_times_[embedded_worker_id] = base::TimeTicks::Now(); |
| 176 } | 181 } |
| 177 | 182 |
| 178 } // namespace content | 183 } // namespace content |
| OLD | NEW |