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

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

Issue 2191733004: [Offline Pages] Configure for no retries (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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
« no previous file with comments | « no previous file | components/offline_pages/background/request_coordinator.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 kMaxRetries = 2; 9 const int kMaxTries = 1;
10 const int kBackgroundProcessingTimeBudgetSeconds = 170; 10 const int kBackgroundProcessingTimeBudgetSeconds = 170;
11 const int kSinglePageTimeLimitSeconds = 120; 11 const int kSinglePageTimeLimitSeconds = 120;
12 const int kMinimumBatteryPercentageForNonUserRequestOfflining = 50; 12 const int kMinimumBatteryPercentageForNonUserRequestOfflining = 50;
13 const int kRequestExpirationTimeInSeconds = 60 * 60 * 24 * 7; 13 const int kRequestExpirationTimeInSeconds = 60 * 60 * 24 * 7;
14 } // namespace 14 } // namespace
15 15
16 namespace offline_pages { 16 namespace offline_pages {
17 17
18 // Policy for the Background Offlining system. Some policy will belong to the 18 // Policy for the Background Offlining system. Some policy will belong to the
19 // RequestCoordinator, some to the RequestQueue, and some to the Offliner. 19 // RequestCoordinator, some to the RequestQueue, and some to the Offliner.
20 class OfflinerPolicy { 20 class OfflinerPolicy {
21 public: 21 public:
22 OfflinerPolicy() 22 OfflinerPolicy()
23 : prefer_untried_requests_(false), 23 : prefer_untried_requests_(false),
24 prefer_earlier_requests_(true), 24 prefer_earlier_requests_(true),
25 retry_count_is_more_important_than_recency_(true) {} 25 retry_count_is_more_important_than_recency_(false) {}
26 26
27 OfflinerPolicy(bool prefer_untried, 27 OfflinerPolicy(bool prefer_untried,
28 bool prefer_earlier, 28 bool prefer_earlier,
29 bool prefer_retry_count) 29 bool prefer_retry_count)
30 : prefer_untried_requests_(prefer_untried), 30 : prefer_untried_requests_(prefer_untried),
31 prefer_earlier_requests_(prefer_earlier), 31 prefer_earlier_requests_(prefer_earlier),
32 retry_count_is_more_important_than_recency_(prefer_retry_count) {} 32 retry_count_is_more_important_than_recency_(prefer_retry_count) {}
33 33
34 // TODO(petewil): Numbers here are chosen arbitrarily, do the proper studies 34 // TODO(petewil): Numbers here are chosen arbitrarily, do the proper studies
35 // to get good policy numbers. 35 // to get good policy numbers.
36 36
37 // TODO(petewil): Eventually this should get data from a finch experiment. 37 // TODO(petewil): Eventually this should get data from a finch experiment.
38 38
39 // Returns true if we should prefer retrying lesser tried requests. 39 // Returns true if we should prefer retrying lesser tried requests.
40 bool ShouldPreferUntriedRequests() const { return prefer_untried_requests_; } 40 bool ShouldPreferUntriedRequests() const { return prefer_untried_requests_; }
41 41
42 // Returns true if we should prefer older requests of equal number of tries. 42 // Returns true if we should prefer older requests of equal number of tries.
43 bool ShouldPreferEarlierRequests() const { return prefer_earlier_requests_; } 43 bool ShouldPreferEarlierRequests() const { return prefer_earlier_requests_; }
44 44
45 // Returns true if retry count is considered more important than recency in 45 // Returns true if retry count is considered more important than recency in
46 // picking which request to try next. 46 // picking which request to try next.
47 bool RetryCountIsMoreImportantThanRecency() const { 47 bool RetryCountIsMoreImportantThanRecency() const {
48 return retry_count_is_more_important_than_recency_; 48 return retry_count_is_more_important_than_recency_;
49 } 49 }
50 50
51 // The max number of times we will retry a request. 51 // The max number of times we will retry a request.
52 int GetMaxRetries() const { return kMaxRetries; } 52 int GetMaxTries() const { return kMaxTries; }
53 53
54 bool PowerRequiredForUserRequestedPage() const { return false; } 54 bool PowerRequiredForUserRequestedPage() const { return false; }
55 55
56 bool PowerRequiredForNonUserRequestedPage() const { return true; } 56 bool PowerRequiredForNonUserRequestedPage() const { return true; }
57 57
58 bool UnmeteredNetworkRequiredForUserRequestedPage() const { return false; } 58 bool UnmeteredNetworkRequiredForUserRequestedPage() const { return false; }
59 59
60 bool UnmeteredNetworkRequiredForNonUserRequestedPage() const { return true; } 60 bool UnmeteredNetworkRequiredForNonUserRequestedPage() const { return true; }
61 61
62 int BatteryPercentageRequiredForUserRequestedPage() const { return 0; } 62 int BatteryPercentageRequiredForUserRequestedPage() const { return 0; }
(...skipping 26 matching lines...) Expand all
89 } 89 }
90 90
91 private: 91 private:
92 bool prefer_untried_requests_; 92 bool prefer_untried_requests_;
93 bool prefer_earlier_requests_; 93 bool prefer_earlier_requests_;
94 bool retry_count_is_more_important_than_recency_; 94 bool retry_count_is_more_important_than_recency_;
95 }; 95 };
96 } 96 }
97 97
98 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_OFFLINER_POLICY_H_ 98 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_OFFLINER_POLICY_H_
OLDNEW
« no previous file with comments | « no previous file | components/offline_pages/background/request_coordinator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698