Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/offline_pages/client_policy_controller.h" | 5 #include "components/offline_pages/client_policy_controller.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
| 10 #include "components/offline_pages/client_namespace_constants.h" | 10 #include "components/offline_pages/client_namespace_constants.h" |
| 11 | 11 |
| 12 using LifetimeType = offline_pages::LifetimePolicy::LifetimeType; | 12 using LifetimeType = offline_pages::LifetimePolicy::LifetimeType; |
| 13 | 13 |
| 14 namespace offline_pages { | 14 namespace offline_pages { |
| 15 | 15 |
| 16 ClientPolicyController::ClientPolicyController() { | 16 ClientPolicyController::ClientPolicyController() { |
| 17 policies_.clear(); | 17 policies_.clear(); |
| 18 // Manually defining client policies for bookmark and last_n. | 18 // Manually defining client policies for bookmark and last_n. |
| 19 policies_.insert(std::make_pair( | 19 policies_.insert(std::make_pair( |
| 20 kBookmarkNamespace, | 20 kBookmarkNamespace, |
| 21 MakePolicy(kBookmarkNamespace, LifetimeType::TEMPORARY, | 21 MakePolicy(kBookmarkNamespace, LifetimeType::TEMPORARY, |
| 22 base::TimeDelta::FromDays(7), kUnlimitedPages, 1))); | 22 base::TimeDelta::FromDays(7), kUnlimitedPages, 1))); |
| 23 policies_.insert(std::make_pair( | 23 policies_.insert(std::make_pair( |
| 24 kLastNNamespace, | 24 kLastNNamespace, |
| 25 MakePolicy(kLastNNamespace, LifetimeType::TEMPORARY, | 25 MakePolicy(kLastNNamespace, LifetimeType::TEMPORARY, |
| 26 base::TimeDelta::FromDays(2), kUnlimitedPages, 1))); | 26 base::TimeDelta::FromDays(2), kUnlimitedPages, 1))); |
| 27 policies_.insert(std::make_pair( | |
| 28 kAsyncNamespace, MakePolicy(kAsyncNamespace, LifetimeType::TEMPORARY, | |
|
fgorski
2016/07/01 19:26:09
They should be LifetimeType::PERSISTENT.
romax
2016/07/06 22:03:28
I'm not against to change it to persistent. Howeve
fgorski
2016/07/07 17:01:45
We are not done with the feature. Downloads home i
| |
| 29 base::TimeDelta::FromDays(2), kUnlimitedPages, | |
|
fgorski
2016/07/01 19:26:09
We need to make sure we have an infinite expiratio
romax
2016/07/06 22:03:27
please see previous comment.
| |
| 30 kUnlimitedPages))); | |
| 27 // Fallback policy. | 31 // Fallback policy. |
| 28 policies_.insert(std::make_pair( | 32 policies_.insert(std::make_pair( |
| 29 kDefaultNamespace, MakePolicy(kDefaultNamespace, LifetimeType::TEMPORARY, | 33 kDefaultNamespace, MakePolicy(kDefaultNamespace, LifetimeType::TEMPORARY, |
| 30 base::TimeDelta::FromDays(1), 10, 1))); | 34 base::TimeDelta::FromDays(1), 10, 1))); |
| 31 } | 35 } |
| 32 | 36 |
| 33 ClientPolicyController::~ClientPolicyController() {} | 37 ClientPolicyController::~ClientPolicyController() {} |
| 34 | 38 |
| 35 // static | 39 // static |
| 36 const OfflinePageClientPolicy ClientPolicyController::MakePolicy( | 40 const OfflinePageClientPolicy ClientPolicyController::MakePolicy( |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 48 const OfflinePageClientPolicy& ClientPolicyController::GetPolicy( | 52 const OfflinePageClientPolicy& ClientPolicyController::GetPolicy( |
| 49 const std::string& name_space) const { | 53 const std::string& name_space) const { |
| 50 const auto& iter = policies_.find(name_space); | 54 const auto& iter = policies_.find(name_space); |
| 51 if (iter != policies_.end()) | 55 if (iter != policies_.end()) |
| 52 return iter->second; | 56 return iter->second; |
| 53 // Fallback when the namespace isn't defined. | 57 // Fallback when the namespace isn't defined. |
| 54 return policies_.at(kDefaultNamespace); | 58 return policies_.at(kDefaultNamespace); |
| 55 } | 59 } |
| 56 | 60 |
| 57 } // namespace offline_pages | 61 } // namespace offline_pages |
| OLD | NEW |