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

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

Issue 2269173003: Adjust scheduling for non-user requested items (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: FGorski CR feedback Created 4 years, 3 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 kMaxStartedTries = 5; 9 const int kMaxStartedTries = 5;
10 const int kMaxCompletedTries = 1; 10 const int kMaxCompletedTries = 1;
11 const int kBackgroundProcessingTimeBudgetSeconds = 170; 11 const int kBackgroundProcessingTimeBudgetSeconds = 170;
12 const int kSinglePageTimeLimitSeconds = 120; 12 const int kSinglePageTimeLimitSeconds = 120;
13 const int kMinimumBatteryPercentageForNonUserRequestOfflining = 50;
14 const int kRequestExpirationTimeInSeconds = 60 * 60 * 24 * 7; 13 const int kRequestExpirationTimeInSeconds = 60 * 60 * 24 * 7;
15 } // namespace 14 } // namespace
16 15
17 namespace offline_pages { 16 namespace offline_pages {
18 17
19 // Policy for the Background Offlining system. Some policy will belong to the 18 // Policy for the Background Offlining system. Some policy will belong to the
20 // RequestCoordinator, some to the RequestQueue, and some to the Offliner. 19 // RequestCoordinator, some to the RequestQueue, and some to the Offliner.
21 class OfflinerPolicy { 20 class OfflinerPolicy {
22 public: 21 public:
23 OfflinerPolicy() 22 OfflinerPolicy()
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 57
59 // The max number of times we will start a request. Not all started attempts 58 // The max number of times we will start a request. Not all started attempts
60 // will complete. This may be caused by prerenderer issues or chromium being 59 // will complete. This may be caused by prerenderer issues or chromium being
61 // swapped out of memory. 60 // swapped out of memory.
62 int GetMaxStartedTries() const { return max_started_tries_; } 61 int GetMaxStartedTries() const { return max_started_tries_; }
63 62
64 // The max number of times we will retry a request when the attempt 63 // The max number of times we will retry a request when the attempt
65 // completed, but failed. 64 // completed, but failed.
66 int GetMaxCompletedTries() const { return max_completed_tries_; } 65 int GetMaxCompletedTries() const { return max_completed_tries_; }
67 66
68 bool PowerRequiredForUserRequestedPage() const { return false; } 67 bool PowerRequired(bool user_requested) const {
68 return (!user_requested);
69 }
69 70
70 bool PowerRequiredForNonUserRequestedPage() const { return true; } 71 bool UnmeteredNetworkRequired(bool user_requested) const {
72 return !(user_requested);
73 }
71 74
72 bool UnmeteredNetworkRequiredForUserRequestedPage() const { return false; } 75 int BatteryPercentageRequired(bool user_requested) const {
73 76 if (user_requested)
74 bool UnmeteredNetworkRequiredForNonUserRequestedPage() const { return true; } 77 return 0;
75 78 // This is so low because we require the device to be plugged in and
76 int BatteryPercentageRequiredForUserRequestedPage() const { return 0; } 79 // charging. If we decide to allow non-user requested pages when not
77 80 // plugged in, we should raise this somewhat higher.
78 // This is so low because we require the device to be plugged in and charging. 81 return 25;
79 // If we decide to allow non-user requested pages when not plugged in, we 82 }
80 // should raise this somewhat higher.
81 int BatteryPercentageRequiredForNonUserRequestedPage() const { return 25; }
82 83
83 // How many seconds to keep trying new pages for, before we give up, and 84 // How many seconds to keep trying new pages for, before we give up, and
84 // return to the scheduler. 85 // return to the scheduler.
85 int GetBackgroundProcessingTimeBudgetSeconds() const { 86 int GetBackgroundProcessingTimeBudgetSeconds() const {
86 return kBackgroundProcessingTimeBudgetSeconds; 87 return kBackgroundProcessingTimeBudgetSeconds;
87 } 88 }
88 89
89 // How long do we allow a page to load before giving up on it 90 // How long do we allow a page to load before giving up on it
90 int GetSinglePageTimeLimitInSeconds() const { 91 int GetSinglePageTimeLimitInSeconds() const {
91 return kSinglePageTimeLimitSeconds; 92 return kSinglePageTimeLimitSeconds;
92 } 93 }
93 94
94 // How long we allow requests to remain in the system before giving up. 95 // How long we allow requests to remain in the system before giving up.
95 int GetRequestExpirationTimeInSeconds() const { 96 int GetRequestExpirationTimeInSeconds() const {
96 return kRequestExpirationTimeInSeconds; 97 return kRequestExpirationTimeInSeconds;
97 } 98 }
98 99
99 // How much battery must we have before fetching a page not explicitly
100 // requested by the user?
101 int GetMinimumBatteryPercentageForNonUserRequestOfflining() const {
102 return kMinimumBatteryPercentageForNonUserRequestOfflining;
103 }
104
105 private: 100 private:
106 bool prefer_untried_requests_; 101 bool prefer_untried_requests_;
107 bool prefer_earlier_requests_; 102 bool prefer_earlier_requests_;
108 bool retry_count_is_more_important_than_recency_; 103 bool retry_count_is_more_important_than_recency_;
109 int max_started_tries_; 104 int max_started_tries_;
110 int max_completed_tries_; 105 int max_completed_tries_;
111 }; 106 };
112 } 107 }
113 108
114 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_OFFLINER_POLICY_H_ 109 #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