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/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 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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(ContainsKey(process_sender_map_, process_id)); | 256 DCHECK(ContainsKey(process_sender_map_, process_id)); |
| 257 | 257 |
| 258 int embedded_worker_id = params->embedded_worker_id; | 258 int embedded_worker_id = params->embedded_worker_id; |
| 259 #ifndef NDEBUG | |
|
nhiroki
2016/07/19 03:37:53
"#if DCHECK_IS_ON()" would be better for DCHECK_AL
falken
2016/07/22 01:34:47
Acknowledged.
| |
| 260 // Assert the embedded worker's process id is |process_id|. | |
| 259 WorkerInstanceMap::iterator found = worker_map_.find(embedded_worker_id); | 261 WorkerInstanceMap::iterator found = worker_map_.find(embedded_worker_id); |
| 260 DCHECK(found != worker_map_.end()); | 262 DCHECK(found != worker_map_.end()); |
| 261 DCHECK_EQ(found->second->process_id(), process_id); | 263 DCHECK_EQ(found->second->process_id(), process_id); |
|
nhiroki
2016/07/19 03:37:53
Optional: I'd prefer not to have macros in a produ
falken
2016/07/22 01:34:47
Much better, done.
| |
| 262 | 264 // Assert the embedded worker is not in the map for starting/running workers. |
| 263 DCHECK(!ContainsKey(worker_process_map_, process_id) || | 265 DCHECK(!ContainsKey(worker_process_map_, process_id) || |
| 264 worker_process_map_[process_id].count(embedded_worker_id) == 0); | 266 worker_process_map_[process_id].count(embedded_worker_id) == 0); |
|
nhiroki
2016/07/19 03:37:53
Optional: "!ContainsKey(worker_process_map_[proces
falken
2016/07/22 01:34:47
Huh yea. Not sure why I used count in the first pl
| |
| 267 #endif // NDEBUG | |
| 265 | 268 |
| 266 ServiceWorkerStatusCode status = | 269 ServiceWorkerStatusCode status = |
| 267 Send(process_id, new EmbeddedWorkerMsg_StartWorker(*params)); | 270 Send(process_id, new EmbeddedWorkerMsg_StartWorker(*params)); |
| 268 if (status == SERVICE_WORKER_OK) | 271 if (status == SERVICE_WORKER_OK) |
| 269 worker_process_map_[process_id].insert(embedded_worker_id); | 272 worker_process_map_[process_id].insert(embedded_worker_id); |
| 270 return status; | 273 return status; |
| 271 } | 274 } |
| 272 | 275 |
| 273 ServiceWorkerStatusCode EmbeddedWorkerRegistry::Send( | 276 ServiceWorkerStatusCode EmbeddedWorkerRegistry::Send( |
| 274 int process_id, IPC::Message* message_ptr) { | 277 int process_id, IPC::Message* message_ptr) { |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 300 EmbeddedWorkerInstance* worker = GetWorker(embedded_worker_id); | 303 EmbeddedWorkerInstance* worker = GetWorker(embedded_worker_id); |
| 301 if (!worker || worker->process_id() != process_id) { | 304 if (!worker || worker->process_id() != process_id) { |
| 302 UMA_HISTOGRAM_BOOLEAN("ServiceWorker.WorkerForMessageFound", false); | 305 UMA_HISTOGRAM_BOOLEAN("ServiceWorker.WorkerForMessageFound", false); |
| 303 return nullptr; | 306 return nullptr; |
| 304 } | 307 } |
| 305 UMA_HISTOGRAM_BOOLEAN("ServiceWorker.WorkerForMessageFound", true); | 308 UMA_HISTOGRAM_BOOLEAN("ServiceWorker.WorkerForMessageFound", true); |
| 306 return worker; | 309 return worker; |
| 307 } | 310 } |
| 308 | 311 |
| 309 } // namespace content | 312 } // namespace content |
| OLD | NEW |