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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 int process_id, | 71 int process_id, |
72 int embedded_worker_id) { | 72 int embedded_worker_id) { |
73 WorkerInstanceMap::iterator found = worker_map_.find(embedded_worker_id); | 73 WorkerInstanceMap::iterator found = worker_map_.find(embedded_worker_id); |
74 DCHECK(found != worker_map_.end()); | 74 DCHECK(found != worker_map_.end()); |
75 DCHECK_EQ(found->second->process_id(), process_id); | 75 DCHECK_EQ(found->second->process_id(), process_id); |
76 if (found == worker_map_.end() || found->second->process_id() != process_id) | 76 if (found == worker_map_.end() || found->second->process_id() != process_id) |
77 return; | 77 return; |
78 found->second->OnReadyForInspection(); | 78 found->second->OnReadyForInspection(); |
79 } | 79 } |
80 | 80 |
81 void EmbeddedWorkerRegistry::OnWorkerScriptLoaded(int process_id, | 81 void EmbeddedWorkerRegistry::OnWorkerScriptLoaded( |
82 int embedded_worker_id) { | 82 int process_id, |
| 83 int thread_id, |
| 84 int embedded_worker_id ) { |
83 WorkerInstanceMap::iterator found = worker_map_.find(embedded_worker_id); | 85 WorkerInstanceMap::iterator found = worker_map_.find(embedded_worker_id); |
84 DCHECK(found != worker_map_.end()); | 86 DCHECK(found != worker_map_.end()); |
85 DCHECK_EQ(found->second->process_id(), process_id); | 87 DCHECK_EQ(found->second->process_id(), process_id); |
86 if (found == worker_map_.end() || found->second->process_id() != process_id) | 88 if (found == worker_map_.end() || found->second->process_id() != process_id) |
87 return; | 89 return; |
88 found->second->OnScriptLoaded(); | 90 found->second->OnScriptLoaded(thread_id); |
89 } | 91 } |
90 | 92 |
91 void EmbeddedWorkerRegistry::OnWorkerScriptLoadFailed(int process_id, | 93 void EmbeddedWorkerRegistry::OnWorkerScriptLoadFailed(int process_id, |
92 int embedded_worker_id) { | 94 int embedded_worker_id) { |
93 WorkerInstanceMap::iterator found = worker_map_.find(embedded_worker_id); | 95 WorkerInstanceMap::iterator found = worker_map_.find(embedded_worker_id); |
94 DCHECK(found != worker_map_.end()); | 96 DCHECK(found != worker_map_.end()); |
95 DCHECK_EQ(found->second->process_id(), process_id); | 97 DCHECK_EQ(found->second->process_id(), process_id); |
96 if (found == worker_map_.end() || found->second->process_id() != process_id) | 98 if (found == worker_map_.end() || found->second->process_id() != process_id) |
97 return; | 99 return; |
98 found->second->OnScriptLoadFailed(); | 100 found->second->OnScriptLoadFailed(); |
99 } | 101 } |
100 | 102 |
101 void EmbeddedWorkerRegistry::OnWorkerStarted( | 103 void EmbeddedWorkerRegistry::OnWorkerStarted( |
102 int process_id, int thread_id, int embedded_worker_id) { | 104 int process_id, int embedded_worker_id) { |
103 DCHECK(!ContainsKey(worker_process_map_, process_id) || | 105 DCHECK(!ContainsKey(worker_process_map_, process_id) || |
104 worker_process_map_[process_id].count(embedded_worker_id) == 0); | 106 worker_process_map_[process_id].count(embedded_worker_id) == 0); |
105 WorkerInstanceMap::iterator found = worker_map_.find(embedded_worker_id); | 107 WorkerInstanceMap::iterator found = worker_map_.find(embedded_worker_id); |
106 DCHECK(found != worker_map_.end()); | 108 DCHECK(found != worker_map_.end()); |
107 DCHECK_EQ(found->second->process_id(), process_id); | 109 DCHECK_EQ(found->second->process_id(), process_id); |
108 if (found == worker_map_.end() || found->second->process_id() != process_id) | 110 if (found == worker_map_.end() || found->second->process_id() != process_id) |
109 return; | 111 return; |
110 worker_process_map_[process_id].insert(embedded_worker_id); | 112 worker_process_map_[process_id].insert(embedded_worker_id); |
111 found->second->OnStarted(thread_id); | 113 found->second->OnStarted(); |
112 } | 114 } |
113 | 115 |
114 void EmbeddedWorkerRegistry::OnWorkerStopped( | 116 void EmbeddedWorkerRegistry::OnWorkerStopped( |
115 int process_id, int embedded_worker_id) { | 117 int process_id, int embedded_worker_id) { |
116 WorkerInstanceMap::iterator found = worker_map_.find(embedded_worker_id); | 118 WorkerInstanceMap::iterator found = worker_map_.find(embedded_worker_id); |
117 DCHECK(found != worker_map_.end()); | 119 DCHECK(found != worker_map_.end()); |
118 DCHECK_EQ(found->second->process_id(), process_id); | 120 DCHECK_EQ(found->second->process_id(), process_id); |
119 if (found == worker_map_.end() || found->second->process_id() != process_id) | 121 if (found == worker_map_.end() || found->second->process_id() != process_id) |
120 return; | 122 return; |
121 worker_process_map_[process_id].erase(embedded_worker_id); | 123 worker_process_map_[process_id].erase(embedded_worker_id); |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 } | 239 } |
238 | 240 |
239 void EmbeddedWorkerRegistry::RemoveWorker(int process_id, | 241 void EmbeddedWorkerRegistry::RemoveWorker(int process_id, |
240 int embedded_worker_id) { | 242 int embedded_worker_id) { |
241 DCHECK(ContainsKey(worker_map_, embedded_worker_id)); | 243 DCHECK(ContainsKey(worker_map_, embedded_worker_id)); |
242 worker_map_.erase(embedded_worker_id); | 244 worker_map_.erase(embedded_worker_id); |
243 worker_process_map_.erase(process_id); | 245 worker_process_map_.erase(process_id); |
244 } | 246 } |
245 | 247 |
246 } // namespace content | 248 } // namespace content |
OLD | NEW |