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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <utility> | 10 #include <utility> |
11 | 11 |
12 #include "content/browser/renderer_host/render_process_host_impl.h" | 12 #include "content/browser/renderer_host/render_process_host_impl.h" |
13 #include "content/browser/service_worker/service_worker_context_wrapper.h" | 13 #include "content/browser/service_worker/service_worker_context_wrapper.h" |
14 #include "content/browser/site_instance_impl.h" | |
14 #include "content/common/service_worker/embedded_worker_settings.h" | 15 #include "content/common/service_worker/embedded_worker_settings.h" |
15 #include "content/public/browser/browser_thread.h" | 16 #include "content/public/browser/browser_thread.h" |
16 #include "content/public/browser/content_browser_client.h" | 17 #include "content/public/browser/content_browser_client.h" |
17 #include "content/public/browser/site_instance.h" | 18 #include "content/public/browser/site_instance.h" |
18 #include "content/public/common/child_process_host.h" | 19 #include "content/public/common/child_process_host.h" |
19 #include "content/public/common/content_client.h" | 20 #include "content/public/common/content_client.h" |
20 #include "url/gurl.h" | 21 #include "url/gurl.h" |
21 | 22 |
22 namespace content { | 23 namespace content { |
23 | 24 |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
209 std::make_pair(embedded_worker_id, ProcessInfo(process_id))); | 210 std::make_pair(embedded_worker_id, ProcessInfo(process_id))); |
210 BrowserThread::PostTask( | 211 BrowserThread::PostTask( |
211 BrowserThread::IO, FROM_HERE, | 212 BrowserThread::IO, FROM_HERE, |
212 base::Bind(callback, SERVICE_WORKER_OK, process_id, | 213 base::Bind(callback, SERVICE_WORKER_OK, process_id, |
213 false /* is_new_process */, settings)); | 214 false /* is_new_process */, settings)); |
214 return; | 215 return; |
215 } | 216 } |
216 } | 217 } |
217 | 218 |
218 // No existing processes available; start a new one. | 219 // No existing processes available; start a new one. |
219 scoped_refptr<SiteInstance> site_instance = | 220 scoped_refptr<SiteInstanceImpl> site_instance = |
220 SiteInstance::CreateForURL(browser_context_, script_url); | 221 SiteInstanceImpl::CreateForURL(browser_context_, script_url); |
222 site_instance->set_process_reuse_policy( | |
223 SiteInstanceImpl::ProcessReusePolicy:: | |
224 REUSE_CHECKING_FRAMES_AND_NAVIGATIONS); | |
nasko
2017/05/05 05:22:00
Reading this code, I wonder if it will be more nat
clamy
2017/05/05 15:10:11
Except it could have already been set in other cas
Charlie Reis
2017/05/15 03:41:52
Just curious, what's the advantage of either of th
clamy
2017/05/16 14:50:46
I'm leaving it as is for now.
| |
221 RenderProcessHost* rph = site_instance->GetProcess(); | 225 RenderProcessHost* rph = site_instance->GetProcess(); |
222 | 226 |
223 // This Init() call posts a task to the IO thread that adds the RPH's | 227 // This Init() call posts a task to the IO thread that adds the RPH's |
224 // ServiceWorkerDispatcherHost to the | 228 // ServiceWorkerDispatcherHost to the |
225 // EmbeddedWorkerRegistry::process_sender_map_. | 229 // EmbeddedWorkerRegistry::process_sender_map_. |
226 if (!rph->Init()) { | 230 if (!rph->Init()) { |
227 LOG(ERROR) << "Couldn't start a new process!"; | 231 LOG(ERROR) << "Couldn't start a new process!"; |
228 BrowserThread::PostTask( | 232 BrowserThread::PostTask( |
229 BrowserThread::IO, FROM_HERE, | 233 BrowserThread::IO, FROM_HERE, |
230 base::Bind(callback, SERVICE_WORKER_ERROR_PROCESS_NOT_FOUND, | 234 base::Bind(callback, SERVICE_WORKER_ERROR_PROCESS_NOT_FOUND, |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
339 namespace std { | 343 namespace std { |
340 // Destroying ServiceWorkerProcessManagers only on the UI thread allows the | 344 // Destroying ServiceWorkerProcessManagers only on the UI thread allows the |
341 // member WeakPtr to safely guard the object's lifetime when used on that | 345 // member WeakPtr to safely guard the object's lifetime when used on that |
342 // thread. | 346 // thread. |
343 void default_delete<content::ServiceWorkerProcessManager>::operator()( | 347 void default_delete<content::ServiceWorkerProcessManager>::operator()( |
344 content::ServiceWorkerProcessManager* ptr) const { | 348 content::ServiceWorkerProcessManager* ptr) const { |
345 content::BrowserThread::DeleteSoon( | 349 content::BrowserThread::DeleteSoon( |
346 content::BrowserThread::UI, FROM_HERE, ptr); | 350 content::BrowserThread::UI, FROM_HERE, ptr); |
347 } | 351 } |
348 } // namespace std | 352 } // namespace std |
OLD | NEW |