| 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 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_ |
| OLD | NEW |