OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "components/offline_pages/client_policy_controller.h" | |
6 | |
7 #include <utility> | |
8 | |
9 #include "base/time/time.h" | |
10 | |
11 using LifetimeType = offline_pages::LifetimePolicy::LifetimeType; | |
12 | |
13 namespace offline_pages { | |
14 | |
15 namespace { | |
16 OfflinePageClientPolicy TranslateToPolicy( | |
fgorski
2016/04/30 17:42:25
fix indentation. (git cl format should align this
fgorski
2016/04/30 17:42:25
MakePolicy is a better name
Also you could make i
romax
2016/05/02 20:33:44
Done.
| |
17 std::string name_space, | |
fgorski
2016/04/30 17:42:24
const ref
romax
2016/05/02 20:33:44
Done.
| |
18 LifetimeType lifetime_type, | |
19 base::TimeDelta expire_period, | |
fgorski
2016/04/30 17:42:25
const ref
romax
2016/05/02 20:33:44
Done.
| |
20 int64_t page_limit) { | |
21 return {name_space, {lifetime_type, expire_period, page_limit}}; | |
22 } | |
23 } | |
24 | |
25 ClientPolicyController& ClientPolicyController::GetInstance() { | |
26 static ClientPolicyController instance; | |
27 return instance; | |
28 } | |
29 | |
30 OfflinePageClientPolicy ClientPolicyController::GetPolicy( | |
31 std::string name_space) { | |
32 const auto& iter = policies_.find(name_space); | |
33 if (iter != policies_.end()) { | |
fgorski
2016/04/30 17:42:25
braces not needed.
romax
2016/05/02 20:33:44
Done.
| |
34 return iter->second; | |
35 } | |
36 // Fallback when the namespace isn't defined. | |
37 return kDefaultClientPolicy; | |
38 } | |
39 | |
40 ClientPolicyController::ClientPolicyController() { | |
41 policies_.clear(); | |
42 // TODO(romax) Make here somehow more clever. | |
43 policies_.insert(std::make_pair("bookmark", | |
fgorski
2016/04/30 17:42:25
you should be referring to a const here. and below
romax
2016/05/02 20:33:44
Acknowledged.
| |
44 TranslateToPolicy("bookmark", LifetimeType::TEMPORARY, | |
45 base::TimeDelta::FromDays(7), kUnlimitedPage))); | |
46 policies_.insert(std::make_pair("last_n", | |
47 TranslateToPolicy("last_n", LifetimeType::TEMPORARY, | |
48 base::TimeDelta::FromDays(2), 20))); | |
49 } | |
50 | |
51 ClientPolicyController::~ClientPolicyController() { | |
fgorski
2016/04/30 17:42:25
Order of methods should be:
ctor
dtor
static
insta
romax
2016/05/02 20:33:44
Done.
| |
52 } | |
53 | |
54 } // namespace offline_pages | |
OLD | NEW |