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

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

Issue 2113383002: More detailed implementation of the RequestPicker (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Try a different way of checking policy to separate policy from checking. Created 4 years, 5 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.cc
diff --git a/components/offline_pages/background/request_coordinator.cc b/components/offline_pages/background/request_coordinator.cc
index e6ac73f55fc065eb4b25c8fee76eb8ad2f1f444c..85d6356f3d54d8d66526295f6acc4eefdb3b9c21 100644
--- a/components/offline_pages/background/request_coordinator.cc
+++ b/components/offline_pages/background/request_coordinator.cc
@@ -60,22 +60,23 @@ RequestCoordinator::RequestCoordinator(std::unique_ptr<OfflinerPolicy> policy,
last_offlining_status_(Offliner::RequestStatus::UNKNOWN),
weak_ptr_factory_(this) {
DCHECK(policy_ != nullptr);
- picker_.reset(new RequestPicker(queue_.get()));
+ picker_.reset(new RequestPicker(queue_.get(), policy_.get()));
}
RequestCoordinator::~RequestCoordinator() {}
bool RequestCoordinator::SavePageLater(
- const GURL& url, const ClientId& client_id) {
+ const GURL& url, const ClientId& client_id, bool was_user_requested) {
DVLOG(2) << "URL is " << url << " " << __FUNCTION__;
- // TODO(petewil): We need a robust scheme for allocating new IDs.
+ // TODO(petewil): We need a robust scheme for allocating new IDs. We may need
+ // GUIDS for the downloads home design.
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());
+ id++, url, client_id, base::Time::Now(), was_user_requested);
// Put the request on the request queue.
queue_->AddRequest(request,
@@ -116,6 +117,7 @@ void RequestCoordinator::StopProcessing() {
bool RequestCoordinator::StartProcessing(
const DeviceConditions& device_conditions,
const base::Callback<void(bool)>& callback) {
+ current_conditions_.reset(new DeviceConditions(device_conditions));
if (is_busy_) return false;
is_canceled_ = false;
@@ -135,7 +137,8 @@ void RequestCoordinator::TryNextRequest() {
base::Bind(&RequestCoordinator::RequestPicked,
weak_ptr_factory_.GetWeakPtr()),
base::Bind(&RequestCoordinator::RequestQueueEmpty,
- weak_ptr_factory_.GetWeakPtr()));
+ weak_ptr_factory_.GetWeakPtr()),
+ current_conditions_.get());
}
// Called by the request picker when a request has been picked.

Powered by Google App Engine
This is Rietveld 408576698