| 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 // its own. In either case, the callback will be called when processing | 53 // its own. In either case, the callback will be called when processing |
| 54 // is stopped or complete. | 54 // is stopped or complete. |
| 55 void StopProcessing(); | 55 void StopProcessing(); |
| 56 | 56 |
| 57 // Returns the request queue used for requests. Coordinator keeps ownership. | 57 // Returns the request queue used for requests. Coordinator keeps ownership. |
| 58 RequestQueue* GetQueue() { return queue_.get(); } | 58 RequestQueue* GetQueue() { return queue_.get(); } |
| 59 | 59 |
| 60 Scheduler* GetSchedulerForTesting() { return scheduler_.get(); } | 60 Scheduler* GetSchedulerForTesting() { return scheduler_.get(); } |
| 61 | 61 |
| 62 // Returns the status of the most recent offlining. | 62 // Returns the status of the most recent offlining. |
| 63 Offliner::CompletionStatus last_offlining_status() { | 63 Offliner::RequestStatus last_offlining_status() { |
| 64 return last_offlining_status_; | 64 return last_offlining_status_; |
| 65 } | 65 } |
| 66 | 66 |
| 67 private: | 67 private: |
| 68 void AddRequestResultCallback(RequestQueue::AddRequestResult result, | 68 void AddRequestResultCallback(RequestQueue::AddRequestResult result, |
| 69 const SavePageRequest& request); | 69 const SavePageRequest& request); |
| 70 | 70 |
| 71 void SendRequestToOffliner(SavePageRequest& request); | 71 void SendRequestToOffliner(const SavePageRequest& request); |
| 72 | 72 |
| 73 void OfflinerDoneCallback(const SavePageRequest& request, | 73 void OfflinerDoneCallback(const SavePageRequest& request, |
| 74 Offliner::CompletionStatus status); | 74 Offliner::RequestStatus status); |
| 75 | 75 |
| 76 // RequestCoordinator takes over ownership of the policy | 76 // RequestCoordinator takes over ownership of the policy |
| 77 std::unique_ptr<OfflinerPolicy> policy_; | 77 std::unique_ptr<OfflinerPolicy> policy_; |
| 78 // OfflinerFactory. Used to create offline pages. Owned. | 78 // OfflinerFactory. Used to create offline pages. Owned. |
| 79 std::unique_ptr<OfflinerFactory> factory_; | 79 std::unique_ptr<OfflinerFactory> factory_; |
| 80 // RequestQueue. Used to store incoming requests. Owned. | 80 // RequestQueue. Used to store incoming requests. Owned. |
| 81 std::unique_ptr<RequestQueue> queue_; | 81 std::unique_ptr<RequestQueue> queue_; |
| 82 // Scheduler. Used to request a callback when network is available. Owned. | 82 // Scheduler. Used to request a callback when network is available. Owned. |
| 83 std::unique_ptr<Scheduler> scheduler_; | 83 std::unique_ptr<Scheduler> scheduler_; |
| 84 // Status of the most recent offlining. | 84 // Status of the most recent offlining. |
| 85 Offliner::CompletionStatus last_offlining_status_; | 85 Offliner::RequestStatus last_offlining_status_; |
| 86 | 86 |
| 87 DISALLOW_COPY_AND_ASSIGN(RequestCoordinator); | 87 DISALLOW_COPY_AND_ASSIGN(RequestCoordinator); |
| 88 }; | 88 }; |
| 89 | 89 |
| 90 } // namespace offline_pages | 90 } // namespace offline_pages |
| 91 | 91 |
| 92 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_COORDINATOR_H_ | 92 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_COORDINATOR_H_ |
| OLD | NEW |