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

Side by Side Diff: components/offline_pages/client_policy_controller.cc

Issue 1934743003: Implementing client policy and controller. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixing build errors. Created 4 years, 7 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 unified diff | Download patch
OLDNEW
(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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698