OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/service_worker_process_manager.h" | 5 #include "content/browser/service_worker/service_worker_process_manager.h" |
6 | 6 |
7 #include "content/browser/renderer_host/render_process_host_impl.h" | 7 #include "content/browser/renderer_host/render_process_host_impl.h" |
8 #include "content/browser/service_worker/service_worker_context_wrapper.h" | 8 #include "content/browser/service_worker/service_worker_context_wrapper.h" |
9 #include "content/public/browser/browser_thread.h" | 9 #include "content/public/browser/browser_thread.h" |
10 #include "content/public/browser/site_instance.h" | 10 #include "content/public/browser/site_instance.h" |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 std::make_pair(embedded_worker_id, ProcessInfo(*it))); | 173 std::make_pair(embedded_worker_id, ProcessInfo(*it))); |
174 BrowserThread::PostTask(BrowserThread::IO, | 174 BrowserThread::PostTask(BrowserThread::IO, |
175 FROM_HERE, | 175 FROM_HERE, |
176 base::Bind(callback, SERVICE_WORKER_OK, *it)); | 176 base::Bind(callback, SERVICE_WORKER_OK, *it)); |
177 return; | 177 return; |
178 } | 178 } |
179 | 179 |
180 if (!browser_context_) { | 180 if (!browser_context_) { |
181 // Shutdown has started. | 181 // Shutdown has started. |
182 BrowserThread::PostTask( | 182 BrowserThread::PostTask( |
183 BrowserThread::IO, | 183 BrowserThread::IO, FROM_HERE, |
184 FROM_HERE, | 184 base::Bind(callback, SERVICE_WORKER_ERROR_ABORT, -1)); |
185 base::Bind(callback, SERVICE_WORKER_ERROR_START_WORKER_FAILED, -1)); | |
186 return; | 185 return; |
187 } | 186 } |
188 // No existing processes available; start a new one. | 187 // No existing processes available; start a new one. |
189 scoped_refptr<SiteInstance> site_instance = | 188 scoped_refptr<SiteInstance> site_instance = |
190 SiteInstance::CreateForURL(browser_context_, script_url); | 189 SiteInstance::CreateForURL(browser_context_, script_url); |
191 RenderProcessHost* rph = site_instance->GetProcess(); | 190 RenderProcessHost* rph = site_instance->GetProcess(); |
192 // This Init() call posts a task to the IO thread that adds the RPH's | 191 // This Init() call posts a task to the IO thread that adds the RPH's |
193 // ServiceWorkerDispatcherHost to the | 192 // ServiceWorkerDispatcherHost to the |
194 // EmbeddedWorkerRegistry::process_sender_map_. | 193 // EmbeddedWorkerRegistry::process_sender_map_. |
195 if (!rph->Init()) { | 194 if (!rph->Init()) { |
196 LOG(ERROR) << "Couldn't start a new process!"; | 195 LOG(ERROR) << "Couldn't start a new process!"; |
197 BrowserThread::PostTask( | 196 BrowserThread::PostTask( |
198 BrowserThread::IO, | 197 BrowserThread::IO, FROM_HERE, |
199 FROM_HERE, | 198 base::Bind(callback, SERVICE_WORKER_ERROR_PROCESS_NOT_FOUND, -1)); |
200 base::Bind(callback, SERVICE_WORKER_ERROR_START_WORKER_FAILED, -1)); | |
201 return; | 199 return; |
202 } | 200 } |
203 | 201 |
204 instance_info_.insert( | 202 instance_info_.insert( |
205 std::make_pair(embedded_worker_id, ProcessInfo(site_instance))); | 203 std::make_pair(embedded_worker_id, ProcessInfo(site_instance))); |
206 | 204 |
207 static_cast<RenderProcessHostImpl*>(rph)->IncrementWorkerRefCount(); | 205 static_cast<RenderProcessHostImpl*>(rph)->IncrementWorkerRefCount(); |
208 BrowserThread::PostTask( | 206 BrowserThread::PostTask( |
209 BrowserThread::IO, | 207 BrowserThread::IO, |
210 FROM_HERE, | 208 FROM_HERE, |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 namespace base { | 269 namespace base { |
272 // Destroying ServiceWorkerProcessManagers only on the UI thread allows the | 270 // Destroying ServiceWorkerProcessManagers only on the UI thread allows the |
273 // member WeakPtr to safely guard the object's lifetime when used on that | 271 // member WeakPtr to safely guard the object's lifetime when used on that |
274 // thread. | 272 // thread. |
275 void DefaultDeleter<content::ServiceWorkerProcessManager>::operator()( | 273 void DefaultDeleter<content::ServiceWorkerProcessManager>::operator()( |
276 content::ServiceWorkerProcessManager* ptr) const { | 274 content::ServiceWorkerProcessManager* ptr) const { |
277 content::BrowserThread::DeleteSoon( | 275 content::BrowserThread::DeleteSoon( |
278 content::BrowserThread::UI, FROM_HERE, ptr); | 276 content::BrowserThread::UI, FROM_HERE, ptr); |
279 } | 277 } |
280 } // namespace base | 278 } // namespace base |
OLD | NEW |