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

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

Issue 2113383002: More detailed implementation of the RequestPicker (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Simplify picker logic for multiple criteria 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
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 04e7f8443d184a4bc864550b7aeabf6044831b5c..63e9a7073554273ad3f05d5022ae4ba1367f59f1 100644
--- a/components/offline_pages/background/offliner_policy.h
+++ b/components/offline_pages/background/offliner_policy.h
@@ -5,6 +5,13 @@
#ifndef COMPONENTS_OFFLINE_PAGES_BACKGROUND_OFFLINER_POLICY_H_
#define COMPONENTS_OFFLINE_PAGES_BACKGROUND_OFFLINER_POLICY_H_
+namespace {
+const int kMaxRetries = 2;
+const int kBackgroundTimeBudgetSeconds = 170;
+const int kSinglePageTimeBudgetSeconds = 120;
fgorski 2016/07/20 16:23:31 nit: having defaults specified in such way, you wi
Pete Williamson 2016/07/20 19:50:43 use your budget
fgorski 2016/07/21 17:01:20 Acknowledged.
+const int kMinimumBatteryPercentageForNonUserRequestOfflining = 50;
+} // namespace
+
namespace offline_pages {
// Policy for the Background Offlining system. Some policy will belong to the
@@ -13,8 +20,41 @@ class OfflinerPolicy {
public:
OfflinerPolicy(){};
- // TODO(petewil): Implement and add a .cc file.
- // Eventually this should get data from a finch experiment.
+ // TODO(petewil): Numbers here are chosen arbitrarily, do the proper studies
+ // to get good policy numbers.
+
+ // TODO(petewil): Eventually this should get data from a finch experiment.
+
+ // Returns true if we should prefer retrying already tried requests to
+ // starting new requests to maximize utility of any cached partial results.
+ bool ShouldPreferTriedRequests() { return true; }
+
+ // Returns true if we should prefer older requests of equal number of tries.
+ bool ShouldPreferEarlierRequests() { return true; }
+
+ // Returns true if retry count is considered more important than recency in
+ // picking which request to try next.
+ bool RetryCountIsMoreImportantThanRecency() { return true; }
+
+ // The max number of times we will retry a request.
+ int GetMaxRetries() { return kMaxRetries; }
+
+ // How many seconds to keep trying new pages for, before we give up, and
+ // return to the scheduler for the time being.
fgorski 2016/07/20 16:23:31 nit: can you remove "for the time being"? just "re
Pete Williamson 2016/07/20 19:50:43 Done.
+ int GetBackgroundProcessingTimeBudgetSeconds() {
+ return kBackgroundTimeBudgetSeconds;
+ }
+
+ // How long do we allow a page to load before giving up on it
+ int GetSinglePageTimeBudgetInSeconds() {
+ return kSinglePageTimeBudgetSeconds;
+ }
+
+ // How much battery must we have before fetching a page not explicitly
+ // requested by the user?
+ int GetMinimumBatteryPercentageForNonUserRequestOfflining() {
fgorski 2016/07/20 16:23:31 nit: I think it is safe to drop offlining (given t
Pete Williamson 2016/07/20 19:50:43 Not done, I think it is better to be more explict
+ return kMinimumBatteryPercentageForNonUserRequestOfflining;
+ }
};
}

Powered by Google App Engine
This is Rietveld 408576698