Chromium Code Reviews| 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> |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 // No existing processes available; start a new one. Attempt to reuse an |
| 220 // existing process if possible. | |
|
falken
2017/06/06 13:32:43
Now these sentences read like a contradiction :) H
clamy
2017/06/06 16:37:39
Done.
| |
| 220 // TODO(clamy): Update the process reuse mechanism above following the | 221 // TODO(clamy): Update the process reuse mechanism above following the |
| 221 // implementation of | 222 // implementation of |
| 222 // SiteInstanceImpl::ProcessReusePolicy::REUSE_PENDING_OR_COMMITTED_SITE. | 223 // SiteInstanceImpl::ProcessReusePolicy::REUSE_PENDING_OR_COMMITTED_SITE. |
| 223 scoped_refptr<SiteInstanceImpl> site_instance = | 224 scoped_refptr<SiteInstanceImpl> site_instance = |
| 224 SiteInstanceImpl::CreateForURL(browser_context_, script_url); | 225 SiteInstanceImpl::CreateForURL(browser_context_, script_url); |
| 225 site_instance->set_process_reuse_policy( | 226 if (can_use_existing_process) { |
| 226 SiteInstanceImpl::ProcessReusePolicy::REUSE_PENDING_OR_COMMITTED_SITE); | 227 site_instance->set_process_reuse_policy( |
| 228 SiteInstanceImpl::ProcessReusePolicy::REUSE_PENDING_OR_COMMITTED_SITE); | |
| 229 } | |
| 227 RenderProcessHost* rph = site_instance->GetProcess(); | 230 RenderProcessHost* rph = site_instance->GetProcess(); |
| 228 | 231 |
| 229 // This Init() call posts a task to the IO thread that adds the RPH's | 232 // This Init() call posts a task to the IO thread that adds the RPH's |
| 230 // ServiceWorkerDispatcherHost to the | 233 // ServiceWorkerDispatcherHost to the |
| 231 // EmbeddedWorkerRegistry::process_sender_map_. | 234 // EmbeddedWorkerRegistry::process_sender_map_. |
| 232 if (!rph->Init()) { | 235 if (!rph->Init()) { |
| 233 LOG(ERROR) << "Couldn't start a new process!"; | 236 LOG(ERROR) << "Couldn't start a new process!"; |
| 234 BrowserThread::PostTask( | 237 BrowserThread::PostTask( |
| 235 BrowserThread::IO, FROM_HERE, | 238 BrowserThread::IO, FROM_HERE, |
| 236 base::Bind(callback, SERVICE_WORKER_ERROR_PROCESS_NOT_FOUND, | 239 base::Bind(callback, SERVICE_WORKER_ERROR_PROCESS_NOT_FOUND, |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 345 namespace std { | 348 namespace std { |
| 346 // Destroying ServiceWorkerProcessManagers only on the UI thread allows the | 349 // Destroying ServiceWorkerProcessManagers only on the UI thread allows the |
| 347 // member WeakPtr to safely guard the object's lifetime when used on that | 350 // member WeakPtr to safely guard the object's lifetime when used on that |
| 348 // thread. | 351 // thread. |
| 349 void default_delete<content::ServiceWorkerProcessManager>::operator()( | 352 void default_delete<content::ServiceWorkerProcessManager>::operator()( |
| 350 content::ServiceWorkerProcessManager* ptr) const { | 353 content::ServiceWorkerProcessManager* ptr) const { |
| 351 content::BrowserThread::DeleteSoon( | 354 content::BrowserThread::DeleteSoon( |
| 352 content::BrowserThread::UI, FROM_HERE, ptr); | 355 content::BrowserThread::UI, FROM_HERE, ptr); |
| 353 } | 356 } |
| 354 } // namespace std | 357 } // namespace std |
| OLD | NEW |