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

Unified Diff: content/browser/service_worker/service_worker_context_wrapper.cc

Issue 1771283002: service worker: Observe when resource context is shutting down (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/service_worker/service_worker_context_wrapper.cc
diff --git a/content/browser/service_worker/service_worker_context_wrapper.cc b/content/browser/service_worker/service_worker_context_wrapper.cc
index 85d9830a529c493123c99ac40774c86816ed4696..b09348da3e48b7b30210fbd967289d384dec3b71 100644
--- a/content/browser/service_worker/service_worker_context_wrapper.cc
+++ b/content/browser/service_worker/service_worker_context_wrapper.cc
@@ -130,6 +130,27 @@ void ServiceWorkerContextWrapper::Shutdown() {
base::Bind(&ServiceWorkerContextWrapper::ShutdownOnIO, this));
}
+void ServiceWorkerContextWrapper::InitializeOnIO(
michaeln 2016/03/08 22:04:27 naming nit driveby: since there already are Init()
falken 2016/03/10 01:25:35 Done.
+ ResourceContext* resource_context,
+ scoped_refptr<net::URLRequestContextGetter> request_context_getter) {
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
+ resource_context_ = resource_context;
+ request_context_getter_ = request_context_getter;
+ request_context_getter_->AddObserver(this);
+}
+
+void ServiceWorkerContextWrapper::OnContextShuttingDown() {
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
falken 2016/03/08 09:59:11 mmenke: URLRequestContextGetterObserver documentat
michaeln 2016/03/08 22:04:27 yes, content::iothread == net::networkthread
mmenke 2016/03/09 18:33:42 Correct. net/ is below content/, so doesn't know
+ request_context_getter_->RemoveObserver(this);
+
+ // OnContextShuttingDown is called when the ProfileIOData (ResourceContext) is
+ // shutting down, so call ShutdownOnIO() to clear resource_context_.
+ // This doesn't seem to be called when using content_shell, so we still must
mmenke 2016/03/09 18:33:42 This bug may still exist with content shell, or ot
+ // also call ShutdownOnIO() in Shutdown(), which is called when the storage
+ // partition is destroyed.
+ ShutdownOnIO();
+}
+
void ServiceWorkerContextWrapper::DeleteAndStartOver() {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
if (!context_core_) {
@@ -158,12 +179,6 @@ ResourceContext* ServiceWorkerContextWrapper::resource_context() {
return resource_context_;
}
-void ServiceWorkerContextWrapper::set_resource_context(
- ResourceContext* resource_context) {
- DCHECK_CURRENTLY_ON(BrowserThread::IO);
- resource_context_ = resource_context;
-}
-
static void FinishRegistrationOnIO(
const ServiceWorkerContext::ResultCallback& continuation,
ServiceWorkerStatusCode status,
« no previous file with comments | « content/browser/service_worker/service_worker_context_wrapper.h ('k') | content/browser/storage_partition_impl_map.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698