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

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: fix unittests 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..1dafcef098b02b8f0fef19f5a4fd82da70792057 100644
--- a/content/browser/service_worker/service_worker_context_wrapper.cc
+++ b/content/browser/service_worker/service_worker_context_wrapper.cc
@@ -130,6 +130,29 @@ void ServiceWorkerContextWrapper::Shutdown() {
base::Bind(&ServiceWorkerContextWrapper::ShutdownOnIO, this));
}
+void ServiceWorkerContextWrapper::InitializeResourceContext(
+ 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;
+ // Can be null in tests.
+ if (request_context_getter_)
+ request_context_getter_->AddObserver(this);
+}
+
+void ServiceWorkerContextWrapper::OnContextShuttingDown() {
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
+ request_context_getter_->RemoveObserver(this);
michaeln 2016/03/10 21:15:53 You mentioned this isn't called on ContentShell.
mmenke 2016/03/10 21:20:51 I view this as a hack to resolve incorrect class d
+
+ // 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
+ // 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 +181,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