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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 int process_id, | 72 int process_id, |
73 int embedded_worker_id) { | 73 int embedded_worker_id) { |
74 WorkerInstanceMap::iterator found = worker_map_.find(embedded_worker_id); | 74 WorkerInstanceMap::iterator found = worker_map_.find(embedded_worker_id); |
75 DCHECK(found != worker_map_.end()); | 75 DCHECK(found != worker_map_.end()); |
76 DCHECK_EQ(found->second->process_id(), process_id); | 76 DCHECK_EQ(found->second->process_id(), process_id); |
77 if (found == worker_map_.end() || found->second->process_id() != process_id) | 77 if (found == worker_map_.end() || found->second->process_id() != process_id) |
78 return; | 78 return; |
79 found->second->OnReadyForInspection(); | 79 found->second->OnReadyForInspection(); |
80 } | 80 } |
81 | 81 |
82 void EmbeddedWorkerRegistry::OnWorkerScriptLoaded( | 82 void EmbeddedWorkerRegistry::OnWorkerScriptLoaded(int process_id, |
83 int process_id, | 83 int embedded_worker_id) { |
84 int thread_id, | |
85 int embedded_worker_id ) { | |
86 WorkerInstanceMap::iterator found = worker_map_.find(embedded_worker_id); | 84 WorkerInstanceMap::iterator found = worker_map_.find(embedded_worker_id); |
87 DCHECK(found != worker_map_.end()); | 85 DCHECK(found != worker_map_.end()); |
88 DCHECK_EQ(found->second->process_id(), process_id); | 86 DCHECK_EQ(found->second->process_id(), process_id); |
89 if (found == worker_map_.end() || found->second->process_id() != process_id) | 87 if (found == worker_map_.end() || found->second->process_id() != process_id) |
90 return; | 88 return; |
91 found->second->OnScriptLoaded(thread_id); | 89 found->second->OnScriptLoaded(); |
| 90 } |
| 91 |
| 92 void EmbeddedWorkerRegistry::OnWorkerThreadStarted(int process_id, |
| 93 int thread_id, |
| 94 int embedded_worker_id) { |
| 95 WorkerInstanceMap::iterator found = worker_map_.find(embedded_worker_id); |
| 96 DCHECK(found != worker_map_.end()); |
| 97 DCHECK_EQ(found->second->process_id(), process_id); |
| 98 if (found == worker_map_.end() || found->second->process_id() != process_id) |
| 99 return; |
| 100 found->second->OnThreadStarted(thread_id); |
92 } | 101 } |
93 | 102 |
94 void EmbeddedWorkerRegistry::OnWorkerScriptLoadFailed(int process_id, | 103 void EmbeddedWorkerRegistry::OnWorkerScriptLoadFailed(int process_id, |
95 int embedded_worker_id) { | 104 int embedded_worker_id) { |
96 WorkerInstanceMap::iterator found = worker_map_.find(embedded_worker_id); | 105 WorkerInstanceMap::iterator found = worker_map_.find(embedded_worker_id); |
97 DCHECK(found != worker_map_.end()); | 106 DCHECK(found != worker_map_.end()); |
98 DCHECK_EQ(found->second->process_id(), process_id); | 107 DCHECK_EQ(found->second->process_id(), process_id); |
99 if (found == worker_map_.end() || found->second->process_id() != process_id) | 108 if (found == worker_map_.end() || found->second->process_id() != process_id) |
100 return; | 109 return; |
101 found->second->OnScriptLoadFailed(); | 110 found->second->OnScriptLoadFailed(); |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 DCHECK(ContainsKey(worker_map_, embedded_worker_id)); | 286 DCHECK(ContainsKey(worker_map_, embedded_worker_id)); |
278 worker_map_.erase(embedded_worker_id); | 287 worker_map_.erase(embedded_worker_id); |
279 if (!ContainsKey(worker_process_map_, process_id)) | 288 if (!ContainsKey(worker_process_map_, process_id)) |
280 return; | 289 return; |
281 worker_process_map_[process_id].erase(embedded_worker_id); | 290 worker_process_map_[process_id].erase(embedded_worker_id); |
282 if (worker_process_map_[process_id].empty()) | 291 if (worker_process_map_[process_id].empty()) |
283 worker_process_map_.erase(process_id); | 292 worker_process_map_.erase(process_id); |
284 } | 293 } |
285 | 294 |
286 } // namespace content | 295 } // namespace content |
OLD | NEW |