Index: content/browser/background_fetch/background_fetch_context.h |
diff --git a/content/browser/background_fetch/background_fetch_context.h b/content/browser/background_fetch/background_fetch_context.h |
index 37a1c94adeb9e9850aa531a85b704f5e8a8ef98c..944b5bc3d873f0a9baa6fedd99176c8ce0bbd348 100644 |
--- a/content/browser/background_fetch/background_fetch_context.h |
+++ b/content/browser/background_fetch/background_fetch_context.h |
@@ -11,6 +11,7 @@ |
#include "base/macros.h" |
#include "base/memory/ref_counted.h" |
+#include "base/memory/weak_ptr.h" |
#include "content/common/content_export.h" |
#include "content/public/browser/browser_thread.h" |
#include "third_party/WebKit/public/platform/modules/background_fetch/background_fetch.mojom.h" |
@@ -35,20 +36,18 @@ class BlobHandle; |
class BrowserContext; |
class ServiceWorkerContextWrapper; |
struct ServiceWorkerFetchRequest; |
-class StoragePartitionImpl; |
// The BackgroundFetchContext is the central moderator of ongoing background |
// fetch requests from the Mojo service and from other callers. |
-// Background Fetch requests function similar to normal fetches except that |
+// Background Fetch requests function similarly to normal fetches except that |
// they are persistent across Chromium or service worker shutdown. |
class CONTENT_EXPORT BackgroundFetchContext |
: public base::RefCountedThreadSafe<BackgroundFetchContext, |
- BrowserThread::DeleteOnUIThread> { |
+ BrowserThread::DeleteOnIOThread> { |
public: |
// The BackgroundFetchContext will watch the ServiceWorkerContextWrapper so |
// that it can respond to service worker events such as unregister. |
BackgroundFetchContext(BrowserContext* browser_context, |
- StoragePartitionImpl* storage_partition, |
scoped_refptr<ServiceWorkerContextWrapper> context); |
// Finishes initializing the Background Fetch context on the IO thread by |
@@ -56,9 +55,6 @@ class CONTENT_EXPORT BackgroundFetchContext |
void InitializeOnIOThread( |
scoped_refptr<net::URLRequestContextGetter> request_context_getter); |
- // Shutdown must be called before deleting this. Call on the UI thread. |
- void Shutdown(); |
- |
// Starts a Background Fetch for the |registration_id|. The |requests| will be |
// asynchronously fetched. The |callback| will be invoked when the fetch has |
// been registered, or an error occurred that avoids it from doing so. |
@@ -80,15 +76,12 @@ class CONTENT_EXPORT BackgroundFetchContext |
private: |
friend class base::DeleteHelper<BackgroundFetchContext>; |
- friend struct BrowserThread::DeleteOnThread<BrowserThread::UI>; |
+ friend struct BrowserThread::DeleteOnThread<BrowserThread::IO>; |
friend class base::RefCountedThreadSafe<BackgroundFetchContext, |
- BrowserThread::DeleteOnUIThread>; |
+ BrowserThread::DeleteOnIOThread>; |
~BackgroundFetchContext(); |
- // Shuts down the active Job Controllers on the IO thread. |
- void ShutdownOnIO(); |
- |
// Creates a new Job Controller for the given |registration_id| and |options|, |
// which will start fetching the files that are part of the registration. |
void CreateController( |
@@ -135,6 +128,8 @@ class CONTENT_EXPORT BackgroundFetchContext |
std::unique_ptr<BackgroundFetchJobController>> |
active_fetches_; |
+ base::WeakPtrFactory<BackgroundFetchContext> weak_factory_; // Must be last. |
+ |
DISALLOW_COPY_AND_ASSIGN(BackgroundFetchContext); |
}; |