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

Unified Diff: components/offline_pages/offline_page_client_policy.h

Issue 2289143005: [Offline pages] Add a builder and feature struct to policy (Closed)
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 side-by-side diff with in-line comments
Download patch
Index: components/offline_pages/offline_page_client_policy.h
diff --git a/components/offline_pages/offline_page_client_policy.h b/components/offline_pages/offline_page_client_policy.h
index de7ae526b0038685b403773c3a2ec1bcd3c14aa0..760075a217284956acd77fecea4c24608e361150 100644
--- a/components/offline_pages/offline_page_client_policy.h
+++ b/components/offline_pages/offline_page_client_policy.h
@@ -39,6 +39,12 @@ struct LifetimePolicy {
size_t page_limit;
};
+// The struct describing feature set of the offline pages.
+struct FeaturePolicy {
+ bool is_enabled_for_downloads;
+ bool is_user_requested;
+};
+
// The struct describing policies for various namespaces (Bookmark, Last-N etc.)
// used by offline page model. The name_space is supposed to be key, so that
// it's sufficient to compare name_space only when doing comparisons.
@@ -52,6 +58,46 @@ struct OfflinePageClientPolicy {
// How many pages for the same online URL can be stored at any time.
// kUnlimitedPages means there's no limit.
size_t pages_allowed_per_url;
fgorski 2016/08/31 21:31:00 wouldn't this qualify as feature policy?
chili 2016/09/06 20:55:20 I see feature policies (perhaps I should change na
+
+ FeaturePolicy feature_policy;
+};
+
+class OfflinePageClientPolicyBuilder {
+ public:
+ OfflinePageClientPolicyBuilder(const std::string& name_space,
+ LifetimePolicy::LifetimeType lifetime_type,
+ size_t page_limit,
+ size_t pages_allowed_per_url) {
+ policy_ = OfflinePageClientPolicy({name_space,
+ {lifetime_type, base::TimeDelta::FromDays(0), page_limit},
+ pages_allowed_per_url,
+ {false, false}});
+ }
+
+ ~OfflinePageClientPolicyBuilder() {}
+
+ const OfflinePageClientPolicy Build() { return policy_; }
+
+ OfflinePageClientPolicyBuilder& SetExpirePeriod(
+ const base::TimeDelta& expire_period) {
+ policy_.lifetime_policy.expiration_period = expire_period;
+ return *this;
+ }
+
+ OfflinePageClientPolicyBuilder& SetIsDownloaded(
+ const bool is_downloaded) {
+ policy_.feature_policy.is_enabled_for_downloads = is_downloaded;
+ return *this;
+ }
+
+ OfflinePageClientPolicyBuilder& SetUserRequested(
+ const bool user_requested) {
+ policy_.feature_policy.is_user_requested = user_requested;
+ return *this;
+ }
+
+ private:
+ OfflinePageClientPolicy policy_;
};
} // namespace offline_pages

Powered by Google App Engine
This is Rietveld 408576698