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

Unified Diff: content/browser/background_fetch/background_fetch_context.h

Issue 2973233002: [Background Fetch] Cleanup/fix thread safety (Closed)
Patch Set: Remove n.b. from comments Created 3 years, 5 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
« no previous file with comments | « no previous file | content/browser/background_fetch/background_fetch_context.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
};
« no previous file with comments | « no previous file | content/browser/background_fetch/background_fetch_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698