| 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 <limits> | 7 #include <limits> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/metrics/histogram_macros.h" | 13 #include "base/metrics/histogram_macros.h" |
| 14 #include "base/rand_util.h" | 14 #include "base/rand_util.h" |
| 15 #include "base/sys_info.h" | 15 #include "base/sys_info.h" |
| 16 #include "base/time/time.h" | 16 #include "base/time/time.h" |
| 17 #include "components/offline_pages/background/offliner_factory.h" | 17 #include "components/offline_pages/background/offliner_factory.h" |
| 18 #include "components/offline_pages/background/offliner_policy.h" | 18 #include "components/offline_pages/background/offliner_policy.h" |
| 19 #include "components/offline_pages/background/request_picker.h" | 19 #include "components/offline_pages/background/request_picker.h" |
| 20 #include "components/offline_pages/background/save_page_request.h" | 20 #include "components/offline_pages/background/save_page_request.h" |
| 21 #include "components/offline_pages/client_policy_controller.h" | 21 #include "components/offline_pages/client_policy_controller.h" |
| 22 #include "components/offline_pages/offline_page_feature.h" |
| 22 #include "components/offline_pages/offline_page_item.h" | 23 #include "components/offline_pages/offline_page_item.h" |
| 23 #include "components/offline_pages/offline_page_model.h" | 24 #include "components/offline_pages/offline_page_model.h" |
| 24 | 25 |
| 25 namespace offline_pages { | 26 namespace offline_pages { |
| 26 | 27 |
| 27 namespace { | 28 namespace { |
| 28 const bool kUserRequest = true; | 29 const bool kUserRequest = true; |
| 29 const int kMinDurationSeconds = 1; | 30 const int kMinDurationSeconds = 1; |
| 30 const int kMaxDurationSeconds = 7 * 24 * 60 * 60; // 7 days | 31 const int kMaxDurationSeconds = 7 * 24 * 60 * 60; // 7 days |
| 31 const int kDurationBuckets = 50; | 32 const int kDurationBuckets = 50; |
| (...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 542 RequestCoordinator::OfflinerImmediateStartStatus::STATUS_COUNT); | 543 RequestCoordinator::OfflinerImmediateStartStatus::STATUS_COUNT); |
| 543 } | 544 } |
| 544 | 545 |
| 545 RequestCoordinator::OfflinerImmediateStartStatus | 546 RequestCoordinator::OfflinerImmediateStartStatus |
| 546 RequestCoordinator::TryImmediateStart() { | 547 RequestCoordinator::TryImmediateStart() { |
| 547 // Make sure not already busy processing. | 548 // Make sure not already busy processing. |
| 548 if (is_busy_) | 549 if (is_busy_) |
| 549 return OfflinerImmediateStartStatus::BUSY; | 550 return OfflinerImmediateStartStatus::BUSY; |
| 550 | 551 |
| 551 // Make sure we are not on svelte device to start immediately. | 552 // Make sure we are not on svelte device to start immediately. |
| 552 if (is_low_end_device_) { | 553 if (is_low_end_device_ && |
| 554 !offline_pages::IsOfflinePagesSvelteConcurrentLoadingEnabled()) { |
| 553 DVLOG(2) << "low end device, returning"; | 555 DVLOG(2) << "low end device, returning"; |
| 554 // Let the scheduler know we are done processing and failed due to svelte. | 556 // Let the scheduler know we are done processing and failed due to svelte. |
| 555 immediate_schedule_callback_.Run(false); | 557 immediate_schedule_callback_.Run(false); |
| 556 return OfflinerImmediateStartStatus::NOT_STARTED_ON_SVELTE; | 558 return OfflinerImmediateStartStatus::NOT_STARTED_ON_SVELTE; |
| 557 } | 559 } |
| 558 | 560 |
| 559 if (GetConnectionType() == | 561 if (GetConnectionType() == |
| 560 net::NetworkChangeNotifier::ConnectionType::CONNECTION_NONE) | 562 net::NetworkChangeNotifier::ConnectionType::CONNECTION_NONE) |
| 561 return OfflinerImmediateStartStatus::NO_CONNECTION; | 563 return OfflinerImmediateStartStatus::NO_CONNECTION; |
| 562 | 564 |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 869 | 871 |
| 870 ClientPolicyController* RequestCoordinator::GetPolicyController() { | 872 ClientPolicyController* RequestCoordinator::GetPolicyController() { |
| 871 return policy_controller_.get(); | 873 return policy_controller_.get(); |
| 872 } | 874 } |
| 873 | 875 |
| 874 void RequestCoordinator::Shutdown() { | 876 void RequestCoordinator::Shutdown() { |
| 875 network_quality_estimator_ = nullptr; | 877 network_quality_estimator_ = nullptr; |
| 876 } | 878 } |
| 877 | 879 |
| 878 } // namespace offline_pages | 880 } // namespace offline_pages |
| OLD | NEW |