Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Side by Side Diff: components/offline_pages/background/request_coordinator.cc

Issue 2483463002: [Offline Pages] Feature flag to allow concurrent background loading on svelte (Closed)
Patch Set: Merge Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 512 matching lines...) Expand 10 before | Expand all | Expand 10 after
544 RequestCoordinator::OfflinerImmediateStartStatus::STATUS_COUNT); 545 RequestCoordinator::OfflinerImmediateStartStatus::STATUS_COUNT);
545 } 546 }
546 547
547 RequestCoordinator::OfflinerImmediateStartStatus 548 RequestCoordinator::OfflinerImmediateStartStatus
548 RequestCoordinator::TryImmediateStart() { 549 RequestCoordinator::TryImmediateStart() {
549 // Make sure not already busy processing. 550 // Make sure not already busy processing.
550 if (is_busy_) 551 if (is_busy_)
551 return OfflinerImmediateStartStatus::BUSY; 552 return OfflinerImmediateStartStatus::BUSY;
552 553
553 // Make sure we are not on svelte device to start immediately. 554 // Make sure we are not on svelte device to start immediately.
554 if (is_low_end_device_) { 555 if (is_low_end_device_ &&
556 !offline_pages::IsOfflinePagesSvelteConcurrentLoadingEnabled()) {
555 DVLOG(2) << "low end device, returning"; 557 DVLOG(2) << "low end device, returning";
556 // Let the scheduler know we are done processing and failed due to svelte. 558 // Let the scheduler know we are done processing and failed due to svelte.
557 immediate_schedule_callback_.Run(false); 559 immediate_schedule_callback_.Run(false);
558 return OfflinerImmediateStartStatus::NOT_STARTED_ON_SVELTE; 560 return OfflinerImmediateStartStatus::NOT_STARTED_ON_SVELTE;
559 } 561 }
560 562
561 if (GetConnectionType() == 563 if (GetConnectionType() ==
562 net::NetworkChangeNotifier::ConnectionType::CONNECTION_NONE) 564 net::NetworkChangeNotifier::ConnectionType::CONNECTION_NONE)
563 return OfflinerImmediateStartStatus::NO_CONNECTION; 565 return OfflinerImmediateStartStatus::NO_CONNECTION;
564 566
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
872 874
873 ClientPolicyController* RequestCoordinator::GetPolicyController() { 875 ClientPolicyController* RequestCoordinator::GetPolicyController() {
874 return policy_controller_.get(); 876 return policy_controller_.get();
875 } 877 }
876 878
877 void RequestCoordinator::Shutdown() { 879 void RequestCoordinator::Shutdown() {
878 network_quality_estimator_ = nullptr; 880 network_quality_estimator_ = nullptr;
879 } 881 }
880 882
881 } // namespace offline_pages 883 } // namespace offline_pages
OLDNEW
« no previous file with comments | « components/offline_pages/background/BUILD.gn ('k') | components/offline_pages/background/request_coordinator_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698