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

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

Issue 2425873003: [Offline Pages] Add evaluation test support in RequestCoordinator. (Closed)
Patch Set: Created 4 years, 2 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 { 8 namespace {
9 const int kMaxStartedTries = 4; 9 const int kMaxStartedTries = 4;
10 const int kMaxCompletedTries = 1; 10 const int kMaxCompletedTries = 1;
11 const int kBackgroundProcessingTimeBudgetSeconds = 170; 11 const int kBackgroundProcessingTimeBudgetSeconds = 170;
12 const int kSinglePageTimeLimitWhenBackgroundScheduledSeconds = 120; 12 const int kSinglePageTimeLimitWhenBackgroundScheduledSeconds = 120;
13 const int kSinglePageTimeLimitForImmediateLoadSeconds = 300; 13 const int kSinglePageTimeLimitForImmediateLoadSeconds = 300;
14 const int kRequestExpirationTimeInSeconds = 60 * 60 * 24 * 7; 14 const int kRequestExpirationTimeInSeconds = 60 * 60 * 24 * 7;
15 } // namespace 15 } // namespace
16 16
17 namespace offline_pages { 17 namespace offline_pages {
18 18
19 // Policy for the Background Offlining system. Some policy will belong to the 19 // Policy for the Background Offlining system. Some policy will belong to the
20 // RequestCoordinator, some to the RequestQueue, and some to the Offliner. 20 // RequestCoordinator, some to the RequestQueue, and some to the Offliner.
21 class OfflinerPolicy { 21 class OfflinerPolicy {
22 public: 22 public:
23 OfflinerPolicy() 23 OfflinerPolicy()
24 : prefer_untried_requests_(false), 24 : OfflinerPolicy(false,
25 prefer_earlier_requests_(true), 25 true,
dougarnett 2016/10/18 17:26:32 Hard to read what these bools apply to. I would ty
Pete Williamson 2016/10/18 19:24:32 boolean arguments are always hard to understand at
romax 2016/10/18 20:31:51 I forgot why I used this but seems like simply add
26 retry_count_is_more_important_than_recency_(false), 26 false,
27 max_started_tries_(kMaxStartedTries), 27 kMaxStartedTries,
28 max_completed_tries_(kMaxCompletedTries) {} 28 kMaxCompletedTries,
29 kBackgroundProcessingTimeBudgetSeconds) {}
dougarnett 2016/10/18 17:26:32 We might consider renaming to identify this consta
romax 2016/10/18 20:31:51 Done.
29 30
30 // Constructor for unit tests. 31 // Constructor for unit tests.
31 OfflinerPolicy(bool prefer_untried, 32 OfflinerPolicy(bool prefer_untried,
32 bool prefer_earlier, 33 bool prefer_earlier,
33 bool prefer_retry_count, 34 bool prefer_retry_count,
34 int max_started_tries, 35 int max_started_tries,
35 int max_completed_tries) 36 int max_completed_tries)
37 : OfflinerPolicy(prefer_untried,
38 prefer_earlier,
39 prefer_retry_count,
40 max_started_tries,
41 max_completed_tries,
42 kBackgroundProcessingTimeBudgetSeconds) {}
43
44 OfflinerPolicy(bool prefer_untried,
45 bool prefer_earlier,
46 bool prefer_retry_count,
47 int max_started_tries,
48 int max_completed_tries,
49 int background_processing_time_budget)
36 : prefer_untried_requests_(prefer_untried), 50 : prefer_untried_requests_(prefer_untried),
37 prefer_earlier_requests_(prefer_earlier), 51 prefer_earlier_requests_(prefer_earlier),
38 retry_count_is_more_important_than_recency_(prefer_retry_count), 52 retry_count_is_more_important_than_recency_(prefer_retry_count),
39 max_started_tries_(max_started_tries), 53 max_started_tries_(max_started_tries),
40 max_completed_tries_(max_completed_tries) {} 54 max_completed_tries_(max_completed_tries),
55 background_processing_time_budget_(background_processing_time_budget) {}
41 56
42 // TODO(petewil): Numbers here are chosen arbitrarily, do the proper studies 57 // TODO(petewil): Numbers here are chosen arbitrarily, do the proper studies
43 // to get good policy numbers. Eventually this should get data from a finch 58 // to get good policy numbers. Eventually this should get data from a finch
44 // experiment. 59 // experiment.
45 60
46 // Returns true if we should prefer retrying lesser tried requests. 61 // Returns true if we should prefer retrying lesser tried requests.
47 bool ShouldPreferUntriedRequests() const { return prefer_untried_requests_; } 62 bool ShouldPreferUntriedRequests() const { return prefer_untried_requests_; }
48 63
49 // Returns true if we should prefer older requests of equal number of tries. 64 // Returns true if we should prefer older requests of equal number of tries.
50 bool ShouldPreferEarlierRequests() const { return prefer_earlier_requests_; } 65 bool ShouldPreferEarlierRequests() const { return prefer_earlier_requests_; }
(...skipping 26 matching lines...) Expand all
77 return 0; 92 return 0;
78 // This is so low because we require the device to be plugged in and 93 // This is so low because we require the device to be plugged in and
79 // charging. If we decide to allow non-user requested pages when not 94 // charging. If we decide to allow non-user requested pages when not
80 // plugged in, we should raise this somewhat higher. 95 // plugged in, we should raise this somewhat higher.
81 return 25; 96 return 25;
82 } 97 }
83 98
84 // How many seconds to keep trying new pages for, before we give up, and 99 // How many seconds to keep trying new pages for, before we give up, and
85 // return to the scheduler. 100 // return to the scheduler.
86 int GetBackgroundProcessingTimeBudgetSeconds() const { 101 int GetBackgroundProcessingTimeBudgetSeconds() const {
87 return kBackgroundProcessingTimeBudgetSeconds; 102 return background_processing_time_budget_;
88 } 103 }
89 104
90 // How long do we allow a page to load before giving up on it when 105 // How long do we allow a page to load before giving up on it when
91 // background loading was scheduled. 106 // background loading was scheduled.
92 int GetSinglePageTimeLimitWhenBackgroundScheduledInSeconds() const { 107 int GetSinglePageTimeLimitWhenBackgroundScheduledInSeconds() const {
93 return kSinglePageTimeLimitWhenBackgroundScheduledSeconds; 108 return kSinglePageTimeLimitWhenBackgroundScheduledSeconds;
94 } 109 }
95 110
96 // How long do we allow a page to load before giving up on it when 111 // How long do we allow a page to load before giving up on it when
97 // immediately background loading. 112 // immediately background loading.
98 int GetSinglePageTimeLimitForImmediateLoadInSeconds() const { 113 int GetSinglePageTimeLimitForImmediateLoadInSeconds() const {
99 return kSinglePageTimeLimitForImmediateLoadSeconds; 114 return kSinglePageTimeLimitForImmediateLoadSeconds;
100 } 115 }
101 116
102 // How long we allow requests to remain in the system before giving up. 117 // How long we allow requests to remain in the system before giving up.
103 int GetRequestExpirationTimeInSeconds() const { 118 int GetRequestExpirationTimeInSeconds() const {
104 return kRequestExpirationTimeInSeconds; 119 return kRequestExpirationTimeInSeconds;
105 } 120 }
106 121
107 private: 122 private:
108 bool prefer_untried_requests_; 123 bool prefer_untried_requests_;
109 bool prefer_earlier_requests_; 124 bool prefer_earlier_requests_;
110 bool retry_count_is_more_important_than_recency_; 125 bool retry_count_is_more_important_than_recency_;
111 int max_started_tries_; 126 int max_started_tries_;
112 int max_completed_tries_; 127 int max_completed_tries_;
128 int background_processing_time_budget_;
113 }; 129 };
114 } // namespace offline_pages 130 } // namespace offline_pages
115 131
116 132
117 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_OFFLINER_POLICY_H_ 133 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_OFFLINER_POLICY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698