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

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

Issue 19733003: Implement cloud policy invalidations using the invalidation service framework. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 4 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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 "chrome/browser/policy/cloud/user_cloud_policy_manager_factory.h" 5 #include "chrome/browser/policy/cloud/user_cloud_policy_manager_factory.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "chrome/browser/invalidation/invalidation_service_factory.h"
9 #include "chrome/browser/policy/cloud/user_cloud_policy_manager.h" 10 #include "chrome/browser/policy/cloud/user_cloud_policy_manager.h"
10 #include "chrome/browser/policy/cloud/user_cloud_policy_store.h" 11 #include "chrome/browser/policy/cloud/user_cloud_policy_store.h"
11 #include "chrome/browser/profiles/profile.h" 12 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/common/chrome_switches.h" 13 #include "chrome/common/chrome_switches.h"
13 #include "components/browser_context_keyed_service/browser_context_dependency_ma nager.h" 14 #include "components/browser_context_keyed_service/browser_context_dependency_ma nager.h"
14 15
15 namespace policy { 16 namespace policy {
16 17
17 // static 18 // static
18 UserCloudPolicyManagerFactory* UserCloudPolicyManagerFactory::GetInstance() { 19 UserCloudPolicyManagerFactory* UserCloudPolicyManagerFactory::GetInstance() {
19 return Singleton<UserCloudPolicyManagerFactory>::get(); 20 return Singleton<UserCloudPolicyManagerFactory>::get();
20 } 21 }
21 22
22 // static 23 // static
23 UserCloudPolicyManager* UserCloudPolicyManagerFactory::GetForProfile( 24 UserCloudPolicyManager* UserCloudPolicyManagerFactory::GetForProfile(
24 Profile* profile) { 25 Profile* profile) {
25 return GetInstance()->GetManagerForProfile(profile); 26 return GetInstance()->GetManagerForProfile(profile);
26 } 27 }
27 28
28 // static 29 // static
29 scoped_ptr<UserCloudPolicyManager> 30 scoped_ptr<UserCloudPolicyManager>
30 UserCloudPolicyManagerFactory::CreateForProfile(Profile* profile, 31 UserCloudPolicyManagerFactory::CreateForProfile(Profile* profile,
31 bool force_immediate_load) { 32 bool force_immediate_load) {
32 return GetInstance()->CreateManagerForProfile(profile, force_immediate_load); 33 return GetInstance()->CreateManagerForProfile(profile, force_immediate_load);
33 } 34 }
34 35
35 UserCloudPolicyManagerFactory::UserCloudPolicyManagerFactory() 36 UserCloudPolicyManagerFactory::UserCloudPolicyManagerFactory()
36 : BrowserContextKeyedBaseFactory( 37 : BrowserContextKeyedBaseFactory(
37 "UserCloudPolicyManager", 38 "UserCloudPolicyManager",
38 BrowserContextDependencyManager::GetInstance()) {} 39 BrowserContextDependencyManager::GetInstance()) {
40 DependsOn(invalidation::InvalidationServiceFactory::GetInstance());
41 }
39 42
40 UserCloudPolicyManagerFactory::~UserCloudPolicyManagerFactory() {} 43 UserCloudPolicyManagerFactory::~UserCloudPolicyManagerFactory() {}
41 44
42 UserCloudPolicyManager* UserCloudPolicyManagerFactory::GetManagerForProfile( 45 UserCloudPolicyManager* UserCloudPolicyManagerFactory::GetManagerForProfile(
43 Profile* profile) { 46 Profile* profile) {
44 // Get the manager for the original profile, since the PolicyService is 47 // Get the manager for the original profile, since the PolicyService is
45 // also shared between the incognito Profile and the original Profile. 48 // also shared between the incognito Profile and the original Profile.
46 ManagerMap::const_iterator it = managers_.find(profile->GetOriginalProfile()); 49 ManagerMap::const_iterator it = managers_.find(profile->GetOriginalProfile());
47 return it != managers_.end() ? it->second : NULL; 50 return it != managers_.end() ? it->second : NULL;
48 } 51 }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 ManagerMap::iterator entry = managers_.find(profile); 100 ManagerMap::iterator entry = managers_.find(profile);
98 if (entry != managers_.end()) { 101 if (entry != managers_.end()) {
99 DCHECK_EQ(instance, entry->second); 102 DCHECK_EQ(instance, entry->second);
100 managers_.erase(entry); 103 managers_.erase(entry);
101 } else { 104 } else {
102 NOTREACHED(); 105 NOTREACHED();
103 } 106 }
104 } 107 }
105 108
106 } // namespace policy 109 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698