Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(64)

Side by Side Diff: components/offline_pages/background/offliner_policy.h

Issue 2113383002: More detailed implementation of the RequestPicker (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Try a different way of checking policy to separate policy from checking. Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 lesser tried requests.
29 bool ShouldPreferUntriedRequests() { return false; }
30
31 // Returns true if we should prefer older requests of equal number of tries.
32 bool ShouldPreferEarlierRequests() { return true; }
33
34 // Returns true if retry count is considered more important than recency in
35 // picking which request to try next.
36 bool RetryCountIsMoreImportantThanRecency() { return true; }
37
38 // The max number of times we will retry a request.
39 int GetMaxRetries() { return kMaxRetries; }
40
41 // How many seconds to keep trying new pages for, before we give up, and
42 // return to the scheduler.
43 int GetBackgroundProcessingTimeBudgetSeconds() {
44 return kBackgroundTimeBudgetSeconds;
45 }
46
47 // How long do we allow a page to load before giving up on it
48 int GetSinglePageTimeBudgetInSeconds() {
49 return kSinglePageTimeBudgetSeconds;
50 }
51
52 // How much battery must we have before fetching a page not explicitly
53 // requested by the user?
54 int GetMinimumBatteryPercentageForNonUserRequestOfflining() {
55 return kMinimumBatteryPercentageForNonUserRequestOfflining;
56 }
18 }; 57 };
19 } 58 }
20 59
21 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_OFFLINER_POLICY_H_ 60 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_OFFLINER_POLICY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698