| 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 #include "components/offline_pages/background/request_coordinator.h" | 5 #include "components/offline_pages/background/request_coordinator.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/metrics/histogram_macros.h" | 12 #include "base/metrics/histogram_macros.h" |
| 13 #include "base/rand_util.h" | 13 #include "base/rand_util.h" |
| 14 #include "base/sys_info.h" |
| 14 #include "base/time/time.h" | 15 #include "base/time/time.h" |
| 15 #include "components/offline_pages/background/offliner_factory.h" | 16 #include "components/offline_pages/background/offliner_factory.h" |
| 16 #include "components/offline_pages/background/offliner_policy.h" | 17 #include "components/offline_pages/background/offliner_policy.h" |
| 17 #include "components/offline_pages/background/request_picker.h" | 18 #include "components/offline_pages/background/request_picker.h" |
| 18 #include "components/offline_pages/background/save_page_request.h" | 19 #include "components/offline_pages/background/save_page_request.h" |
| 19 #include "components/offline_pages/offline_page_item.h" | 20 #include "components/offline_pages/offline_page_item.h" |
| 20 #include "components/offline_pages/offline_page_model.h" | 21 #include "components/offline_pages/offline_page_model.h" |
| 21 | 22 |
| 22 namespace offline_pages { | 23 namespace offline_pages { |
| 23 | 24 |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 | 331 |
| 331 TryNextRequest(); | 332 TryNextRequest(); |
| 332 | 333 |
| 333 return true; | 334 return true; |
| 334 } | 335 } |
| 335 | 336 |
| 336 void RequestCoordinator::StartProcessingIfConnected() { | 337 void RequestCoordinator::StartProcessingIfConnected() { |
| 337 // Makes sure not already busy processing. | 338 // Makes sure not already busy processing. |
| 338 if (is_busy_) return; | 339 if (is_busy_) return; |
| 339 | 340 |
| 341 // Make sure we are not on svelte device to start immediately. |
| 342 if (base::SysInfo::IsLowEndDevice()) return; |
| 343 |
| 340 // Check for network connectivity. | 344 // Check for network connectivity. |
| 341 net::NetworkChangeNotifier::ConnectionType connection = GetConnectionType(); | 345 net::NetworkChangeNotifier::ConnectionType connection = GetConnectionType(); |
| 342 | 346 |
| 343 if ((connection != | 347 if ((connection != |
| 344 net::NetworkChangeNotifier::ConnectionType::CONNECTION_NONE)) { | 348 net::NetworkChangeNotifier::ConnectionType::CONNECTION_NONE)) { |
| 345 // Create conservative device conditions for the connectivity | 349 // Create conservative device conditions for the connectivity |
| 346 // (assume no battery). | 350 // (assume no battery). |
| 347 DeviceConditions device_conditions(false, 0, connection); | 351 DeviceConditions device_conditions(false, 0, connection); |
| 348 StartProcessing(device_conditions, base::Bind(&EmptySchedulerCallback)); | 352 StartProcessing(device_conditions, base::Bind(&EmptySchedulerCallback)); |
| 349 } | 353 } |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 537 FOR_EACH_OBSERVER(Observer, observers_, OnChanged(request)); | 541 FOR_EACH_OBSERVER(Observer, observers_, OnChanged(request)); |
| 538 } | 542 } |
| 539 | 543 |
| 540 void RequestCoordinator::GetOffliner() { | 544 void RequestCoordinator::GetOffliner() { |
| 541 if (!offliner_) { | 545 if (!offliner_) { |
| 542 offliner_ = factory_->GetOffliner(policy_.get()); | 546 offliner_ = factory_->GetOffliner(policy_.get()); |
| 543 } | 547 } |
| 544 } | 548 } |
| 545 | 549 |
| 546 } // namespace offline_pages | 550 } // namespace offline_pages |
| OLD | NEW |