OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_COORDINATOR_H_ |
| 6 #define COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_COORDINATOR_H_ |
| 7 |
| 8 namespace offline_pages { |
| 9 |
| 10 class SavePageRequest; |
| 11 |
| 12 // Coordinates queueing and processing save page later requests. |
| 13 class RequestCoordinator : public KeyedService { |
| 14 public: |
| 15 // Callback to report when the processing of a triggered task is complete. |
| 16 typedef base::Callback<void()> ProcessingDoneCallback; |
| 17 |
| 18 // TODO(dougarnett): How to inject Offliner factories and policy objects. |
| 19 RequestCoordinator(); |
| 20 |
| 21 ~RequestCoordinator() {} |
| 22 |
| 23 // Handles shutdown of KeyedService. |
| 24 void Shutdown(); |
| 25 |
| 26 // Queues |request| to later load and save when system conditions allow. |
| 27 bool SavePageLater(const SavePageRequest& request); |
| 28 |
| 29 // Starts processing of one or more queued save page later requests. |
| 30 // Returns whether processing was started and that caller should expect |
| 31 // a callback. If processing was already active, returns false. |
| 32 bool StartProcessing(const ProcessingDoneCallback& callback); |
| 33 |
| 34 // Stops the current request processing if active. This is a way for |
| 35 // caller to abort processing; otherwise, processing will complete on |
| 36 // its own. In either case, the callback will be called when processing |
| 37 // is stopped or complete. |
| 38 void StopProcessing(); |
| 39 |
| 40 // TODO(dougarnett): add policy support methods. |
| 41 }; |
| 42 |
| 43 } // namespace offline_pages |
| 44 |
| 45 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_COORDINATOR_H_ |
OLD | NEW |