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 <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 22 class OfflinerFactory; | 22 class OfflinerFactory; |
| 23 class Offliner; | 23 class Offliner; |
| 24 class RequestPicker; | 24 class RequestPicker; |
| 25 class SavePageRequest; | 25 class SavePageRequest; |
| 26 class Scheduler; | 26 class Scheduler; |
| 27 | 27 |
| 28 // Coordinates queueing and processing save page later requests. | 28 // Coordinates queueing and processing save page later requests. |
| 29 class RequestCoordinator : public KeyedService { | 29 class RequestCoordinator : public KeyedService { |
| 30 public: | 30 public: |
| 31 // Callback to report when the processing of a triggered task is complete. | 31 // Callback to report when the processing of a triggered task is complete. |
| 32 typedef base::Callback<void()> ProcessingDoneCallback; | 32 typedef base::Callback<void()> ProcessingDoneCallback; |
|
Bernhard Bauer
2016/06/08 14:09:29
Is this now used anymore?
Pete Williamson
2016/06/08 17:43:28
Removed
| |
| 33 typedef base::Callback<void(const SavePageRequest& request)> | 33 typedef base::Callback<void(const SavePageRequest& request)> |
| 34 RequestPickedCallback; | 34 RequestPickedCallback; |
| 35 typedef base::Callback<void()> RequestQueueEmptyCallback; | 35 typedef base::Callback<void()> RequestQueueEmptyCallback; |
| 36 | 36 |
| 37 RequestCoordinator(std::unique_ptr<OfflinerPolicy> policy, | 37 RequestCoordinator(std::unique_ptr<OfflinerPolicy> policy, |
| 38 std::unique_ptr<OfflinerFactory> factory, | 38 std::unique_ptr<OfflinerFactory> factory, |
| 39 std::unique_ptr<RequestQueue> queue, | 39 std::unique_ptr<RequestQueue> queue, |
| 40 std::unique_ptr<Scheduler> scheduler); | 40 std::unique_ptr<Scheduler> scheduler); |
| 41 | 41 |
| 42 ~RequestCoordinator() override; | 42 ~RequestCoordinator() override; |
| 43 | 43 |
| 44 // Queues |request| to later load and save when system conditions allow. | 44 // Queues |request| to later load and save when system conditions allow. |
| 45 // Returns true if the page could be queued successfully. | 45 // Returns true if the page could be queued successfully. |
| 46 bool SavePageLater(const GURL& url, const ClientId& client_id); | 46 bool SavePageLater(const GURL& url, const ClientId& client_id); |
| 47 | 47 |
| 48 // Starts processing of one or more queued save page later requests. | 48 // Starts processing of one or more queued save page later requests. |
| 49 // Returns whether processing was started and that caller should expect | 49 // Returns whether processing was started and that caller should expect |
| 50 // a callback. If processing was already active, returns false. | 50 // a callback. If processing was already active, returns false. |
| 51 bool StartProcessing(const ProcessingDoneCallback& callback); | 51 bool StartProcessing(const base::Callback<void(bool)> callback); |
|
Bernhard Bauer
2016/06/08 14:09:29
I would still pass the callback by (const) referen
Pete Williamson
2016/06/08 17:43:28
Done.
| |
| 52 | 52 |
| 53 // Stops the current request processing if active. This is a way for | 53 // Stops the current request processing if active. This is a way for |
| 54 // caller to abort processing; otherwise, processing will complete on | 54 // caller to abort processing; otherwise, processing will complete on |
| 55 // its own. In either case, the callback will be called when processing | 55 // its own. In either case, the callback will be called when processing |
| 56 // is stopped or complete. | 56 // is stopped or complete. |
| 57 void StopProcessing(); | 57 void StopProcessing(); |
| 58 | 58 |
| 59 // Returns the request queue used for requests. Coordinator keeps ownership. | 59 // Returns the request queue used for requests. Coordinator keeps ownership. |
| 60 RequestQueue* queue() { return queue_.get(); } | 60 RequestQueue* queue() { return queue_.get(); } |
| 61 | 61 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 96 std::unique_ptr<RequestPicker> picker_; | 96 std::unique_ptr<RequestPicker> picker_; |
| 97 // Allows us to pass a weak pointer to callbacks. | 97 // Allows us to pass a weak pointer to callbacks. |
| 98 base::WeakPtrFactory<RequestCoordinator> weak_ptr_factory_; | 98 base::WeakPtrFactory<RequestCoordinator> weak_ptr_factory_; |
| 99 | 99 |
| 100 DISALLOW_COPY_AND_ASSIGN(RequestCoordinator); | 100 DISALLOW_COPY_AND_ASSIGN(RequestCoordinator); |
| 101 }; | 101 }; |
| 102 | 102 |
| 103 } // namespace offline_pages | 103 } // namespace offline_pages |
| 104 | 104 |
| 105 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_COORDINATOR_H_ | 105 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_COORDINATOR_H_ |
| OLD | NEW |