| 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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 | 143 |
| 144 // Returns the status of the most recent offlining. | 144 // Returns the status of the most recent offlining. |
| 145 Offliner::RequestStatus last_offlining_status() { | 145 Offliner::RequestStatus last_offlining_status() { |
| 146 return last_offlining_status_; | 146 return last_offlining_status_; |
| 147 } | 147 } |
| 148 | 148 |
| 149 bool is_busy() { | 149 bool is_busy() { |
| 150 return is_busy_; | 150 return is_busy_; |
| 151 } | 151 } |
| 152 | 152 |
| 153 // Returns whether processing is starting (before it is decided to actually |
| 154 // process a request (is_busy()) at this time or not. |
| 155 bool is_starting() { return is_starting_; } |
| 156 |
| 153 // Tracks whether the last offlining attempt got canceled. This is reset by | 157 // Tracks whether the last offlining attempt got canceled. This is reset by |
| 154 // the next StartProcessing() call. | 158 // the next StartProcessing() call. |
| 155 bool is_canceled() { | 159 bool is_canceled() { |
| 156 return is_stopped_; | 160 return is_stopped_; |
| 157 } | 161 } |
| 158 | 162 |
| 159 OfflineEventLogger* GetLogger() { | 163 OfflineEventLogger* GetLogger() { |
| 160 return &event_logger_; | 164 return &event_logger_; |
| 161 } | 165 } |
| 162 | 166 |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 void SetDeviceConditionsForTest(DeviceConditions& current_conditions) { | 261 void SetDeviceConditionsForTest(DeviceConditions& current_conditions) { |
| 258 current_conditions_.reset(new DeviceConditions(current_conditions)); | 262 current_conditions_.reset(new DeviceConditions(current_conditions)); |
| 259 } | 263 } |
| 260 | 264 |
| 261 friend class RequestCoordinatorTest; | 265 friend class RequestCoordinatorTest; |
| 262 | 266 |
| 263 // The offliner can only handle one request at a time - if the offliner is | 267 // The offliner can only handle one request at a time - if the offliner is |
| 264 // busy, prevent other requests. This flag marks whether the offliner is in | 268 // busy, prevent other requests. This flag marks whether the offliner is in |
| 265 // use. | 269 // use. |
| 266 bool is_busy_; | 270 bool is_busy_; |
| 267 // True if the current request has been canceled. | 271 // There is more than one path to start processing so this flag is used |
| 272 // to avoid race conditions before is_busy_ is established. |
| 273 bool is_starting_; |
| 274 // True if the current processing window has been canceled. |
| 268 bool is_stopped_; | 275 bool is_stopped_; |
| 269 // True if we should use the test connection type instead of the actual type. | 276 // True if we should use the test connection type instead of the actual type. |
| 270 bool use_test_connection_type_; | 277 bool use_test_connection_type_; |
| 271 // For use by tests, a fake network connection type | 278 // For use by tests, a fake network connection type |
| 272 net::NetworkChangeNotifier::ConnectionType test_connection_type_; | 279 net::NetworkChangeNotifier::ConnectionType test_connection_type_; |
| 273 // Unowned pointer to the current offliner, if any. | 280 // Unowned pointer to the current offliner, if any. |
| 274 Offliner* offliner_; | 281 Offliner* offliner_; |
| 275 base::Time operation_start_time_; | 282 base::Time operation_start_time_; |
| 276 // The observers. | 283 // The observers. |
| 277 base::ObserverList<Observer> observers_; | 284 base::ObserverList<Observer> observers_; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 301 base::TimeDelta offliner_timeout_; | 308 base::TimeDelta offliner_timeout_; |
| 302 // Allows us to pass a weak pointer to callbacks. | 309 // Allows us to pass a weak pointer to callbacks. |
| 303 base::WeakPtrFactory<RequestCoordinator> weak_ptr_factory_; | 310 base::WeakPtrFactory<RequestCoordinator> weak_ptr_factory_; |
| 304 | 311 |
| 305 DISALLOW_COPY_AND_ASSIGN(RequestCoordinator); | 312 DISALLOW_COPY_AND_ASSIGN(RequestCoordinator); |
| 306 }; | 313 }; |
| 307 | 314 |
| 308 } // namespace offline_pages | 315 } // namespace offline_pages |
| 309 | 316 |
| 310 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_COORDINATOR_H_ | 317 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_COORDINATOR_H_ |
| OLD | NEW |