Chromium Code Reviews| 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..714a402d6b27568c1feb6fb04654ed27ee34d282 100644 |
| --- a/components/offline_pages/offline_page_client_policy.h |
| +++ b/components/offline_pages/offline_page_client_policy.h |
| @@ -32,13 +32,21 @@ struct LifetimePolicy { |
| LifetimeType lifetime_type; |
|
dewittj
2016/09/12 21:40:53
I might also assign defaults here and in page_limi
chili
2016/09/13 00:36:10
Done.
|
| // The time after which the page expires. |
| - base::TimeDelta expiration_period; |
| + base::TimeDelta expiration_period = base::TimeDelta::FromDays(0); |
| // The maximum number of pages allowed to be saved by the namespace. |
| // kUnlimitedPages (defined above) means no limit set. |
| 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 = false; |
| + // Whether pages are removed on user-initiated cache reset. Defaults to true. |
| + bool is_removed_on_cache_reset = true; |
| +}; |
| + |
| // 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,50 @@ 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(); |
|
dewittj
2016/09/12 21:40:53
Is this line strictly necessary? I think it shoul
chili
2016/09/13 00:36:10
Done.
|
| + policy_.name_space = name_space; |
| + policy_.lifetime_policy.lifetime_type = lifetime_type; |
| + policy_.lifetime_policy.page_limit = page_limit; |
| + policy_.pages_allowed_per_url = pages_allowed_per_url; |
| + } |
| + |
| + ~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_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(OfflinePageClientPolicyBuilder); |
| }; |
| } // namespace offline_pages |