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

Side by Side Diff: chrome/browser/policy/user_cloud_policy_manager_factory.cc

Issue 11415094: Split UserCloudPolicyManager implementation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. Created 8 years 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2012 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 "chrome/browser/policy/user_cloud_policy_manager_factory.h"
6
7 #include "base/logging.h"
8 #include "chrome/browser/policy/user_cloud_policy_manager.h"
9 #include "chrome/browser/policy/user_cloud_policy_store.h"
10 #include "chrome/browser/profiles/profile_dependency_manager.h"
11
12 namespace policy {
13
14 // static
15 UserCloudPolicyManagerFactory* UserCloudPolicyManagerFactory::GetInstance() {
16 return Singleton<UserCloudPolicyManagerFactory>::get();
17 }
18
19 // static
20 UserCloudPolicyManager* UserCloudPolicyManagerFactory::GetForProfile(
21 Profile* profile) {
22 return GetInstance()->GetManagerForProfile(profile);
23 }
24
25 // static
26 scoped_ptr<UserCloudPolicyManager>
27 UserCloudPolicyManagerFactory::CreateForProfile(Profile* profile,
28 bool force_immediate_load) {
29 return GetInstance()->CreateManagerForProfile(profile, force_immediate_load);
30 }
31
32 UserCloudPolicyManagerFactory::UserCloudPolicyManagerFactory()
33 : ProfileKeyedBaseFactory("UserCloudPolicyManager",
34 ProfileDependencyManager::GetInstance()) {}
35
36 UserCloudPolicyManagerFactory::~UserCloudPolicyManagerFactory() {}
37
38 UserCloudPolicyManager* UserCloudPolicyManagerFactory::GetManagerForProfile(
39 Profile* profile) {
40 ManagerMap::const_iterator it = managers_.find(profile);
41 return it != managers_.end() ? it->second : NULL;
42 }
43
44 scoped_ptr<UserCloudPolicyManager>
45 UserCloudPolicyManagerFactory::CreateManagerForProfile(
46 Profile* profile,
47 bool force_immediate_load) {
48 scoped_ptr<policy::UserCloudPolicyStore> store(
49 policy::UserCloudPolicyStore::Create(profile));
50 if (force_immediate_load)
51 store->LoadImmediately();
52 return make_scoped_ptr(
53 new policy::UserCloudPolicyManager(profile, store.Pass()));
54 }
55
56 void UserCloudPolicyManagerFactory::ProfileShutdown(Profile* profile) {
57 UserCloudPolicyManager* manager = GetManagerForProfile(profile);
58 if (manager)
59 manager->Shutdown();
Elliot Glaysher 2012/11/27 23:31:22 So if I understand correctly, ProfileShutdown is r
Mattias Nissler (ping if slow) 2012/11/28 09:47:06 Mostly correct. However, I do already have a Depen
60 }
61
62 void UserCloudPolicyManagerFactory::SetEmptyTestingFactory(Profile* profile) {}
63
64 void UserCloudPolicyManagerFactory::CreateServiceNow(Profile* profile) {}
65
66 void UserCloudPolicyManagerFactory::Register(Profile* profile,
67 UserCloudPolicyManager* instance) {
68 UserCloudPolicyManager*& entry = managers_[profile];
69 DCHECK(!entry);
70 entry = instance;
71 }
72
73 void UserCloudPolicyManagerFactory::Unregister(
74 Profile* profile,
75 UserCloudPolicyManager* instance) {
76 ManagerMap::iterator entry = managers_.find(profile);
77 if (entry != managers_.end()) {
78 DCHECK_EQ(instance, entry->second);
79 managers_.erase(entry);
80 } else {
81 NOTREACHED();
82 }
83 }
84
85 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/policy/user_cloud_policy_manager_factory.h ('k') | chrome/browser/policy/user_cloud_policy_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698