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

Unified Diff: components/offline_pages/core/prefetch/prefetch_dispatcher.h

Issue 2879013002: Create skeleton for the Prefetching store and initial pipeline step. (Closed)
Patch Set: Dispatcher instance is now injected into Service. Minor changes. Created 3 years, 7 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: components/offline_pages/core/prefetch/prefetch_dispatcher.h
diff --git a/components/offline_pages/core/prefetch/prefetch_dispatcher.h b/components/offline_pages/core/prefetch/prefetch_dispatcher.h
index 36f9b206de3b4931cd2951798012fbeac27d9977..db90fe3cb86612e3360f60be632486c4357c638f 100644
--- a/components/offline_pages/core/prefetch/prefetch_dispatcher.h
+++ b/components/offline_pages/core/prefetch/prefetch_dispatcher.h
@@ -10,27 +10,16 @@
#include "base/memory/weak_ptr.h"
#include "components/offline_pages/core/offline_page_item.h"
-#include "components/offline_pages/core/prefetch/prefetch_dispatcher.h"
-
-class GURL;
+#include "components/offline_pages/core/prefetch/prefetch_types.h"
namespace offline_pages {
+class PrefetchService;
// Serves as the entry point for external signals into the prefetching system.
// It listens to these events, converts them to the appropriate internal tasks
// and manage their execution and inter-dependencies.
class PrefetchDispatcher {
public:
- struct PrefetchURL {
- // Used to differentiate URLs from different sources. |name_space| should
- // be unique per source. |id| can be anything useful to identify the page,
- // but will not be used for deduplication.
- ClientId client_id;
-
- // This URL will be prefetched by the system.
- GURL url;
- };
-
// A |ScopedBackgroundTask| is created when we are running in a background
// task. Destroying this object should notify the system that we are done
// processing the background task.
@@ -46,9 +35,15 @@ class PrefetchDispatcher {
virtual ~PrefetchDispatcher() = default;
- // Called when a consumer has candidate URLs for the system to prefetch.
- // Duplicates are accepted by the PrefetchDispatcher but ignored.
+ // Initializes the dispatcher with its respective service instance. This must
+ // be done before any other methods are called.
+ virtual void SetService(PrefetchService* service) = 0;
+
+ // Called when a client has candidate URLs for the system to prefetch, along
+ // with the client's unique namespace. URLs that are currently in the system
+ // for this client are acceptable but ignored.
virtual void AddCandidatePrefetchURLs(
+ const std::string& name_space,
const std::vector<PrefetchURL>& prefetch_urls) = 0;
// Called when all existing suggestions are no longer considered valid for a
@@ -59,7 +54,8 @@ class PrefetchDispatcher {
// Called to invalidate a single PrefetchURL entry identified by |client_id|.
// If multiple have the same |client_id|, they will all be removed.
- virtual void RemovePrefetchURLsByClientId(const ClientId& client_id) = 0;
+ virtual void RemovePrefetchURLsByClientId(const std::string& name_space,
+ const std::string& client_id) = 0;
// Called when Android OS has scheduled us for background work. When
// destroyed, |task| will call back and inform the OS that we are done work

Powered by Google App Engine
This is Rietveld 408576698