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

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

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.h
diff --git a/content/browser/service_worker/service_worker_context_wrapper.h b/content/browser/service_worker/service_worker_context_wrapper.h
index c99340c6d462837da05cacce5476a6498125547b..5447d8e16e88f161026fd4da8122587ccad5e7e6 100644
--- a/content/browser/service_worker/service_worker_context_wrapper.h
+++ b/content/browser/service_worker/service_worker_context_wrapper.h
@@ -7,6 +7,7 @@
#include <stdint.h>
+#include <string>
#include <vector>
#include "base/files/file_path.h"
@@ -16,6 +17,7 @@
#include "content/browser/service_worker/service_worker_context_core.h"
#include "content/common/content_export.h"
#include "content/public/browser/service_worker_context.h"
+#include "net/url_request/url_request_context_getter_observer.h"
namespace base {
class FilePath;
@@ -42,6 +44,7 @@ class StoragePartitionImpl;
// is what is used internally in the service worker lib.
class CONTENT_EXPORT ServiceWorkerContextWrapper
: NON_EXPORTED_BASE(public ServiceWorkerContext),
+ public net::URLRequestContextGetterObserver,
public base::RefCountedThreadSafe<ServiceWorkerContextWrapper> {
public:
using StatusCallback = base::Callback<void(ServiceWorkerStatusCode)>;
@@ -63,6 +66,14 @@ class CONTENT_EXPORT ServiceWorkerContextWrapper
storage::SpecialStoragePolicy* special_storage_policy);
void Shutdown();
+ // Must be called on the IO thread.
+ void InitializeResourceContext(
+ ResourceContext* resource_context,
+ scoped_refptr<net::URLRequestContextGetter> request_context_getter);
+
+ // For net::URLRequestContextGetterObserver
+ void OnContextShuttingDown() override;
+
// Deletes all files on disk and restarts the system asynchronously. This
// leaves the system in a disabled state until it's done. This should be
// called on the IO thread.
@@ -79,8 +90,6 @@ class CONTENT_EXPORT ServiceWorkerContextWrapper
// shutdown.
ResourceContext* resource_context();
- void set_resource_context(ResourceContext* resource_context);
-
// The process manager can be used on either UI or IO.
ServiceWorkerProcessManager* process_manager() {
return process_manager_.get();
@@ -228,7 +237,7 @@ class CONTENT_EXPORT ServiceWorkerContextWrapper
const scoped_refptr<base::ObserverListThreadSafe<
ServiceWorkerContextObserver>> observer_list_;
const scoped_ptr<ServiceWorkerProcessManager> process_manager_;
- // Cleared in Shutdown():
+ // Cleared in ShutdownOnIO():
scoped_ptr<ServiceWorkerContextCore> context_core_;
// Initialized in Init(); true if the user data directory is empty.
@@ -240,6 +249,8 @@ class CONTENT_EXPORT ServiceWorkerContextWrapper
// The ResourceContext associated with this context.
ResourceContext* resource_context_;
+ scoped_refptr<net::URLRequestContextGetter> request_context_getter_;
+
DISALLOW_COPY_AND_ASSIGN(ServiceWorkerContextWrapper);
};

Powered by Google App Engine
This is Rietveld 408576698