| 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); |
| 95 found->second->OnScriptLoaded(); |
| 96 } |
| 97 |
| 87 void EmbeddedWorkerRegistry::OnWorkerStarted( | 98 void EmbeddedWorkerRegistry::OnWorkerStarted( |
| 88 int process_id, int thread_id, int embedded_worker_id) { | 99 int process_id, int thread_id, int embedded_worker_id) { |
| 89 DCHECK(!ContainsKey(worker_process_map_, process_id) || | 100 DCHECK(!ContainsKey(worker_process_map_, process_id) || |
| 90 worker_process_map_[process_id].count(embedded_worker_id) == 0); | 101 worker_process_map_[process_id].count(embedded_worker_id) == 0); |
| 91 WorkerInstanceMap::iterator found = worker_map_.find(embedded_worker_id); | 102 WorkerInstanceMap::iterator found = worker_map_.find(embedded_worker_id); |
| 92 if (found == worker_map_.end()) { | 103 if (found == worker_map_.end()) { |
| 93 LOG(ERROR) << "Worker " << embedded_worker_id << " not registered"; | 104 LOG(ERROR) << "Worker " << embedded_worker_id << " not registered"; |
| 94 return; | 105 return; |
| 95 } | 106 } |
| 96 worker_process_map_[process_id].insert(embedded_worker_id); | 107 worker_process_map_[process_id].insert(embedded_worker_id); |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 } | 238 } |
| 228 | 239 |
| 229 void EmbeddedWorkerRegistry::RemoveWorker(int process_id, | 240 void EmbeddedWorkerRegistry::RemoveWorker(int process_id, |
| 230 int embedded_worker_id) { | 241 int embedded_worker_id) { |
| 231 DCHECK(ContainsKey(worker_map_, embedded_worker_id)); | 242 DCHECK(ContainsKey(worker_map_, embedded_worker_id)); |
| 232 worker_map_.erase(embedded_worker_id); | 243 worker_map_.erase(embedded_worker_id); |
| 233 worker_process_map_.erase(process_id); | 244 worker_process_map_.erase(process_id); |
| 234 } | 245 } |
| 235 | 246 |
| 236 } // namespace content | 247 } // namespace content |
| OLD | NEW |