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

Side by Side Diff: content/browser/browser_context.cc

Issue 653633004: Shutdown Service Workers before the profile is destroyed (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: sync Created 6 years, 1 month 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/public/browser/browser_context.h" 5 #include "content/public/browser/browser_context.h"
6 6
7 #if !defined(OS_IOS) 7 #if !defined(OS_IOS)
8 #include "content/browser/download/download_manager_impl.h" 8 #include "content/browser/download/download_manager_impl.h"
9 #include "content/browser/fileapi/chrome_blob_storage_context.h" 9 #include "content/browser/fileapi/chrome_blob_storage_context.h"
10 #include "content/browser/indexed_db/indexed_db_context_impl.h" 10 #include "content/browser/indexed_db/indexed_db_context_impl.h"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 context->channel_id_service()->GetChannelIDStore()-> 77 context->channel_id_service()->GetChannelIDStore()->
78 SetForceKeepSessionState(); 78 SetForceKeepSessionState();
79 appcache_service->set_force_keep_session_state(); 79 appcache_service->set_force_keep_session_state();
80 } 80 }
81 81
82 void SaveSessionStateOnIndexedDBThread( 82 void SaveSessionStateOnIndexedDBThread(
83 scoped_refptr<IndexedDBContextImpl> indexed_db_context) { 83 scoped_refptr<IndexedDBContextImpl> indexed_db_context) {
84 indexed_db_context->SetForceKeepSessionState(); 84 indexed_db_context->SetForceKeepSessionState();
85 } 85 }
86 86
87 void ShutdownServiceWorkerContext(StoragePartition* partition) {
88 ServiceWorkerContextWrapper* wrapper =
89 static_cast<ServiceWorkerContextWrapper*>(
90 partition->GetServiceWorkerContext());
91 wrapper->process_manager()->Shutdown();
92 }
93
87 } // namespace 94 } // namespace
88 95
89 // static 96 // static
90 void BrowserContext::AsyncObliterateStoragePartition( 97 void BrowserContext::AsyncObliterateStoragePartition(
91 BrowserContext* browser_context, 98 BrowserContext* browser_context,
92 const GURL& site, 99 const GURL& site,
93 const base::Closure& on_gc_required) { 100 const base::Closure& on_gc_required) {
94 GetStoragePartitionMap(browser_context)->AsyncObliterate(site, 101 GetStoragePartitionMap(browser_context)->AsyncObliterate(site,
95 on_gc_required); 102 on_gc_required);
96 } 103 }
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 BrowserContext* browser_context, 225 BrowserContext* browser_context,
219 const GURL& origin, 226 const GURL& origin,
220 int64 service_worker_registration_id, 227 int64 service_worker_registration_id,
221 const std::string& data, 228 const std::string& data,
222 const base::Callback<void(PushDeliveryStatus)>& callback) { 229 const base::Callback<void(PushDeliveryStatus)>& callback) {
223 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 230 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
224 PushMessagingRouter::DeliverMessage( 231 PushMessagingRouter::DeliverMessage(
225 browser_context, origin, service_worker_registration_id, data, callback); 232 browser_context, origin, service_worker_registration_id, data, callback);
226 } 233 }
227 234
235 // static
236 void BrowserContext::NotifyWillBeDestroyed(BrowserContext* browser_context) {
237 // Service Workers must shutdown before the browser context is destroyed,
238 // since they keep render process hosts alive and the codebase assumes that
239 // render process hosts die before their profile (browser context) dies.
240 ForEachStoragePartition(browser_context,
241 base::Bind(ShutdownServiceWorkerContext));
242 }
243
228 void BrowserContext::EnsureResourceContextInitialized(BrowserContext* context) { 244 void BrowserContext::EnsureResourceContextInitialized(BrowserContext* context) {
229 // This will be enough to tickle initialization of BrowserContext if 245 // This will be enough to tickle initialization of BrowserContext if
230 // necessary, which initializes ResourceContext. The reason we don't call 246 // necessary, which initializes ResourceContext. The reason we don't call
231 // ResourceContext::InitializeResourceContext() directly here is that 247 // ResourceContext::InitializeResourceContext() directly here is that
232 // ResourceContext initialization may call back into BrowserContext 248 // ResourceContext initialization may call back into BrowserContext
233 // and when that call returns it'll end rewriting its UserData map. It will 249 // and when that call returns it'll end rewriting its UserData map. It will
234 // end up rewriting the same value but this still causes a race condition. 250 // end up rewriting the same value but this still causes a race condition.
235 // 251 //
236 // See http://crbug.com/115678. 252 // See http://crbug.com/115678.
237 GetDefaultStoragePartition(context); 253 GetDefaultStoragePartition(context);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 #endif // !OS_IOS 289 #endif // !OS_IOS
274 290
275 BrowserContext::~BrowserContext() { 291 BrowserContext::~BrowserContext() {
276 #if !defined(OS_IOS) 292 #if !defined(OS_IOS)
277 if (GetUserData(kDownloadManagerKeyName)) 293 if (GetUserData(kDownloadManagerKeyName))
278 GetDownloadManager(this)->Shutdown(); 294 GetDownloadManager(this)->Shutdown();
279 #endif 295 #endif
280 } 296 }
281 297
282 } // namespace content 298 } // namespace content
OLDNEW
« no previous file with comments | « chrome/browser/profiles/profile.cc ('k') | content/browser/service_worker/service_worker_context_wrapper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698