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/stl_util.h" | 8 #include "base/stl_util.h" |
| 9 #include "content/browser/renderer_host/render_widget_helper.h" | 9 #include "content/browser/renderer_host/render_widget_helper.h" |
| 10 #include "content/browser/service_worker/embedded_worker_instance.h" | 10 #include "content/browser/service_worker/embedded_worker_instance.h" |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 77 } | 77 } |
| 78 | 78 |
| 79 void EmbeddedWorkerRegistry::Shutdown() { | 79 void EmbeddedWorkerRegistry::Shutdown() { |
| 80 for (WorkerInstanceMap::iterator it = worker_map_.begin(); | 80 for (WorkerInstanceMap::iterator it = worker_map_.begin(); |
| 81 it != worker_map_.end(); | 81 it != worker_map_.end(); |
| 82 ++it) { | 82 ++it) { |
| 83 it->second->Stop(); | 83 it->second->Stop(); |
| 84 } | 84 } |
| 85 } | 85 } |
| 86 | 86 |
| 87 void EmbeddedWorkerRegistry::OnWorkerScriptLoaded(int process_id, | |
| 88 int embedded_worker_id) { | |
| 89 WorkerInstanceMap::iterator found = worker_map_.find(embedded_worker_id); | |
| 90 if (found == worker_map_.end()) { | |
| 91 LOG(ERROR) << "Worker " << embedded_worker_id << " not registered"; | |
| 92 return; | |
| 93 } | |
| 94 DCHECK_EQ(found->second->process_id(), process_id); | |
|
nasko
2014/05/02 16:24:46
What are the implications of this check failing? W
horo
2014/05/06 00:26:48
Done.
| |
| 95 found->second->OnScriptLoaded(); | |
| 96 } | |
| 97 | |
| 98 void EmbeddedWorkerRegistry::OnWorkerScriptLoadFailed(int process_id, | |
| 99 int embedded_worker_id) { | |
| 100 WorkerInstanceMap::iterator found = worker_map_.find(embedded_worker_id); | |
| 101 if (found == worker_map_.end()) { | |
| 102 LOG(ERROR) << "Worker " << embedded_worker_id << " not registered"; | |
| 103 return; | |
| 104 } | |
| 105 DCHECK_EQ(found->second->process_id(), process_id); | |
| 106 found->second->OnScriptLoadFailed(); | |
| 107 } | |
| 108 | |
| 87 void EmbeddedWorkerRegistry::OnWorkerStarted( | 109 void EmbeddedWorkerRegistry::OnWorkerStarted( |
| 88 int process_id, int thread_id, int embedded_worker_id) { | 110 int process_id, int thread_id, int embedded_worker_id) { |
| 89 DCHECK(!ContainsKey(worker_process_map_, process_id) || | 111 DCHECK(!ContainsKey(worker_process_map_, process_id) || |
| 90 worker_process_map_[process_id].count(embedded_worker_id) == 0); | 112 worker_process_map_[process_id].count(embedded_worker_id) == 0); |
| 91 WorkerInstanceMap::iterator found = worker_map_.find(embedded_worker_id); | 113 WorkerInstanceMap::iterator found = worker_map_.find(embedded_worker_id); |
| 92 if (found == worker_map_.end()) { | 114 if (found == worker_map_.end()) { |
| 93 LOG(ERROR) << "Worker " << embedded_worker_id << " not registered"; | 115 LOG(ERROR) << "Worker " << embedded_worker_id << " not registered"; |
| 94 return; | 116 return; |
| 95 } | 117 } |
| 96 worker_process_map_[process_id].insert(embedded_worker_id); | 118 worker_process_map_[process_id].insert(embedded_worker_id); |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 227 } | 249 } |
| 228 | 250 |
| 229 void EmbeddedWorkerRegistry::RemoveWorker(int process_id, | 251 void EmbeddedWorkerRegistry::RemoveWorker(int process_id, |
| 230 int embedded_worker_id) { | 252 int embedded_worker_id) { |
| 231 DCHECK(ContainsKey(worker_map_, embedded_worker_id)); | 253 DCHECK(ContainsKey(worker_map_, embedded_worker_id)); |
| 232 worker_map_.erase(embedded_worker_id); | 254 worker_map_.erase(embedded_worker_id); |
| 233 worker_process_map_.erase(process_id); | 255 worker_process_map_.erase(process_id); |
| 234 } | 256 } |
| 235 | 257 |
| 236 } // namespace content | 258 } // namespace content |
| OLD | NEW |