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/embedded_worker_registry.h" | 5 #include "content/browser/service_worker/embedded_worker_registry.h" |
6 | 6 |
7 #include "base/bind_helpers.h" | 7 #include "base/bind_helpers.h" |
8 #include "base/metrics/histogram_macros.h" | 8 #include "base/metrics/histogram_macros.h" |
9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
10 #include "content/browser/renderer_host/render_widget_helper.h" | 10 #include "content/browser/renderer_host/render_widget_helper.h" |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 std::unique_ptr<EmbeddedWorkerStartParams> params, | 248 std::unique_ptr<EmbeddedWorkerStartParams> params, |
249 int process_id) { | 249 int process_id) { |
250 if (!context_) | 250 if (!context_) |
251 return SERVICE_WORKER_ERROR_ABORT; | 251 return SERVICE_WORKER_ERROR_ABORT; |
252 | 252 |
253 // The ServiceWorkerDispatcherHost is supposed to be created when the process | 253 // The ServiceWorkerDispatcherHost is supposed to be created when the process |
254 // is created, and keep an entry in process_sender_map_ for its whole | 254 // is created, and keep an entry in process_sender_map_ for its whole |
255 // lifetime. | 255 // lifetime. |
256 DCHECK(base::ContainsKey(process_sender_map_, process_id)); | 256 DCHECK(base::ContainsKey(process_sender_map_, process_id)); |
257 | 257 |
258 int embedded_worker_id = params->embedded_worker_id; | 258 int embedded_worker_id = params->internal.embedded_worker_id; |
259 DCHECK(GetWorker(embedded_worker_id)); | 259 DCHECK(GetWorker(embedded_worker_id)); |
260 DCHECK_EQ(GetWorker(embedded_worker_id)->process_id(), process_id); | 260 DCHECK_EQ(GetWorker(embedded_worker_id)->process_id(), process_id); |
261 DCHECK( | 261 DCHECK( |
262 !base::ContainsKey(worker_process_map_, process_id) || | 262 !base::ContainsKey(worker_process_map_, process_id) || |
263 !base::ContainsKey(worker_process_map_[process_id], embedded_worker_id)); | 263 !base::ContainsKey(worker_process_map_[process_id], embedded_worker_id)); |
264 | 264 |
265 ServiceWorkerStatusCode status = | 265 ServiceWorkerStatusCode status = |
266 Send(process_id, new EmbeddedWorkerMsg_StartWorker(*params)); | 266 Send(process_id, new EmbeddedWorkerMsg_StartWorker(params->internal)); |
267 if (status == SERVICE_WORKER_OK) | 267 if (status == SERVICE_WORKER_OK) |
268 BindWorkerToProcess(process_id, embedded_worker_id); | 268 BindWorkerToProcess(process_id, embedded_worker_id); |
269 return status; | 269 return status; |
270 } | 270 } |
271 | 271 |
272 void EmbeddedWorkerRegistry::BindWorkerToProcess(int process_id, | 272 void EmbeddedWorkerRegistry::BindWorkerToProcess(int process_id, |
273 int embedded_worker_id) { | 273 int embedded_worker_id) { |
274 // The ServiceWorkerDispatcherHost is supposed to be created when the process | 274 // The ServiceWorkerDispatcherHost is supposed to be created when the process |
275 // is created, and keep an entry in process_sender_map_ for its whole | 275 // is created, and keep an entry in process_sender_map_ for its whole |
276 // lifetime. | 276 // lifetime. |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 EmbeddedWorkerInstance* worker = GetWorker(embedded_worker_id); | 320 EmbeddedWorkerInstance* worker = GetWorker(embedded_worker_id); |
321 if (!worker || worker->process_id() != process_id) { | 321 if (!worker || worker->process_id() != process_id) { |
322 UMA_HISTOGRAM_BOOLEAN("ServiceWorker.WorkerForMessageFound", false); | 322 UMA_HISTOGRAM_BOOLEAN("ServiceWorker.WorkerForMessageFound", false); |
323 return nullptr; | 323 return nullptr; |
324 } | 324 } |
325 UMA_HISTOGRAM_BOOLEAN("ServiceWorker.WorkerForMessageFound", true); | 325 UMA_HISTOGRAM_BOOLEAN("ServiceWorker.WorkerForMessageFound", true); |
326 return worker; | 326 return worker; |
327 } | 327 } |
328 | 328 |
329 } // namespace content | 329 } // namespace content |
OLD | NEW |