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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 CHECK(instance_info_.empty()); | 70 CHECK(instance_info_.empty()); |
71 } | 71 } |
72 | 72 |
73 void ServiceWorkerProcessManager::Shutdown() { | 73 void ServiceWorkerProcessManager::Shutdown() { |
74 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 74 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
75 { | 75 { |
76 base::AutoLock lock(browser_context_lock_); | 76 base::AutoLock lock(browser_context_lock_); |
77 browser_context_ = nullptr; | 77 browser_context_ = nullptr; |
78 } | 78 } |
79 | 79 |
80 for (std::map<int, ProcessInfo>::const_iterator it = instance_info_.begin(); | 80 // In single-process mode, Shutdown() is called when deleting the default |
81 it != instance_info_.end(); | 81 // browser context, which is itself destroyed after the RenderProcessHost, |
82 ++it) { | 82 // and RenderProcessHost::FromID() just returns a nullptr. |
83 RenderProcessHost::FromID(it->second.process_id) | 83 // The refcount decrement can be skipped anyway since there's only one process |
84 ->DecrementServiceWorkerRefCount(); | 84 if (!RenderProcessHost::run_renderer_in_process()) { |
| 85 for (std::map<int, ProcessInfo>::const_iterator it = instance_info_.begin(); |
| 86 it != instance_info_.end(); ++it) { |
| 87 RenderProcessHost::FromID(it->second.process_id) |
| 88 ->DecrementServiceWorkerRefCount(); |
| 89 } |
85 } | 90 } |
86 instance_info_.clear(); | 91 instance_info_.clear(); |
87 } | 92 } |
88 | 93 |
89 bool ServiceWorkerProcessManager::IsShutdown() { | 94 bool ServiceWorkerProcessManager::IsShutdown() { |
90 base::AutoLock lock(browser_context_lock_); | 95 base::AutoLock lock(browser_context_lock_); |
91 return !browser_context_; | 96 return !browser_context_; |
92 } | 97 } |
93 | 98 |
94 void ServiceWorkerProcessManager::AddProcessReferenceToPattern( | 99 void ServiceWorkerProcessManager::AddProcessReferenceToPattern( |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 namespace std { | 339 namespace std { |
335 // Destroying ServiceWorkerProcessManagers only on the UI thread allows the | 340 // Destroying ServiceWorkerProcessManagers only on the UI thread allows the |
336 // member WeakPtr to safely guard the object's lifetime when used on that | 341 // member WeakPtr to safely guard the object's lifetime when used on that |
337 // thread. | 342 // thread. |
338 void default_delete<content::ServiceWorkerProcessManager>::operator()( | 343 void default_delete<content::ServiceWorkerProcessManager>::operator()( |
339 content::ServiceWorkerProcessManager* ptr) const { | 344 content::ServiceWorkerProcessManager* ptr) const { |
340 content::BrowserThread::DeleteSoon( | 345 content::BrowserThread::DeleteSoon( |
341 content::BrowserThread::UI, FROM_HERE, ptr); | 346 content::BrowserThread::UI, FROM_HERE, ptr); |
342 } | 347 } |
343 } // namespace std | 348 } // namespace std |
OLD | NEW |