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 { |
| 9 const int kMaxRetries = 2; |
| 10 const int kBackgroundTimeBudgetSeconds = 170; |
| 11 const int kSinglePageTimeBudgetSeconds = 120; |
| 12 const int kMinimumBatteryPercentageForNonUserRequestOfflining = 50; |
| 13 } // namespace |
| 14 |
8 namespace offline_pages { | 15 namespace offline_pages { |
9 | 16 |
10 // Policy for the Background Offlining system. Some policy will belong to the | 17 // Policy for the Background Offlining system. Some policy will belong to the |
11 // RequestCoordinator, some to the RequestQueue, and some to the Offliner. | 18 // RequestCoordinator, some to the RequestQueue, and some to the Offliner. |
12 class OfflinerPolicy { | 19 class OfflinerPolicy { |
13 public: | 20 public: |
14 OfflinerPolicy(){}; | 21 OfflinerPolicy(){}; |
15 | 22 |
16 // TODO(petewil): Implement and add a .cc file. | 23 // TODO(petewil): Numbers here are chosen arbitrarily, do the proper studies |
17 // Eventually this should get data from a finch experiment. | 24 // to get good policy numbers. |
| 25 |
| 26 // TODO(petewil): Eventually this should get data from a finch experiment. |
| 27 |
| 28 // Returns true if we should prefer retrying already tried requests to |
| 29 // starting new requests to maximize utility of any cached partial results. |
| 30 bool ShouldPreferTriedRequests() { return true; } |
| 31 |
| 32 // Returns true if we should prefer older requests of equal number of tries. |
| 33 bool ShouldPreferEarlierRequests() { return true; } |
| 34 |
| 35 // Returns true if retry count is considered more important than recency in |
| 36 // picking which request to try next. |
| 37 bool RetryCountIsMoreImportantThanRecency() { return true; } |
| 38 |
| 39 // The max number of times we will retry a request. |
| 40 int GetMaxRetries() { return kMaxRetries; } |
| 41 |
| 42 // How many seconds to keep trying new pages for, before we give up, and |
| 43 // return to the scheduler for the time being. |
| 44 int GetBackgroundProcessingTimeBudgetSeconds() { |
| 45 return kBackgroundTimeBudgetSeconds; |
| 46 } |
| 47 |
| 48 // How long do we allow a page to load before giving up on it |
| 49 int GetSinglePageTimeBudgetInSeconds() { |
| 50 return kSinglePageTimeBudgetSeconds; |
| 51 } |
| 52 |
| 53 // How much battery must we have before fetching a page not explicitly |
| 54 // requested by the user? |
| 55 int GetMinimumBatteryPercentageForNonUserRequestOfflining() { |
| 56 return kMinimumBatteryPercentageForNonUserRequestOfflining; |
| 57 } |
18 }; | 58 }; |
19 } | 59 } |
20 | 60 |
21 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_OFFLINER_POLICY_H_ | 61 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_OFFLINER_POLICY_H_ |
OLD | NEW |