| 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" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 13 #include "components/keyed_service/core/keyed_service.h" | 13 #include "components/keyed_service/core/keyed_service.h" |
| 14 #include "components/offline_pages/background/device_conditions.h" | 14 #include "components/offline_pages/background/device_conditions.h" |
| 15 #include "components/offline_pages/background/offliner.h" | 15 #include "components/offline_pages/background/offliner.h" |
| 16 #include "components/offline_pages/background/request_coordinator_event_logger.h
" |
| 16 #include "components/offline_pages/background/request_queue.h" | 17 #include "components/offline_pages/background/request_queue.h" |
| 17 #include "components/offline_pages/background/scheduler.h" | 18 #include "components/offline_pages/background/scheduler.h" |
| 18 #include "url/gurl.h" | 19 #include "url/gurl.h" |
| 19 | 20 |
| 20 namespace offline_pages { | 21 namespace offline_pages { |
| 21 | 22 |
| 22 struct ClientId; | 23 struct ClientId; |
| 23 class OfflinerPolicy; | 24 class OfflinerPolicy; |
| 24 class OfflinerFactory; | 25 class OfflinerFactory; |
| 25 class Offliner; | 26 class Offliner; |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 bool is_busy() { | 81 bool is_busy() { |
| 81 return is_busy_; | 82 return is_busy_; |
| 82 } | 83 } |
| 83 | 84 |
| 84 // Tracks whether the last offlining attempt got canceled. This is reset by | 85 // Tracks whether the last offlining attempt got canceled. This is reset by |
| 85 // the next StartProcessing() call. | 86 // the next StartProcessing() call. |
| 86 bool is_canceled() { | 87 bool is_canceled() { |
| 87 return is_canceled_; | 88 return is_canceled_; |
| 88 } | 89 } |
| 89 | 90 |
| 91 OfflineEventLogger* GetLogger() { |
| 92 return &event_logger_; |
| 93 } |
| 94 |
| 90 private: | 95 private: |
| 91 void AddRequestResultCallback(RequestQueue::AddRequestResult result, | 96 void AddRequestResultCallback(RequestQueue::AddRequestResult result, |
| 92 const SavePageRequest& request); | 97 const SavePageRequest& request); |
| 93 | 98 |
| 94 void UpdateRequestCallback(RequestQueue::UpdateRequestResult result); | 99 void UpdateRequestCallback(RequestQueue::UpdateRequestResult result); |
| 95 | 100 |
| 96 // Callback from the request picker when it has chosen our next request. | 101 // Callback from the request picker when it has chosen our next request. |
| 97 void RequestPicked(const SavePageRequest& request); | 102 void RequestPicked(const SavePageRequest& request); |
| 98 | 103 |
| 99 // Callback from the request picker when no more requests are in the queue. | 104 // Callback from the request picker when no more requests are in the queue. |
| (...skipping 29 matching lines...) Expand all Loading... |
| 129 // RequestQueue. Used to store incoming requests. Owned. | 134 // RequestQueue. Used to store incoming requests. Owned. |
| 130 std::unique_ptr<RequestQueue> queue_; | 135 std::unique_ptr<RequestQueue> queue_; |
| 131 // Scheduler. Used to request a callback when network is available. Owned. | 136 // Scheduler. Used to request a callback when network is available. Owned. |
| 132 std::unique_ptr<Scheduler> scheduler_; | 137 std::unique_ptr<Scheduler> scheduler_; |
| 133 // Status of the most recent offlining. | 138 // Status of the most recent offlining. |
| 134 Offliner::RequestStatus last_offlining_status_; | 139 Offliner::RequestStatus last_offlining_status_; |
| 135 // Class to choose which request to schedule next | 140 // Class to choose which request to schedule next |
| 136 std::unique_ptr<RequestPicker> picker_; | 141 std::unique_ptr<RequestPicker> picker_; |
| 137 // Calling this returns to the scheduler across the JNI bridge. | 142 // Calling this returns to the scheduler across the JNI bridge. |
| 138 base::Callback<void(bool)> scheduler_callback_; | 143 base::Callback<void(bool)> scheduler_callback_; |
| 144 // Logger to record events. |
| 145 RequestCoordinatorEventLogger event_logger_; |
| 139 // Allows us to pass a weak pointer to callbacks. | 146 // Allows us to pass a weak pointer to callbacks. |
| 140 base::WeakPtrFactory<RequestCoordinator> weak_ptr_factory_; | 147 base::WeakPtrFactory<RequestCoordinator> weak_ptr_factory_; |
| 141 | 148 |
| 142 DISALLOW_COPY_AND_ASSIGN(RequestCoordinator); | 149 DISALLOW_COPY_AND_ASSIGN(RequestCoordinator); |
| 143 }; | 150 }; |
| 144 | 151 |
| 145 } // namespace offline_pages | 152 } // namespace offline_pages |
| 146 | 153 |
| 147 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_COORDINATOR_H_ | 154 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_COORDINATOR_H_ |
| OLD | NEW |