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

Unified Diff: components/offline_pages/background/offliner_policy.h

Issue 2178723002: Add more unit tests for RequestPicker (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rename helper function, improve comment 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | components/offline_pages/background/request_picker_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/offline_pages/background/offliner_policy.h
diff --git a/components/offline_pages/background/offliner_policy.h b/components/offline_pages/background/offliner_policy.h
index ee2cc0db615b05a614ff0ce23379ac3e1fa54196..0d97c6777c48640a10fbbd226948a7db31510b9d 100644
--- a/components/offline_pages/background/offliner_policy.h
+++ b/components/offline_pages/background/offliner_policy.h
@@ -18,7 +18,17 @@ namespace offline_pages {
// RequestCoordinator, some to the RequestQueue, and some to the Offliner.
class OfflinerPolicy {
public:
- OfflinerPolicy(){};
+ OfflinerPolicy()
+ : prefer_untried_requests_(false),
+ prefer_earlier_requests_(true),
+ retry_count_is_more_important_than_recency_(true) {}
+
+ OfflinerPolicy(bool prefer_untried,
+ bool prefer_earlier,
+ bool prefer_retry_count)
+ : prefer_untried_requests_(prefer_untried),
+ prefer_earlier_requests_(prefer_earlier),
+ retry_count_is_more_important_than_recency_(prefer_retry_count) {}
// TODO(petewil): Numbers here are chosen arbitrarily, do the proper studies
// to get good policy numbers.
@@ -26,14 +36,16 @@ class OfflinerPolicy {
// TODO(petewil): Eventually this should get data from a finch experiment.
// Returns true if we should prefer retrying lesser tried requests.
- bool ShouldPreferUntriedRequests() { return false; }
+ bool ShouldPreferUntriedRequests() const { return prefer_untried_requests_; }
// Returns true if we should prefer older requests of equal number of tries.
- bool ShouldPreferEarlierRequests() { return true; }
+ bool ShouldPreferEarlierRequests() const { return prefer_earlier_requests_; }
// Returns true if retry count is considered more important than recency in
// picking which request to try next.
- bool RetryCountIsMoreImportantThanRecency() { return true; }
+ bool RetryCountIsMoreImportantThanRecency() const {
+ return retry_count_is_more_important_than_recency_;
+ }
// The max number of times we will retry a request.
int GetMaxRetries() { return kMaxRetries; }
@@ -54,6 +66,11 @@ class OfflinerPolicy {
int GetMinimumBatteryPercentageForNonUserRequestOfflining() {
return kMinimumBatteryPercentageForNonUserRequestOfflining;
}
+
+ private:
+ bool prefer_untried_requests_;
+ bool prefer_earlier_requests_;
+ bool retry_count_is_more_important_than_recency_;
};
}
« no previous file with comments | « no previous file | components/offline_pages/background/request_picker_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698