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

Side by Side Diff: components/offline_pages/background/request_coordinator.cc

Issue 2064323004: Defines initial DeviceConditions and and plumbs down through StartProcessing() call. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge Created 4 years, 6 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/offline_pages/background/request_coordinator.h" 5 #include "components/offline_pages/background/request_coordinator.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 } 79 }
80 80
81 void RequestCoordinator::RequestQueueEmpty() { 81 void RequestCoordinator::RequestQueueEmpty() {
82 // Clear the outstanding "safety" task in the scheduler. 82 // Clear the outstanding "safety" task in the scheduler.
83 scheduler_->Unschedule(); 83 scheduler_->Unschedule();
84 // Return control to the scheduler when there is no more to do. 84 // Return control to the scheduler when there is no more to do.
85 scheduler_callback_.Run(true); 85 scheduler_callback_.Run(true);
86 } 86 }
87 87
88 bool RequestCoordinator::StartProcessing( 88 bool RequestCoordinator::StartProcessing(
89 const DeviceConditions& device_conditions,
89 const base::Callback<void(bool)>& callback) { 90 const base::Callback<void(bool)>& callback) {
90 scheduler_callback_ = callback; 91 scheduler_callback_ = callback;
91 // TODO(petewil): Check existing conditions (should be passed down from 92 // TODO(petewil): Check existing conditions (should be passed down from
92 // BackgroundTask) 93 // BackgroundTask)
93 94
94 TryNextRequest(); 95 TryNextRequest();
95 96
96 // TODO(petewil): Should return true if the caller should expect a 97 // TODO(petewil): Should return true if the caller should expect a
97 // callback. Return false if there is already a request running. 98 // callback. Return false if there is already a request running.
98 // Probably best to do this when I prevent multiple instances from 99 // Probably best to do this when I prevent multiple instances from
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 139
139 // TODO(petewil): If the request succeeded, remove it from the Queue. 140 // TODO(petewil): If the request succeeded, remove it from the Queue.
140 if (status == Offliner::RequestStatus::SAVED) { 141 if (status == Offliner::RequestStatus::SAVED) {
141 queue_->RemoveRequest(request.request_id(), 142 queue_->RemoveRequest(request.request_id(),
142 base::Bind(&RequestCoordinator::UpdateRequestCallback, 143 base::Bind(&RequestCoordinator::UpdateRequestCallback,
143 weak_ptr_factory_.GetWeakPtr())); 144 weak_ptr_factory_.GetWeakPtr()));
144 } 145 }
145 146
146 // TODO(petewil): Check time budget. Return to the scheduler if we are out. 147 // TODO(petewil): Check time budget. Return to the scheduler if we are out.
147 148
148
149 // Start a request if we have time. 149 // Start a request if we have time.
150 TryNextRequest(); 150 TryNextRequest();
151 } 151 }
152 152
153 } // namespace offline_pages 153 } // namespace offline_pages
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698