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 { | |
| 9 const int kMaxRetries = 2; | |
| 10 const int kBackgroundTimeBudgetSeconds = 170; | |
| 11 const int kSinglePageTimeBudgetSeconds = 120; | |
| 12 const int kBatteryPercentageForSpeculativeOfflining = 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 // The max number of times we will retry a request. | |
| 36 int GetMaxRetries() { return kMaxRetries; } | |
| 37 | |
| 38 // How many seconds to keep trying new pages for, before we give up, and | |
| 39 // return to the scheduler for the time being. | |
| 40 int GetBackgroundProcessingTimeBudgetSeconds() { | |
| 41 return kBackgroundTimeBudgetSeconds; | |
| 42 } | |
| 43 | |
| 44 // How long do we allow a page to load before giving up on it | |
| 45 int GetSinglePageTimeBudgetInSeconds() { | |
| 46 return kSinglePageTimeBudgetSeconds; | |
| 47 } | |
| 48 | |
| 49 // How much battery must we have before fetching a page not explicitly | |
| 50 // requested by the user? | |
| 51 int GetMinimumBatteryLevelForNonUserRequestOfflining() { | |
| 52 return kBatteryPercentageForSpeculativeOfflining; | |
|
dougarnett
2016/07/19 00:20:44
please match constant name to newer method name
Pete Williamson
2016/07/19 19:48:08
Done.
| |
| 53 } | |
| 18 }; | 54 }; |
| 19 } | 55 } |
| 20 | 56 |
| 21 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_OFFLINER_POLICY_H_ | 57 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_OFFLINER_POLICY_H_ |
| OLD | NEW |