Chromium Code Reviews| 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 "base/callback.h" | 8 #include "base/callback.h" |
| 9 | 9 |
| 10 namespace offline_pages { | 10 namespace offline_pages { |
| 11 | 11 |
| 12 class SavePageRequest; | |
| 13 | |
| 12 // Coordinates queueing and processing save page later requests. | 14 // Coordinates queueing and processing save page later requests. |
| 13 class RequestCoordinator { | 15 class RequestCoordinator { |
| 14 public: | 16 public: |
| 15 // Callback to report when the processing of a triggered task is complete. | 17 // Callback to report when the processing of a triggered task is complete. |
| 16 typedef base::Callback<void()> ProcessingDoneCallback; | 18 typedef base::Callback<void()> ProcessingDoneCallback; |
| 17 | 19 |
| 18 struct SavePageRequest { | |
| 19 // TODO(dougarnett): define and consider making stand-alone. | |
| 20 }; | |
| 21 | |
| 22 // TODO(dougarnett): How to inject Offliner factories and policy objects. | 20 // TODO(dougarnett): How to inject Offliner factories and policy objects. |
| 23 RequestCoordinator(); | 21 RequestCoordinator(); |
| 24 | 22 |
| 25 ~RequestCoordinator(); | 23 ~RequestCoordinator(); |
| 26 | 24 |
| 27 // Queues |request| to later load and save when system conditions allow. | 25 // Queues |request| to later load and save when system conditions allow. |
| 26 // Returns true if the page could be queueud successfully. | |
|
fgorski
2016/05/04 17:39:44
nit: queued
Pete Williamson
2016/05/04 18:17:42
Done.
| |
| 28 bool SavePageLater(const SavePageRequest& request); | 27 bool SavePageLater(const SavePageRequest& request); |
| 29 | 28 |
| 30 // Starts processing of one or more queued save page later requests. | 29 // Starts processing of one or more queued save page later requests. |
| 31 // Returns whether processing was started and that caller should expect | 30 // Returns whether processing was started and that caller should expect |
| 32 // a callback. If processing was already active, returns false. | 31 // a callback. If processing was already active, returns false. |
| 33 bool StartProcessing(const ProcessingDoneCallback& callback); | 32 bool StartProcessing(const ProcessingDoneCallback& callback); |
| 34 | 33 |
| 35 // Stops the current request processing if active. This is a way for | 34 // Stops the current request processing if active. This is a way for |
| 36 // caller to abort processing; otherwise, processing will complete on | 35 // caller to abort processing; otherwise, processing will complete on |
| 37 // its own. In either case, the callback will be called when processing | 36 // its own. In either case, the callback will be called when processing |
| 38 // is stopped or complete. | 37 // is stopped or complete. |
| 39 void StopProcessing(); | 38 void StopProcessing(); |
| 40 | 39 |
| 41 // TODO(dougarnett): add policy support methods. | 40 // TODO(dougarnett): add policy support methods. |
| 42 }; | 41 }; |
| 43 | 42 |
| 44 } // namespace offline_pages | 43 } // namespace offline_pages |
| 45 | 44 |
| 46 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_COORDINATOR_H_ | 45 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_COORDINATOR_H_ |
| OLD | NEW |