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

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: CR feedback per 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
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..c8f0c99490cfa2c15d9f4f1462c73204f57a25ce 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,15 @@ class Offliner;
class SavePageRequest;
// Coordinates queueing and processing save page later requests.
-class RequestCoordinator : public KeyedService {
+class RequestCoordinator : public KeyedService,
+ public base::SupportsWeakPtr<RequestCoordinator> {
fgorski 2016/05/11 19:45:15 nit: alignment. Unless you ran git cl format and
Pete Williamson 2016/05/11 22:13:03 Done.
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 +50,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);
};

Powered by Google App Engine
This is Rietveld 408576698