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

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

Issue 2425873003: [Offline Pages] Add evaluation test support in RequestCoordinator. (Closed)
Patch Set: Addressed comments. 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 kDefaultBackgroundProcessingTimeBudgetSeconds = 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 : prefer_untried_requests_(false),
25 prefer_earlier_requests_(true), 25 prefer_earlier_requests_(true),
26 retry_count_is_more_important_than_recency_(false), 26 retry_count_is_more_important_than_recency_(false),
27 max_started_tries_(kMaxStartedTries), 27 max_started_tries_(kMaxStartedTries),
28 max_completed_tries_(kMaxCompletedTries) {} 28 max_completed_tries_(kMaxCompletedTries),
29 background_processing_time_budget_(
30 kDefaultBackgroundProcessingTimeBudgetSeconds) {}
29 31
30 // Constructor for unit tests. 32 // Constructor for unit tests.
31 OfflinerPolicy(bool prefer_untried, 33 OfflinerPolicy(bool prefer_untried,
32 bool prefer_earlier, 34 bool prefer_earlier,
33 bool prefer_retry_count, 35 bool prefer_retry_count,
34 int max_started_tries, 36 int max_started_tries,
35 int max_completed_tries) 37 int max_completed_tries,
38 int background_processing_time_budget)
36 : prefer_untried_requests_(prefer_untried), 39 : prefer_untried_requests_(prefer_untried),
37 prefer_earlier_requests_(prefer_earlier), 40 prefer_earlier_requests_(prefer_earlier),
38 retry_count_is_more_important_than_recency_(prefer_retry_count), 41 retry_count_is_more_important_than_recency_(prefer_retry_count),
39 max_started_tries_(max_started_tries), 42 max_started_tries_(max_started_tries),
40 max_completed_tries_(max_completed_tries) {} 43 max_completed_tries_(max_completed_tries),
44 background_processing_time_budget_(background_processing_time_budget) {}
41 45
42 // TODO(petewil): Numbers here are chosen arbitrarily, do the proper studies 46 // 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 47 // to get good policy numbers. Eventually this should get data from a finch
44 // experiment. 48 // experiment.
45 49
46 // Returns true if we should prefer retrying lesser tried requests. 50 // Returns true if we should prefer retrying lesser tried requests.
47 bool ShouldPreferUntriedRequests() const { return prefer_untried_requests_; } 51 bool ShouldPreferUntriedRequests() const { return prefer_untried_requests_; }
48 52
49 // Returns true if we should prefer older requests of equal number of tries. 53 // Returns true if we should prefer older requests of equal number of tries.
50 bool ShouldPreferEarlierRequests() const { return prefer_earlier_requests_; } 54 bool ShouldPreferEarlierRequests() const { return prefer_earlier_requests_; }
(...skipping 26 matching lines...) Expand all
77 return 0; 81 return 0;
78 // This is so low because we require the device to be plugged in and 82 // 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 83 // charging. If we decide to allow non-user requested pages when not
80 // plugged in, we should raise this somewhat higher. 84 // plugged in, we should raise this somewhat higher.
81 return 25; 85 return 25;
82 } 86 }
83 87
84 // How many seconds to keep trying new pages for, before we give up, and 88 // How many seconds to keep trying new pages for, before we give up, and
85 // return to the scheduler. 89 // return to the scheduler.
86 int GetBackgroundProcessingTimeBudgetSeconds() const { 90 int GetBackgroundProcessingTimeBudgetSeconds() const {
87 return kBackgroundProcessingTimeBudgetSeconds; 91 return background_processing_time_budget_;
88 } 92 }
89 93
90 // How long do we allow a page to load before giving up on it when 94 // How long do we allow a page to load before giving up on it when
91 // background loading was scheduled. 95 // background loading was scheduled.
92 int GetSinglePageTimeLimitWhenBackgroundScheduledInSeconds() const { 96 int GetSinglePageTimeLimitWhenBackgroundScheduledInSeconds() const {
93 return kSinglePageTimeLimitWhenBackgroundScheduledSeconds; 97 return kSinglePageTimeLimitWhenBackgroundScheduledSeconds;
94 } 98 }
95 99
96 // How long do we allow a page to load before giving up on it when 100 // How long do we allow a page to load before giving up on it when
97 // immediately background loading. 101 // immediately background loading.
98 int GetSinglePageTimeLimitForImmediateLoadInSeconds() const { 102 int GetSinglePageTimeLimitForImmediateLoadInSeconds() const {
99 return kSinglePageTimeLimitForImmediateLoadSeconds; 103 return kSinglePageTimeLimitForImmediateLoadSeconds;
100 } 104 }
101 105
102 // How long we allow requests to remain in the system before giving up. 106 // How long we allow requests to remain in the system before giving up.
103 int GetRequestExpirationTimeInSeconds() const { 107 int GetRequestExpirationTimeInSeconds() const {
104 return kRequestExpirationTimeInSeconds; 108 return kRequestExpirationTimeInSeconds;
105 } 109 }
106 110
107 private: 111 private:
108 bool prefer_untried_requests_; 112 bool prefer_untried_requests_;
109 bool prefer_earlier_requests_; 113 bool prefer_earlier_requests_;
110 bool retry_count_is_more_important_than_recency_; 114 bool retry_count_is_more_important_than_recency_;
111 int max_started_tries_; 115 int max_started_tries_;
112 int max_completed_tries_; 116 int max_completed_tries_;
117 int background_processing_time_budget_;
113 }; 118 };
114 } // namespace offline_pages 119 } // namespace offline_pages
115 120
116 121
117 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_OFFLINER_POLICY_H_ 122 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_OFFLINER_POLICY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698