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

Unified Diff: components/offline_pages/background/request_coordinator.h

Issue 1969463002: Add a save page request to the request queue (and test it). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More CR feedback from FGorski Created 4 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
« no previous file with comments | « chrome/chrome_tests_unit.gypi ('k') | components/offline_pages/background/request_coordinator.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/offline_pages/background/request_coordinator.h
diff --git a/components/offline_pages/background/request_coordinator.h b/components/offline_pages/background/request_coordinator.h
index c5dee91e55823f3af3e6948094f24d5fb8aee1df..44d937409fb97010c523edc2dec773567af07c30 100644
--- a/components/offline_pages/background/request_coordinator.h
+++ b/components/offline_pages/background/request_coordinator.h
@@ -9,7 +9,9 @@
#include "base/callback.h"
#include "base/macros.h"
+#include "base/memory/weak_ptr.h"
#include "components/keyed_service/core/keyed_service.h"
+#include "components/offline_pages/background/request_queue.h"
#include "url/gurl.h"
namespace offline_pages {
@@ -21,13 +23,16 @@ class Offliner;
class SavePageRequest;
// Coordinates queueing and processing save page later requests.
-class RequestCoordinator : public KeyedService {
+class RequestCoordinator :
+ public KeyedService,
+ public base::SupportsWeakPtr<RequestCoordinator> {
public:
// Callback to report when the processing of a triggered task is complete.
typedef base::Callback<void()> ProcessingDoneCallback;
RequestCoordinator(std::unique_ptr<OfflinerPolicy> policy,
- std::unique_ptr<OfflinerFactory> factory);
+ std::unique_ptr<OfflinerFactory> factory,
+ std::unique_ptr<RequestQueue> queue);
~RequestCoordinator() override;
@@ -46,11 +51,18 @@ class RequestCoordinator : public KeyedService {
// is stopped or complete.
void StopProcessing();
+ // Returns the request queue used for requests. Coordinator keeps ownership.
+ RequestQueue* GetQueue() { return queue_.get(); }
+
private:
- // RequestCoordinator takes over ownership of the policy
+ void AddRequestResultCallback(RequestQueue::AddRequestResult result,
+ const SavePageRequest& request);
+ // OfflinerPolicy. Used to store policies. Owned.
std::unique_ptr<OfflinerPolicy> policy_;
- // Factory is owned by the RequestCoordinator.
+ // OfflinerFactory. Used to create offline pages. Owned.
std::unique_ptr<OfflinerFactory> factory_;
+ // RequestQueue. Used to store incoming requests. Owned.
+ std::unique_ptr<RequestQueue> queue_;
DISALLOW_COPY_AND_ASSIGN(RequestCoordinator);
};
« no previous file with comments | « chrome/chrome_tests_unit.gypi ('k') | components/offline_pages/background/request_coordinator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698