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

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: Renaming Created 4 years, 3 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..cc7c10ba1f4e13376a10b0af62c365414d38c491 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_supported_by_download;
+ bool is_removed_on_cache_reset;
+};
+
// 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;
+
+ 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},
fgorski 2016/09/07 03:25:05 was this formatting produced by "git cl format". I
chili 2016/09/12 17:39:01 Done.
+ pages_allowed_per_url,
+ {false, false}});
fgorski 2016/09/07 03:25:05 this is where I would probably stuff true in the s
chili 2016/09/12 17:39:01 Done.
+ }
+
+ ~OfflinePageClientPolicyBuilder() {}
+
+ const OfflinePageClientPolicy Build() { return policy_; }
fgorski 2016/09/07 03:25:05 Document that calling build does not reset the obj
chili 2016/09/12 17:39:01 Done.
+
+ OfflinePageClientPolicyBuilder& SetExpirePeriod(
+ const base::TimeDelta& expire_period) {
+ policy_.lifetime_policy.expiration_period = expire_period;
+ return *this;
+ }
+
+ OfflinePageClientPolicyBuilder& SetIsSupportedByDownload(
+ const bool is_downloaded) {
+ policy_.feature_policy.is_supported_by_download = is_downloaded;
+ return *this;
+ }
+
+ OfflinePageClientPolicyBuilder& SetIsRemovedOnCacheReset(
+ const bool removed_on_cache_reset) {
+ policy_.feature_policy.is_removed_on_cache_reset = removed_on_cache_reset;
+ return *this;
+ }
+
+ private:
+ OfflinePageClientPolicy policy_;
};
} // namespace offline_pages

Powered by Google App Engine
This is Rietveld 408576698