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

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

Issue 2177943005: Move user requested trigger conditions into policy object. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Make more methods const Created 4 years, 4 months 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
« no previous file with comments | « components/offline_pages/background/request_coordinator.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <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"
(...skipping 11 matching lines...) Expand all
22 namespace { 22 namespace {
23 23
24 // Records the final request status UMA for an offlining request. This should 24 // Records the final request status UMA for an offlining request. This should
25 // only be called once per Offliner::LoadAndSave request. 25 // only be called once per Offliner::LoadAndSave request.
26 void RecordOfflinerResultUMA(Offliner::RequestStatus request_status) { 26 void RecordOfflinerResultUMA(Offliner::RequestStatus request_status) {
27 UMA_HISTOGRAM_ENUMERATION("OfflinePages.Background.OfflinerRequestStatus", 27 UMA_HISTOGRAM_ENUMERATION("OfflinePages.Background.OfflinerRequestStatus",
28 request_status, 28 request_status,
29 Offliner::RequestStatus::STATUS_COUNT); 29 Offliner::RequestStatus::STATUS_COUNT);
30 } 30 }
31 31
32 // TODO(dougarnett/petewil): Move to Policy object. Also consider lower minimum
33 // battery percentage once there is some processing time limits in place.
34 const Scheduler::TriggerConditions kUserRequestTriggerConditions(
35 false /* require_power_connected */,
36 50 /* minimum_battery_percentage */,
37 false /* require_unmetered_network */);
38
39 // Timeout is 2.5 minutes based on the size of Marshmallow doze mode 32 // Timeout is 2.5 minutes based on the size of Marshmallow doze mode
40 // maintenance window (3 minutes) 33 // maintenance window (3 minutes)
41 // TODO(petewil): Find the optimal timeout based on data for 2G connections and 34 // TODO(petewil): Find the optimal timeout based on data for 2G connections and
42 // common EM websites. crbug.com/625204 35 // common EM websites. crbug.com/625204
43 // TODO(petewil): Move this value into the policy object. 36 // TODO(petewil): Move this value into the policy object.
44 long OFFLINER_TIMEOUT_SECONDS = 150; 37 long OFFLINER_TIMEOUT_SECONDS = 150;
45 38
46 } // namespace 39 } // namespace
47 40
48 RequestCoordinator::RequestCoordinator(std::unique_ptr<OfflinerPolicy> policy, 41 RequestCoordinator::RequestCoordinator(std::unique_ptr<OfflinerPolicy> policy,
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 updated_request, 220 updated_request,
228 base::Bind(&RequestCoordinator::UpdateRequestCallback, 221 base::Bind(&RequestCoordinator::UpdateRequestCallback,
229 weak_ptr_factory_.GetWeakPtr())); 222 weak_ptr_factory_.GetWeakPtr()));
230 } 223 }
231 224
232 // TODO(petewil): Check time budget. Return to the scheduler if we are out. 225 // TODO(petewil): Check time budget. Return to the scheduler if we are out.
233 // Start another request if we have time. 226 // Start another request if we have time.
234 TryNextRequest(); 227 TryNextRequest();
235 } 228 }
236 229
237 const Scheduler::TriggerConditions& 230 const Scheduler::TriggerConditions
238 RequestCoordinator::GetTriggerConditionsForUserRequest() { 231 RequestCoordinator::GetTriggerConditionsForUserRequest() {
239 return kUserRequestTriggerConditions; 232 Scheduler::TriggerConditions trigger_conditions(
233 policy_->PowerRequiredForUserRequestedPage(),
234 policy_->BatteryPercentageRequiredForUserRequestedPage(),
235 policy_->UnmeteredNetworkRequiredForUserRequestedPage());
236 return trigger_conditions;
240 } 237 }
241 238
242 void RequestCoordinator::GetOffliner() { 239 void RequestCoordinator::GetOffliner() {
243 if (!offliner_) { 240 if (!offliner_) {
244 offliner_ = factory_->GetOffliner(policy_.get()); 241 offliner_ = factory_->GetOffliner(policy_.get());
245 } 242 }
246 } 243 }
247 244
248 } // namespace offline_pages 245 } // namespace offline_pages
OLDNEW
« no previous file with comments | « components/offline_pages/background/request_coordinator.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698