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_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; |
11 const int kSinglePageTimeBudgetSeconds = 120; | 11 const int kSinglePageTimeBudgetSeconds = 120; |
12 const int kMinimumBatteryPercentageForNonUserRequestOfflining = 50; | 12 const int kMinimumBatteryPercentageForNonUserRequestOfflining = 50; |
| 13 const int kRequestExpirationTimeInSeconds = 60 * 60 * 24 * 7; |
13 } // namespace | 14 } // namespace |
14 | 15 |
15 namespace offline_pages { | 16 namespace offline_pages { |
16 | 17 |
17 // 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 |
18 // RequestCoordinator, some to the RequestQueue, and some to the Offliner. | 19 // RequestCoordinator, some to the RequestQueue, and some to the Offliner. |
19 class OfflinerPolicy { | 20 class OfflinerPolicy { |
20 public: | 21 public: |
21 OfflinerPolicy() | 22 OfflinerPolicy() |
22 : prefer_untried_requests_(false), | 23 : prefer_untried_requests_(false), |
(...skipping 28 matching lines...) Expand all Loading... |
51 int GetMaxRetries() const { return kMaxRetries; } | 52 int GetMaxRetries() const { return kMaxRetries; } |
52 | 53 |
53 bool PowerRequiredForUserRequestedPage() const { return false; } | 54 bool PowerRequiredForUserRequestedPage() const { return false; } |
54 | 55 |
55 bool PowerRequiredForNonUserRequestedPage() const { return true; } | 56 bool PowerRequiredForNonUserRequestedPage() const { return true; } |
56 | 57 |
57 bool UnmeteredNetworkRequiredForUserRequestedPage() const { return false; } | 58 bool UnmeteredNetworkRequiredForUserRequestedPage() const { return false; } |
58 | 59 |
59 bool UnmeteredNetworkRequiredForNonUserRequestedPage() const { return true; } | 60 bool UnmeteredNetworkRequiredForNonUserRequestedPage() const { return true; } |
60 | 61 |
61 int BatteryPercentageRequiredForUserRequestedPage() const { return 50; } | 62 int BatteryPercentageRequiredForUserRequestedPage() const { return 0; } |
62 | 63 |
63 // This is so low because we require the device to be plugged in and charging. | 64 // This is so low because we require the device to be plugged in and charging. |
64 // If we decide to allow non-user requested pages when not plugged in, we | 65 // If we decide to allow non-user requested pages when not plugged in, we |
65 // should raise this somewhat higher. | 66 // should raise this somewhat higher. |
66 int BatteryPercentageRequiredForNonUserRequestedPage() const { return 25; } | 67 int BatteryPercentageRequiredForNonUserRequestedPage() const { return 25; } |
67 | 68 |
68 // How many seconds to keep trying new pages for, before we give up, and | 69 // How many seconds to keep trying new pages for, before we give up, and |
69 // return to the scheduler. | 70 // return to the scheduler. |
70 int GetBackgroundProcessingTimeBudgetSeconds() const { | 71 int GetBackgroundProcessingTimeBudgetSeconds() const { |
71 return kBackgroundTimeBudgetSeconds; | 72 return kBackgroundTimeBudgetSeconds; |
72 } | 73 } |
73 | 74 |
74 // How long do we allow a page to load before giving up on it | 75 // How long do we allow a page to load before giving up on it |
75 int GetSinglePageTimeBudgetInSeconds() const { | 76 int GetSinglePageTimeBudgetInSeconds() const { |
76 return kSinglePageTimeBudgetSeconds; | 77 return kSinglePageTimeBudgetSeconds; |
77 } | 78 } |
78 | 79 |
| 80 // How long we allow requests to remain in the system before giving up. |
| 81 int GetRequestExpirationTimeInSeconds() const { |
| 82 return kRequestExpirationTimeInSeconds; |
| 83 } |
| 84 |
79 // How much battery must we have before fetching a page not explicitly | 85 // How much battery must we have before fetching a page not explicitly |
80 // requested by the user? | 86 // requested by the user? |
81 int GetMinimumBatteryPercentageForNonUserRequestOfflining() const { | 87 int GetMinimumBatteryPercentageForNonUserRequestOfflining() const { |
82 return kMinimumBatteryPercentageForNonUserRequestOfflining; | 88 return kMinimumBatteryPercentageForNonUserRequestOfflining; |
83 } | 89 } |
84 | 90 |
85 private: | 91 private: |
86 bool prefer_untried_requests_; | 92 bool prefer_untried_requests_; |
87 bool prefer_earlier_requests_; | 93 bool prefer_earlier_requests_; |
88 bool retry_count_is_more_important_than_recency_; | 94 bool retry_count_is_more_important_than_recency_; |
89 }; | 95 }; |
90 } | 96 } |
91 | 97 |
92 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_OFFLINER_POLICY_H_ | 98 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_OFFLINER_POLICY_H_ |
OLD | NEW |