OLD | NEW |
---|---|
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 #ifndef COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_COORDINATOR_H_ | 5 #ifndef COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_COORDINATOR_H_ |
6 #define COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_COORDINATOR_H_ | 6 #define COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_COORDINATOR_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
159 // the next StartProcessing() call. | 159 // the next StartProcessing() call. |
160 bool is_canceled() { | 160 bool is_canceled() { |
161 return is_stopped_; | 161 return is_stopped_; |
162 } | 162 } |
163 | 163 |
164 OfflineEventLogger* GetLogger() { | 164 OfflineEventLogger* GetLogger() { |
165 return &event_logger_; | 165 return &event_logger_; |
166 } | 166 } |
167 | 167 |
168 private: | 168 private: |
169 enum class OfflinerImmediateStartStatus { | |
Mark P
2016/10/06 18:54:41
Please follow the advice here about enum histogram
dougarnett
2016/10/06 23:05:00
switched to unscoped enum with explicit values
| |
170 STARTED, | |
171 BUSY, | |
172 NOT_ACCEPTED, | |
173 NO_CONNECTION, | |
174 NO_EFFECTIVE_CONNECTION, | |
Mark P
2016/10/06 18:54:41
What's the difference between this one and the one
dougarnett
2016/10/06 23:05:00
Done.
| |
175 NOT_STARTED_ON_SVELTE, | |
176 // NOTE: insert new values above this line and update histogram enum too. | |
177 STATUS_COUNT, | |
178 }; | |
179 | |
169 // Receives the results of a get from the request queue, and turns that into | 180 // Receives the results of a get from the request queue, and turns that into |
170 // SavePageRequest objects for the caller of GetQueuedRequests. | 181 // SavePageRequest objects for the caller of GetQueuedRequests. |
171 void GetQueuedRequestsCallback( | 182 void GetQueuedRequestsCallback( |
172 const GetRequestsCallback& callback, | 183 const GetRequestsCallback& callback, |
173 RequestQueue::GetRequestsResult result, | 184 RequestQueue::GetRequestsResult result, |
174 std::vector<std::unique_ptr<SavePageRequest>> requests); | 185 std::vector<std::unique_ptr<SavePageRequest>> requests); |
175 | 186 |
176 // Receives the results of a get from the request queue, and turns that into | 187 // Receives the results of a get from the request queue, and turns that into |
177 // SavePageRequest objects for the caller of GetQueuedRequests. | 188 // SavePageRequest objects for the caller of GetQueuedRequests. |
178 void GetRequestsForSchedulingCallback( | 189 void GetRequestsForSchedulingCallback( |
(...skipping 19 matching lines...) Expand all Loading... | |
198 | 209 |
199 void HandleRemovedRequests( | 210 void HandleRemovedRequests( |
200 BackgroundSavePageResult status, | 211 BackgroundSavePageResult status, |
201 const RequestQueue::UpdateMultipleRequestResults& results, | 212 const RequestQueue::UpdateMultipleRequestResults& results, |
202 std::vector<std::unique_ptr<SavePageRequest>> requests); | 213 std::vector<std::unique_ptr<SavePageRequest>> requests); |
203 | 214 |
204 // Start processing now if connected (but with conservative assumption | 215 // Start processing now if connected (but with conservative assumption |
205 // as to other device conditions). | 216 // as to other device conditions). |
206 void StartProcessingIfConnected(); | 217 void StartProcessingIfConnected(); |
207 | 218 |
219 OfflinerImmediateStartStatus TryImmediateStart(); | |
220 | |
208 // Check the request queue, and schedule a task corresponding | 221 // Check the request queue, and schedule a task corresponding |
209 // to the least restrictive type of request in the queue. | 222 // to the least restrictive type of request in the queue. |
210 void ScheduleAsNeeded(); | 223 void ScheduleAsNeeded(); |
211 | 224 |
212 // Callback from the request picker when it has chosen our next request. | 225 // Callback from the request picker when it has chosen our next request. |
213 void RequestPicked(const SavePageRequest& request); | 226 void RequestPicked(const SavePageRequest& request); |
214 | 227 |
215 // Callback from the request picker when no more requests are in the queue. | 228 // Callback from the request picker when no more requests are in the queue. |
216 // The parameter is a signal for what (if any) conditions to schedule future | 229 // The parameter is a signal for what (if any) conditions to schedule future |
217 // processing for. | 230 // processing for. |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
317 base::TimeDelta offliner_timeout_; | 330 base::TimeDelta offliner_timeout_; |
318 // Allows us to pass a weak pointer to callbacks. | 331 // Allows us to pass a weak pointer to callbacks. |
319 base::WeakPtrFactory<RequestCoordinator> weak_ptr_factory_; | 332 base::WeakPtrFactory<RequestCoordinator> weak_ptr_factory_; |
320 | 333 |
321 DISALLOW_COPY_AND_ASSIGN(RequestCoordinator); | 334 DISALLOW_COPY_AND_ASSIGN(RequestCoordinator); |
322 }; | 335 }; |
323 | 336 |
324 } // namespace offline_pages | 337 } // namespace offline_pages |
325 | 338 |
326 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_COORDINATOR_H_ | 339 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_COORDINATOR_H_ |
OLD | NEW |