Chromium Code Reviews| 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 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 Loading... | |
| 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 if (user_requested) | |
| 69 return false; | |
| 70 return true; | |
| 71 } | |
| 69 | 72 |
| 70 bool PowerRequiredForNonUserRequestedPage() const { return true; } | 73 bool UnmeteredNetworkRequired(bool user_requested) const { |
| 74 if (user_requested) | |
| 75 return false; | |
| 76 return true; | |
| 77 } | |
| 71 | 78 |
| 72 bool UnmeteredNetworkRequiredForUserRequestedPage() const { return false; } | 79 int BatteryPercentageRequired(bool user_requested) const { |
| 80 if (user_requested) | |
| 81 return 0; | |
| 82 // This is so low because we require the device to be plugged in and | |
| 83 // charging. If we decide to allow non-user requested pages when not | |
| 84 // plugged in, we should raise this somewhat higher. | |
| 85 return 25; | |
| 86 } | |
| 73 | 87 |
| 74 bool UnmeteredNetworkRequiredForNonUserRequestedPage() const { return true; } | |
| 75 | |
| 76 int BatteryPercentageRequiredForUserRequestedPage() const { return 0; } | |
| 77 | |
| 78 // This is so low because we require the device to be plugged in and charging. | |
| 79 // If we decide to allow non-user requested pages when not plugged in, we | |
| 80 // should raise this somewhat higher. | |
| 81 int BatteryPercentageRequiredForNonUserRequestedPage() const { return 25; } | 88 int BatteryPercentageRequiredForNonUserRequestedPage() const { return 25; } |
|
dougarnett
2016/08/29 15:47:22
delete this one too?
Pete Williamson
2016/09/01 00:10:31
Done.
| |
| 82 | 89 |
| 83 // How many seconds to keep trying new pages for, before we give up, and | 90 // How many seconds to keep trying new pages for, before we give up, and |
| 84 // return to the scheduler. | 91 // return to the scheduler. |
| 85 int GetBackgroundProcessingTimeBudgetSeconds() const { | 92 int GetBackgroundProcessingTimeBudgetSeconds() const { |
| 86 return kBackgroundProcessingTimeBudgetSeconds; | 93 return kBackgroundProcessingTimeBudgetSeconds; |
| 87 } | 94 } |
| 88 | 95 |
| 89 // How long do we allow a page to load before giving up on it | 96 // How long do we allow a page to load before giving up on it |
| 90 int GetSinglePageTimeLimitInSeconds() const { | 97 int GetSinglePageTimeLimitInSeconds() const { |
| 91 return kSinglePageTimeLimitSeconds; | 98 return kSinglePageTimeLimitSeconds; |
| 92 } | 99 } |
| 93 | 100 |
| 94 // How long we allow requests to remain in the system before giving up. | 101 // How long we allow requests to remain in the system before giving up. |
| 95 int GetRequestExpirationTimeInSeconds() const { | 102 int GetRequestExpirationTimeInSeconds() const { |
| 96 return kRequestExpirationTimeInSeconds; | 103 return kRequestExpirationTimeInSeconds; |
| 97 } | 104 } |
| 98 | 105 |
| 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: | 106 private: |
| 106 bool prefer_untried_requests_; | 107 bool prefer_untried_requests_; |
| 107 bool prefer_earlier_requests_; | 108 bool prefer_earlier_requests_; |
| 108 bool retry_count_is_more_important_than_recency_; | 109 bool retry_count_is_more_important_than_recency_; |
| 109 int max_started_tries_; | 110 int max_started_tries_; |
| 110 int max_completed_tries_; | 111 int max_completed_tries_; |
| 111 }; | 112 }; |
| 112 } | 113 } |
| 113 | 114 |
| 114 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_OFFLINER_POLICY_H_ | 115 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_OFFLINER_POLICY_H_ |
| OLD | NEW |