Chromium Code Reviews| Index: components/offline_pages/background/offliner_policy.h |
| diff --git a/components/offline_pages/background/offliner_policy.h b/components/offline_pages/background/offliner_policy.h |
| index 04e7f8443d184a4bc864550b7aeabf6044831b5c..d475e7f4e23ab316659c0bb74a4b71c431c78f9d 100644 |
| --- a/components/offline_pages/background/offliner_policy.h |
| +++ b/components/offline_pages/background/offliner_policy.h |
| @@ -5,6 +5,13 @@ |
| #ifndef COMPONENTS_OFFLINE_PAGES_BACKGROUND_OFFLINER_POLICY_H_ |
| #define COMPONENTS_OFFLINE_PAGES_BACKGROUND_OFFLINER_POLICY_H_ |
| +namespace { |
| +const int kMaxRetries = 2; |
| +const int kBackgroundTimeBudgetSeconds = 170; |
| +const int kSinglePageTimeBudgetSeconds = 120; |
| +const int kBatteryPercentageForSpeculativeOfflining = 50; |
| +} // namespace |
| + |
| namespace offline_pages { |
| // Policy for the Background Offlining system. Some policy will belong to the |
| @@ -13,8 +20,37 @@ class OfflinerPolicy { |
| public: |
| OfflinerPolicy(){}; |
| - // TODO(petewil): Implement and add a .cc file. |
| - // Eventually this should get data from a finch experiment. |
| + // TODO(petewil): Numbers here are chosen arbitrarily, do the proper studies |
| + // to get good policy numbers. |
| + |
| + // TODO(petewil): Eventually this should get data from a finch experiment. |
| + |
| + // Returns true if we should prefer retrying already tried requests to |
| + // starting new requests to maximize utility of any cached partial results. |
| + bool ShouldPreferTriedRequests() { return true; } |
| + |
| + // Returns true if we should prefer older requests of equal number of tries. |
| + bool ShouldPreferEarlierRequests() { return true; } |
| + |
| + // The max number of times we will retry a request. |
| + int GetMaxRetries() { return kMaxRetries; } |
| + |
| + // How many seconds to keep trying new pages for, before we give up, and |
| + // return to the scheduler for the time being. |
| + int GetBackgroundProcessingTimeBudgetSeconds() { |
| + return kBackgroundTimeBudgetSeconds; |
| + } |
| + |
| + // How long do we allow a page to load before giving up on it |
| + int GetSinglePageTimeBudgetInSeconds() { |
| + return kSinglePageTimeBudgetSeconds; |
| + } |
| + |
| + // How much battery must we have before fetching a page not explicitly |
| + // requested by the user? |
| + int GetMinimumBatteryLevelForNonUserRequestOfflining() { |
| + 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.
|
| + } |
| }; |
| } |