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

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

Issue 2218403002: Change database scheme - add state and start tracking (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Stop clearing last request time 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
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 kMaxTries = 1; 9 const int kMaxStartedTries = 5;
10 const int kMaxCompletedTries = 1;
10 const int kBackgroundProcessingTimeBudgetSeconds = 170; 11 const int kBackgroundProcessingTimeBudgetSeconds = 170;
11 const int kSinglePageTimeLimitSeconds = 120; 12 const int kSinglePageTimeLimitSeconds = 120;
12 const int kMinimumBatteryPercentageForNonUserRequestOfflining = 50; 13 const int kMinimumBatteryPercentageForNonUserRequestOfflining = 50;
13 const int kRequestExpirationTimeInSeconds = 60 * 60 * 24 * 7; 14 const int kRequestExpirationTimeInSeconds = 60 * 60 * 24 * 7;
14 } // namespace 15 } // namespace
15 16
16 namespace offline_pages { 17 namespace offline_pages {
17 18
18 // 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
19 // RequestCoordinator, some to the RequestQueue, and some to the Offliner. 20 // RequestCoordinator, some to the RequestQueue, and some to the Offliner.
20 class OfflinerPolicy { 21 class OfflinerPolicy {
21 public: 22 public:
22 OfflinerPolicy() 23 OfflinerPolicy()
23 : prefer_untried_requests_(false), 24 : prefer_untried_requests_(false),
24 prefer_earlier_requests_(true), 25 prefer_earlier_requests_(true),
25 retry_count_is_more_important_than_recency_(false) {} 26 retry_count_is_more_important_than_recency_(false),
27 max_started_tries_(kMaxStartedTries),
28 max_completed_tries_(kMaxCompletedTries) {}
26 29
30 // Constructor for unit tests.
27 OfflinerPolicy(bool prefer_untried, 31 OfflinerPolicy(bool prefer_untried,
28 bool prefer_earlier, 32 bool prefer_earlier,
29 bool prefer_retry_count) 33 bool prefer_retry_count,
34 int max_started_tries,
35 int max_completed_tries)
30 : prefer_untried_requests_(prefer_untried), 36 : prefer_untried_requests_(prefer_untried),
31 prefer_earlier_requests_(prefer_earlier), 37 prefer_earlier_requests_(prefer_earlier),
32 retry_count_is_more_important_than_recency_(prefer_retry_count) {} 38 retry_count_is_more_important_than_recency_(prefer_retry_count),
39 max_started_tries_(max_started_tries),
40 max_completed_tries_(max_completed_tries) {}
33 41
34 // TODO(petewil): Numbers here are chosen arbitrarily, do the proper studies 42 // TODO(petewil): Numbers here are chosen arbitrarily, do the proper studies
35 // to get good policy numbers. 43 // to get good policy numbers.
36 44
37 // TODO(petewil): Eventually this should get data from a finch experiment. 45 // TODO(petewil): Eventually this should get data from a finch experiment.
38 46
39 // Returns true if we should prefer retrying lesser tried requests. 47 // Returns true if we should prefer retrying lesser tried requests.
40 bool ShouldPreferUntriedRequests() const { return prefer_untried_requests_; } 48 bool ShouldPreferUntriedRequests() const { return prefer_untried_requests_; }
41 49
42 // Returns true if we should prefer older requests of equal number of tries. 50 // Returns true if we should prefer older requests of equal number of tries.
43 bool ShouldPreferEarlierRequests() const { return prefer_earlier_requests_; } 51 bool ShouldPreferEarlierRequests() const { return prefer_earlier_requests_; }
44 52
45 // Returns true if retry count is considered more important than recency in 53 // Returns true if retry count is considered more important than recency in
46 // picking which request to try next. 54 // picking which request to try next.
47 bool RetryCountIsMoreImportantThanRecency() const { 55 bool RetryCountIsMoreImportantThanRecency() const {
48 return retry_count_is_more_important_than_recency_; 56 return retry_count_is_more_important_than_recency_;
49 } 57 }
50 58
51 // The max number of times we will retry a request. 59 // The max number of times we will start a request. Not all started attempts
52 int GetMaxTries() const { return kMaxTries; } 60 // will complete. This may be caused by prerenderer issues or chromium being
61 // swapped out of memory.
62 int GetMaxStartedTries() const { return max_started_tries_; }
63
64 // The max number of times we will retry a request when the attempt
65 // completed, but failed.
66 int GetMaxCompletedTries() const { return max_completed_tries_; }
53 67
54 bool PowerRequiredForUserRequestedPage() const { return false; } 68 bool PowerRequiredForUserRequestedPage() const { return false; }
55 69
56 bool PowerRequiredForNonUserRequestedPage() const { return true; } 70 bool PowerRequiredForNonUserRequestedPage() const { return true; }
57 71
58 bool UnmeteredNetworkRequiredForUserRequestedPage() const { return false; } 72 bool UnmeteredNetworkRequiredForUserRequestedPage() const { return false; }
59 73
60 bool UnmeteredNetworkRequiredForNonUserRequestedPage() const { return true; } 74 bool UnmeteredNetworkRequiredForNonUserRequestedPage() const { return true; }
61 75
62 int BatteryPercentageRequiredForUserRequestedPage() const { return 0; } 76 int BatteryPercentageRequiredForUserRequestedPage() const { return 0; }
(...skipping 22 matching lines...) Expand all
85 // How much battery must we have before fetching a page not explicitly 99 // How much battery must we have before fetching a page not explicitly
86 // requested by the user? 100 // requested by the user?
87 int GetMinimumBatteryPercentageForNonUserRequestOfflining() const { 101 int GetMinimumBatteryPercentageForNonUserRequestOfflining() const {
88 return kMinimumBatteryPercentageForNonUserRequestOfflining; 102 return kMinimumBatteryPercentageForNonUserRequestOfflining;
89 } 103 }
90 104
91 private: 105 private:
92 bool prefer_untried_requests_; 106 bool prefer_untried_requests_;
93 bool prefer_earlier_requests_; 107 bool prefer_earlier_requests_;
94 bool retry_count_is_more_important_than_recency_; 108 bool retry_count_is_more_important_than_recency_;
109 int max_started_tries_;
110 int max_completed_tries_;
95 }; 111 };
96 } 112 }
97 113
98 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_OFFLINER_POLICY_H_ 114 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_OFFLINER_POLICY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698