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

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: Update tests and code review comments 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
« no previous file with comments | « components/offline_pages/client_policy_controller_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..d87818fdc05abe5429ca092adc95f31dc2a6f061 100644
--- a/components/offline_pages/offline_page_client_policy.h
+++ b/components/offline_pages/offline_page_client_policy.h
@@ -39,6 +39,14 @@ struct LifetimePolicy {
size_t page_limit;
};
+// The struct describing feature set of the offline pages.
+struct FeaturePolicy {
+ // Whether pages are shown in download ui.
+ bool is_supported_by_download;
+ // Whether pages are removed on user-initiated cache reset. Defaults to true.
+ 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 +60,48 @@ 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},
+ pages_allowed_per_url,
+ {false, true}});
Dmitry Titov 2016/09/12 17:43:34 could you add in-line comments here to say what th
dewittj 2016/09/12 18:06:35 I'd propose adding default values when possible to
chili 2016/09/12 21:24:06 Done.
+ }
+
+ ~OfflinePageClientPolicyBuilder() {}
+
+ // Calling build does not reset the object inside.
+ const OfflinePageClientPolicy Build() const { return policy_; }
+
+ 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_;
Dmitry Titov 2016/09/12 17:43:34 DISALLOW_COPY_AND_ASSIGN...
chili 2016/09/12 21:24:06 Done.
};
} // namespace offline_pages
« no previous file with comments | « components/offline_pages/client_policy_controller_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698