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 #ifndef COMPONENTS_OFFLINE_PAGES_BACKGROUND_OFFLINER_POLICY_H_ | 5 #ifndef COMPONENTS_OFFLINE_PAGES_CORE_BACKGROUND_OFFLINER_POLICY_H_ |
6 #define COMPONENTS_OFFLINE_PAGES_BACKGROUND_OFFLINER_POLICY_H_ | 6 #define COMPONENTS_OFFLINE_PAGES_CORE_BACKGROUND_OFFLINER_POLICY_H_ |
7 | 7 |
8 namespace { | 8 namespace { |
9 // The max number of started tries is to guard against pages that make the | 9 // The max number of started tries is to guard against pages that make the |
10 // prerenderer crash. It should be greater than or equal to the max number of | 10 // prerenderer crash. It should be greater than or equal to the max number of |
11 // completed tries. | 11 // completed tries. |
12 const int kMaxStartedTries = 5; | 12 const int kMaxStartedTries = 5; |
13 // The number of max completed tries is based on Gin2G-poor testing showing that | 13 // The number of max completed tries is based on Gin2G-poor testing showing that |
14 // we often need about 4 tries with a 2 minute window, or 3 retries with a 3 | 14 // we often need about 4 tries with a 2 minute window, or 3 retries with a 3 |
15 // minute window. Also, we count one try now for foreground/disabled requests. | 15 // minute window. Also, we count one try now for foreground/disabled requests. |
16 const int kMaxCompletedTries = 3; | 16 const int kMaxCompletedTries = 3; |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 | 82 |
83 // The max number of times we will start a request. Not all started attempts | 83 // The max number of times we will start a request. Not all started attempts |
84 // will complete. This may be caused by prerenderer issues or chromium being | 84 // will complete. This may be caused by prerenderer issues or chromium being |
85 // swapped out of memory. | 85 // swapped out of memory. |
86 int GetMaxStartedTries() const { return max_started_tries_; } | 86 int GetMaxStartedTries() const { return max_started_tries_; } |
87 | 87 |
88 // The max number of times we will retry a request when the attempt | 88 // The max number of times we will retry a request when the attempt |
89 // completed, but failed. | 89 // completed, but failed. |
90 int GetMaxCompletedTries() const { return max_completed_tries_; } | 90 int GetMaxCompletedTries() const { return max_completed_tries_; } |
91 | 91 |
92 bool PowerRequired(bool user_requested) const { | 92 bool PowerRequired(bool user_requested) const { return (!user_requested); } |
93 return (!user_requested); | |
94 } | |
95 | 93 |
96 bool UnmeteredNetworkRequired(bool user_requested) const { | 94 bool UnmeteredNetworkRequired(bool user_requested) const { |
97 return !(user_requested); | 95 return !(user_requested); |
98 } | 96 } |
99 | 97 |
100 int BatteryPercentageRequired(bool user_requested) const { | 98 int BatteryPercentageRequired(bool user_requested) const { |
101 if (user_requested) | 99 if (user_requested) |
102 return 0; | 100 return 0; |
103 // This is so low because we require the device to be plugged in and | 101 // This is so low because we require the device to be plugged in and |
104 // charging. If we decide to allow non-user requested pages when not | 102 // charging. If we decide to allow non-user requested pages when not |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 private: | 138 private: |
141 bool prefer_untried_requests_; | 139 bool prefer_untried_requests_; |
142 bool prefer_earlier_requests_; | 140 bool prefer_earlier_requests_; |
143 bool retry_count_is_more_important_than_recency_; | 141 bool retry_count_is_more_important_than_recency_; |
144 int max_started_tries_; | 142 int max_started_tries_; |
145 int max_completed_tries_; | 143 int max_completed_tries_; |
146 int background_scheduled_processing_time_budget_; | 144 int background_scheduled_processing_time_budget_; |
147 }; | 145 }; |
148 } // namespace offline_pages | 146 } // namespace offline_pages |
149 | 147 |
150 | 148 #endif // COMPONENTS_OFFLINE_PAGES_CORE_BACKGROUND_OFFLINER_POLICY_H_ |
151 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_OFFLINER_POLICY_H_ | |
OLD | NEW |