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

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

Issue 11415094: Split UserCloudPolicyManager implementation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebae 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 #ifndef CHROME_BROWSER_POLICY_USER_CLOUD_POLICY_MANAGER_FACTORY_H_
6 #define CHROME_BROWSER_POLICY_USER_CLOUD_POLICY_MANAGER_FACTORY_H_
7
8 #include <map>
9
10 #include "base/basictypes.h"
11 #include "base/memory/singleton.h"
12 #include "chrome/browser/profiles/profile_keyed_base_factory.h"
13
14 class Profile;
15
16 namespace policy {
17
18 class UserCloudPolicyManager;
19
20 // ProfileKeyedBaseFactory implementation for UserCloudPolicyManager
21 // instances that initialize per-profile cloud policy settings on the desktop
22 // platforms.
23 //
24 // UserCloudPolicyManager is handled different than other ProfileKeyedServices
25 // because it is a dependency of PrefService. Therefore, lifetime of instances
26 // is managed by Profile, Profile startup code invokes InitForProfile()
Andrew T Wilson (Slow) 2012/11/23 15:04:20 Is this comment still true?
Mattias Nissler (ping if slow) 2012/11/23 17:36:06 Updated.
27 // explicitly and the instance is only deleted after PrefService destruction.
28 //
29 // TODO(mnissler): Remove the special lifetime management in favor of
30 // PrefService directly depending on UserCloudPolicyManager once the former has
31 // been converted to a ProfileKeyedService.
32 class UserCloudPolicyManagerFactory : public ProfileKeyedBaseFactory {
33 public:
34 // Returns an instance of the UserCloudPolicyManagerFactory singleton.
35 static UserCloudPolicyManagerFactory* GetInstance();
36
37 // Returns the UserCloudPolicyManager instance associated with |profile|.
38 static UserCloudPolicyManager* GetForProfile(Profile* profile);
39
40 private:
41 friend class UserCloudPolicyManager;
42 friend struct DefaultSingletonTraits<UserCloudPolicyManagerFactory>;
43
44 UserCloudPolicyManagerFactory();
45 virtual ~UserCloudPolicyManagerFactory();
46
47 // Returns the instance for |profile| or NULL if not found.
48 UserCloudPolicyManager* GetManagerForProfile(Profile* profile);
49
50 // ProfileKeyedBaseFactory:
51 virtual void ProfileShutdown(Profile* profile) OVERRIDE;
52 virtual void SetEmptyTestingFactory(Profile* profile) OVERRIDE;
53 virtual void CreateServiceNow(Profile* profile) OVERRIDE;
54
55 // Invoked by UserCloudPolicyManager to register/unregister instances.
56 void Register(Profile* profile, UserCloudPolicyManager* instance);
57 void Unregister(Profile* profile, UserCloudPolicyManager* instance);
Andrew T Wilson (Slow) 2012/11/23 15:04:20 Is there a reason why creation of UCPMs has to hap
Mattias Nissler (ping if slow) 2012/11/23 17:36:06 Good idea, fixed that. We still need the Unregiste
58
59 typedef std::map<Profile*, UserCloudPolicyManager*> ManagerMap;
60 ManagerMap managers_;
Andrew T Wilson (Slow) 2012/11/23 15:04:20 I don't totally understand why we need to do this
Mattias Nissler (ping if slow) 2012/11/23 17:36:06 ProfileKeyedServiceFactory is owning all the servi
61
62 DISALLOW_COPY_AND_ASSIGN(UserCloudPolicyManagerFactory);
63 };
64
65 } // namespace policy
66
67 #endif // CHROME_BROWSER_POLICY_USER_CLOUD_POLICY_MANAGER_FACTORY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698