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

Side by Side Diff: components/offline_pages/background/offliner_policy.h

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 | « no previous file | components/offline_pages/background/request_coordinator.h » ('j') | 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 #ifndef COMPONENTS_OFFLINE_PAGES_BACKGROUND_OFFLINER_POLICY_H_ 5 #ifndef COMPONENTS_OFFLINE_PAGES_BACKGROUND_OFFLINER_POLICY_H_
6 #define COMPONENTS_OFFLINE_PAGES_BACKGROUND_OFFLINER_POLICY_H_ 6 #define COMPONENTS_OFFLINE_PAGES_BACKGROUND_OFFLINER_POLICY_H_
7 7
8 namespace { 8 namespace {
9 const int kMaxRetries = 2; 9 const int kMaxRetries = 2;
10 const int kBackgroundTimeBudgetSeconds = 170; 10 const int kBackgroundTimeBudgetSeconds = 170;
(...skipping 18 matching lines...) Expand all
29 bool ShouldPreferUntriedRequests() { return false; } 29 bool ShouldPreferUntriedRequests() { return false; }
30 30
31 // Returns true if we should prefer older requests of equal number of tries. 31 // Returns true if we should prefer older requests of equal number of tries.
32 bool ShouldPreferEarlierRequests() { return true; } 32 bool ShouldPreferEarlierRequests() { return true; }
33 33
34 // Returns true if retry count is considered more important than recency in 34 // Returns true if retry count is considered more important than recency in
35 // picking which request to try next. 35 // picking which request to try next.
36 bool RetryCountIsMoreImportantThanRecency() { return true; } 36 bool RetryCountIsMoreImportantThanRecency() { return true; }
37 37
38 // The max number of times we will retry a request. 38 // The max number of times we will retry a request.
39 int GetMaxRetries() { return kMaxRetries; } 39 int GetMaxRetries() const { return kMaxRetries; }
40
41 bool PowerRequiredForUserRequestedPage() const { return false; }
42
43 bool PowerRequiredForNonUserRequestedPage() const { return true; }
44
45 bool UnmeteredNetworkRequiredForUserRequestedPage() const { return false; }
46
47 bool UnmeteredNetworkRequiredForNonUserRequestedPage() const { return true; }
48
49 int BatteryPercentageRequiredForUserRequestedPage() const { return 50; }
50
51 // This is so low because we require the device to be plugged in and charging.
52 // If we decide to allow non-user requested pages when not plugged in, we
53 // should raise this somewhat higher.
54 int BatteryPercentageRequiredForNonUserRequestedPage() const { return 25; }
40 55
41 // How many seconds to keep trying new pages for, before we give up, and 56 // How many seconds to keep trying new pages for, before we give up, and
42 // return to the scheduler. 57 // return to the scheduler.
43 int GetBackgroundProcessingTimeBudgetSeconds() { 58 int GetBackgroundProcessingTimeBudgetSeconds() const {
44 return kBackgroundTimeBudgetSeconds; 59 return kBackgroundTimeBudgetSeconds;
45 } 60 }
46 61
47 // How long do we allow a page to load before giving up on it 62 // How long do we allow a page to load before giving up on it
48 int GetSinglePageTimeBudgetInSeconds() { 63 int GetSinglePageTimeBudgetInSeconds() const {
49 return kSinglePageTimeBudgetSeconds; 64 return kSinglePageTimeBudgetSeconds;
50 } 65 }
51 66
52 // How much battery must we have before fetching a page not explicitly 67 // How much battery must we have before fetching a page not explicitly
53 // requested by the user? 68 // requested by the user?
54 int GetMinimumBatteryPercentageForNonUserRequestOfflining() { 69 int GetMinimumBatteryPercentageForNonUserRequestOfflining() const {
55 return kMinimumBatteryPercentageForNonUserRequestOfflining; 70 return kMinimumBatteryPercentageForNonUserRequestOfflining;
56 } 71 }
57 }; 72 };
58 } 73 }
59 74
60 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_OFFLINER_POLICY_H_ 75 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_OFFLINER_POLICY_H_
OLDNEW
« no previous file with comments | « no previous file | components/offline_pages/background/request_coordinator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698