Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(268)

Side by Side Diff: content/browser/service_worker/service_worker_process_manager.cc

Issue 2927973002: Only use SiteInstance process reuse for ServiceWorker with no failures (Closed)
Patch Set: Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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>
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 instance_info_.insert( 209 instance_info_.insert(
210 std::make_pair(embedded_worker_id, ProcessInfo(process_id))); 210 std::make_pair(embedded_worker_id, ProcessInfo(process_id)));
211 BrowserThread::PostTask( 211 BrowserThread::PostTask(
212 BrowserThread::IO, FROM_HERE, 212 BrowserThread::IO, FROM_HERE,
213 base::Bind(callback, SERVICE_WORKER_OK, process_id, 213 base::Bind(callback, SERVICE_WORKER_OK, process_id,
214 false /* is_new_process */, settings)); 214 false /* is_new_process */, settings));
215 return; 215 return;
216 } 216 }
217 } 217 }
218 218
219 // No existing processes available; start a new one. 219 // ServiceWorkerProcessManager does not know of any renderer processes that
220 // are available for |pattern|. Create a SiteInstance and ask for a renderer
221 // process. Attempt to reuse an existing process if possible.
220 // TODO(clamy): Update the process reuse mechanism above following the 222 // TODO(clamy): Update the process reuse mechanism above following the
221 // implementation of 223 // implementation of
222 // SiteInstanceImpl::ProcessReusePolicy::REUSE_PENDING_OR_COMMITTED_SITE. 224 // SiteInstanceImpl::ProcessReusePolicy::REUSE_PENDING_OR_COMMITTED_SITE.
223 scoped_refptr<SiteInstanceImpl> site_instance = 225 scoped_refptr<SiteInstanceImpl> site_instance =
224 SiteInstanceImpl::CreateForURL(browser_context_, script_url); 226 SiteInstanceImpl::CreateForURL(browser_context_, script_url);
225 site_instance->set_process_reuse_policy( 227 if (can_use_existing_process) {
226 SiteInstanceImpl::ProcessReusePolicy::REUSE_PENDING_OR_COMMITTED_SITE); 228 site_instance->set_process_reuse_policy(
229 SiteInstanceImpl::ProcessReusePolicy::REUSE_PENDING_OR_COMMITTED_SITE);
230 }
227 RenderProcessHost* rph = site_instance->GetProcess(); 231 RenderProcessHost* rph = site_instance->GetProcess();
228 232
229 // This Init() call posts a task to the IO thread that adds the RPH's 233 // This Init() call posts a task to the IO thread that adds the RPH's
230 // ServiceWorkerDispatcherHost to the 234 // ServiceWorkerDispatcherHost to the
231 // EmbeddedWorkerRegistry::process_sender_map_. 235 // EmbeddedWorkerRegistry::process_sender_map_.
232 if (!rph->Init()) { 236 if (!rph->Init()) {
233 LOG(ERROR) << "Couldn't start a new process!"; 237 LOG(ERROR) << "Couldn't start a new process!";
234 BrowserThread::PostTask( 238 BrowserThread::PostTask(
235 BrowserThread::IO, FROM_HERE, 239 BrowserThread::IO, FROM_HERE,
236 base::Bind(callback, SERVICE_WORKER_ERROR_PROCESS_NOT_FOUND, 240 base::Bind(callback, SERVICE_WORKER_ERROR_PROCESS_NOT_FOUND,
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 namespace std { 349 namespace std {
346 // Destroying ServiceWorkerProcessManagers only on the UI thread allows the 350 // Destroying ServiceWorkerProcessManagers only on the UI thread allows the
347 // member WeakPtr to safely guard the object's lifetime when used on that 351 // member WeakPtr to safely guard the object's lifetime when used on that
348 // thread. 352 // thread.
349 void default_delete<content::ServiceWorkerProcessManager>::operator()( 353 void default_delete<content::ServiceWorkerProcessManager>::operator()(
350 content::ServiceWorkerProcessManager* ptr) const { 354 content::ServiceWorkerProcessManager* ptr) const {
351 content::BrowserThread::DeleteSoon( 355 content::BrowserThread::DeleteSoon(
352 content::BrowserThread::UI, FROM_HERE, ptr); 356 content::BrowserThread::UI, FROM_HERE, ptr);
353 } 357 }
354 } // namespace std 358 } // namespace std
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698