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 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(int process_id, |
82 int embedded_worker_id) { | 82 int thread_id, |
nasko
2014/08/26 15:58:24
style: From the style guide: "For function declara
| |
83 int embedded_worker_id ) { | |
83 WorkerInstanceMap::iterator found = worker_map_.find(embedded_worker_id); | 84 WorkerInstanceMap::iterator found = worker_map_.find(embedded_worker_id); |
84 DCHECK(found != worker_map_.end()); | 85 DCHECK(found != worker_map_.end()); |
85 DCHECK_EQ(found->second->process_id(), process_id); | 86 DCHECK_EQ(found->second->process_id(), process_id); |
86 if (found == worker_map_.end() || found->second->process_id() != process_id) | 87 if (found == worker_map_.end() || found->second->process_id() != process_id) |
87 return; | 88 return; |
88 found->second->OnScriptLoaded(); | 89 found->second->OnScriptLoaded(thread_id); |
89 } | 90 } |
90 | 91 |
91 void EmbeddedWorkerRegistry::OnWorkerScriptLoadFailed(int process_id, | 92 void EmbeddedWorkerRegistry::OnWorkerScriptLoadFailed(int process_id, |
92 int embedded_worker_id) { | 93 int embedded_worker_id) { |
93 WorkerInstanceMap::iterator found = worker_map_.find(embedded_worker_id); | 94 WorkerInstanceMap::iterator found = worker_map_.find(embedded_worker_id); |
94 DCHECK(found != worker_map_.end()); | 95 DCHECK(found != worker_map_.end()); |
95 DCHECK_EQ(found->second->process_id(), process_id); | 96 DCHECK_EQ(found->second->process_id(), process_id); |
96 if (found == worker_map_.end() || found->second->process_id() != process_id) | 97 if (found == worker_map_.end() || found->second->process_id() != process_id) |
97 return; | 98 return; |
98 found->second->OnScriptLoadFailed(); | 99 found->second->OnScriptLoadFailed(); |
99 } | 100 } |
100 | 101 |
101 void EmbeddedWorkerRegistry::OnWorkerStarted( | 102 void EmbeddedWorkerRegistry::OnWorkerStarted( |
102 int process_id, int thread_id, int embedded_worker_id) { | 103 int process_id, int embedded_worker_id) { |
103 DCHECK(!ContainsKey(worker_process_map_, process_id) || | 104 DCHECK(!ContainsKey(worker_process_map_, process_id) || |
104 worker_process_map_[process_id].count(embedded_worker_id) == 0); | 105 worker_process_map_[process_id].count(embedded_worker_id) == 0); |
105 WorkerInstanceMap::iterator found = worker_map_.find(embedded_worker_id); | 106 WorkerInstanceMap::iterator found = worker_map_.find(embedded_worker_id); |
106 DCHECK(found != worker_map_.end()); | 107 DCHECK(found != worker_map_.end()); |
107 DCHECK_EQ(found->second->process_id(), process_id); | 108 DCHECK_EQ(found->second->process_id(), process_id); |
108 if (found == worker_map_.end() || found->second->process_id() != process_id) | 109 if (found == worker_map_.end() || found->second->process_id() != process_id) |
109 return; | 110 return; |
110 worker_process_map_[process_id].insert(embedded_worker_id); | 111 worker_process_map_[process_id].insert(embedded_worker_id); |
111 found->second->OnStarted(thread_id); | 112 found->second->OnStarted(); |
112 } | 113 } |
113 | 114 |
114 void EmbeddedWorkerRegistry::OnWorkerStopped( | 115 void EmbeddedWorkerRegistry::OnWorkerStopped(int process_id, |
115 int process_id, int embedded_worker_id) { | 116 int embedded_worker_id) { |
116 WorkerInstanceMap::iterator found = worker_map_.find(embedded_worker_id); | 117 WorkerInstanceMap::iterator found = worker_map_.find(embedded_worker_id); |
117 DCHECK(found != worker_map_.end()); | 118 DCHECK(found != worker_map_.end()); |
118 DCHECK_EQ(found->second->process_id(), process_id); | 119 DCHECK_EQ(found->second->process_id(), process_id); |
119 if (found == worker_map_.end() || found->second->process_id() != process_id) | 120 if (found == worker_map_.end() || found->second->process_id() != process_id) |
120 return; | 121 return; |
121 worker_process_map_[process_id].erase(embedded_worker_id); | 122 worker_process_map_[process_id].erase(embedded_worker_id); |
122 found->second->OnStopped(); | 123 found->second->OnStopped(); |
123 } | 124 } |
124 | 125 |
125 void EmbeddedWorkerRegistry::OnPausedAfterDownload( | 126 void EmbeddedWorkerRegistry::OnPausedAfterDownload( |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
237 } | 238 } |
238 | 239 |
239 void EmbeddedWorkerRegistry::RemoveWorker(int process_id, | 240 void EmbeddedWorkerRegistry::RemoveWorker(int process_id, |
240 int embedded_worker_id) { | 241 int embedded_worker_id) { |
241 DCHECK(ContainsKey(worker_map_, embedded_worker_id)); | 242 DCHECK(ContainsKey(worker_map_, embedded_worker_id)); |
242 worker_map_.erase(embedded_worker_id); | 243 worker_map_.erase(embedded_worker_id); |
243 worker_process_map_.erase(process_id); | 244 worker_process_map_.erase(process_id); |
244 } | 245 } |
245 | 246 |
246 } // namespace content | 247 } // namespace content |
OLD | NEW |