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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 } | 63 } |
64 | 64 |
65 void EmbeddedWorkerDispatcher::OnStartWorker( | 65 void EmbeddedWorkerDispatcher::OnStartWorker( |
66 const EmbeddedWorkerStartParams& params) { | 66 const EmbeddedWorkerStartParams& params) { |
67 DCHECK(!workers_.Lookup(params.embedded_worker_id)); | 67 DCHECK(!workers_.Lookup(params.embedded_worker_id)); |
68 TRACE_EVENT0("ServiceWorker", "EmbeddedWorkerDispatcher::OnStartWorker"); | 68 TRACE_EVENT0("ServiceWorker", "EmbeddedWorkerDispatcher::OnStartWorker"); |
69 std::unique_ptr<WorkerWrapper> wrapper = StartWorkerContext( | 69 std::unique_ptr<WorkerWrapper> wrapper = StartWorkerContext( |
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)); |
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. | 80 // OnStopWorker is possible to be called twice. |
81 if (!wrapper) { | 81 if (!wrapper) { |
82 LOG(WARNING) << "Got OnStopWorker for nonexistent worker"; | 82 LOG(WARNING) << "Got OnStopWorker for nonexistent worker"; |
83 return; | 83 return; |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 void EmbeddedWorkerDispatcher::RecordStopWorkerTimer(int embedded_worker_id) { | 173 void EmbeddedWorkerDispatcher::RecordStopWorkerTimer(int embedded_worker_id) { |
174 WorkerWrapper* wrapper = workers_.Lookup(embedded_worker_id); | 174 WorkerWrapper* wrapper = workers_.Lookup(embedded_worker_id); |
175 DCHECK(wrapper); | 175 DCHECK(wrapper); |
176 // This should eventually call WorkerContextDestroyed. (We may need to post | 176 // This should eventually call WorkerContextDestroyed. (We may need to post |
177 // a delayed task to forcibly abort the worker context if we find it | 177 // a delayed task to forcibly abort the worker context if we find it |
178 // necessary) | 178 // necessary) |
179 stop_worker_times_[embedded_worker_id] = base::TimeTicks::Now(); | 179 stop_worker_times_[embedded_worker_id] = base::TimeTicks::Now(); |
180 } | 180 } |
181 | 181 |
182 } // namespace content | 182 } // namespace content |
OLD | NEW |