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

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

Issue 2678273003: Initial framework setup and skeleton for BackgroundFetchContext (Closed)
Patch Set: Remove observations for service worker context wrapper Created 3 years, 10 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/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
new file mode 100644
index 0000000000000000000000000000000000000000..7669ac418210934fdfe7b13d142f44a420d42bd0
--- /dev/null
+++ b/content/browser/background_fetch/background_fetch_context.h
@@ -0,0 +1,64 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_CONTEXT_H_
+#define CONTENT_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_CONTEXT_H_
+
+#include "base/macros.h"
+#include "base/memory/ref_counted.h"
+#include "content/browser/background_fetch/background_fetch_data_manager.h"
+#include "content/browser/service_worker/service_worker_context_observer.h"
+#include "content/common/content_export.h"
+
+namespace content {
+
+class BrowserContext;
+class FetchRequest;
+class ServiceWorkerContextWrapper;
+
+// 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
+// they are persistent across Chromium or service worker shutdown.
+class CONTENT_EXPORT BackgroundFetchContext
+ : public ServiceWorkerContextObserver,
Peter Beverloo 2017/02/14 15:05:52 nit: let's remove this parent class, as well as th
harkness 2017/02/15 13:48:44 Done.
+ public base::RefCountedThreadSafe<BackgroundFetchContext> {
+ public:
+ // The BackgroundFetchContext will watch the ServiceWorkerContextWrapper so
+ // that it can respond to service worker events such as unregister.
+ BackgroundFetchContext(
+ BrowserContext* browser_context,
+ const scoped_refptr<ServiceWorkerContextWrapper>& context);
+
+ // Init and Shutdown are for use on the UI thread when the StoragePartition is
+ // being setup and torn down.
+ void Init();
+
+ // Shutdown must be called before deleting this. Call on the UI thread.
+ void Shutdown();
+
+ // ServiceWorkerContextObserver methods.
+ void OnRegistrationDeleted(int64_t registration_id,
+ const GURL& pattern) override;
+
+ BackgroundFetchDataManager* GetDataManagerForTesting() {
+ return &background_fetch_data_manager_;
+ }
+
+ private:
+ void CreateRequest(const FetchRequest& fetch_request);
+
+ friend class base::RefCountedThreadSafe<BackgroundFetchContext>;
+ ~BackgroundFetchContext() override;
+
+ BrowserContext* browser_context_;
+ scoped_refptr<ServiceWorkerContextWrapper> service_worker_context_;
+ BackgroundFetchDataManager background_fetch_data_manager_;
+
+ DISALLOW_COPY_AND_ASSIGN(BackgroundFetchContext);
+};
+
+} // namespace content
+
+#endif // CONTENT_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_CONTEXT_H_

Powered by Google App Engine
This is Rietveld 408576698