| Index: components/offline_pages/background/request_coordinator.cc
|
| diff --git a/components/offline_pages/background/request_coordinator.cc b/components/offline_pages/background/request_coordinator.cc
|
| index e2270fbfd99f8df5e2b9e6a5eb2a7fd7a232fce3..bf447575773bc00e0defe3b16d72bbbdf0695afa 100644
|
| --- a/components/offline_pages/background/request_coordinator.cc
|
| +++ b/components/offline_pages/background/request_coordinator.cc
|
| @@ -6,6 +6,7 @@
|
|
|
| #include <utility>
|
|
|
| +#include "base/bind.h"
|
| #include "components/offline_pages/background/offliner_factory.h"
|
| #include "components/offline_pages/background/offliner_policy.h"
|
| #include "components/offline_pages/background/save_page_request.h"
|
| @@ -13,27 +14,48 @@
|
|
|
| namespace offline_pages {
|
|
|
| -RequestCoordinator::RequestCoordinator(
|
| - std::unique_ptr<OfflinerPolicy> policy,
|
| - std::unique_ptr<OfflinerFactory> factory) {
|
| +RequestCoordinator::RequestCoordinator(std::unique_ptr<OfflinerPolicy> policy,
|
| + std::unique_ptr<OfflinerFactory> factory,
|
| + std::unique_ptr<RequestQueue> queue) {
|
| // Do setup as needed.
|
| // TODO(petewil): Assert policy not null.
|
| policy_ = std::move(policy);
|
| factory_ = std::move(factory);
|
| + queue_ = std::move(queue);
|
| }
|
|
|
| RequestCoordinator::~RequestCoordinator() {}
|
|
|
| bool RequestCoordinator::SavePageLater(
|
| const GURL& url, const ClientId& client_id) {
|
| + DVLOG(2) << "URL is " << url << " " << __FUNCTION__;
|
|
|
| // TODO(petewil): We need a robust scheme for allocating new IDs.
|
| - // TODO(petewil): Build a SavePageRequest.
|
| - // TODO(petewil): Put the request on the request queue, nudge the scheduler.
|
| + static int64_t id = 0;
|
| +
|
| + // Build a SavePageRequest.
|
| + // TODO(petewil): Use something like base::Clock to help in testing.
|
| + offline_pages::SavePageRequest request(
|
| + id++, url, client_id, base::Time::Now());
|
| +
|
| + // Put the request on the request queue.
|
| + queue_->AddRequest(request,
|
| + base::Bind(&RequestCoordinator::AddRequestResultCallback,
|
| + AsWeakPtr()));
|
| + // TODO: Do I need to persist the request in case the add fails?
|
|
|
| return true;
|
| }
|
|
|
| +void RequestCoordinator::AddRequestResultCallback(
|
| + RequestQueue::AddRequestResult result,
|
| + const SavePageRequest& request) {
|
| + DVLOG(2) << __FUNCTION__;
|
| +
|
| + // Inform the scheduler that we have an outstanding task.
|
| + // TODO(petewil): implement.
|
| +}
|
| +
|
| bool RequestCoordinator::StartProcessing(
|
| const ProcessingDoneCallback& callback) {
|
| return false;
|
|
|