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

Unified 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: Crazy ProfileKeyedService hackery. Created 8 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/policy/user_cloud_policy_manager_factory.h
diff --git a/chrome/browser/policy/user_cloud_policy_manager_factory.h b/chrome/browser/policy/user_cloud_policy_manager_factory.h
new file mode 100644
index 0000000000000000000000000000000000000000..5fb264bbfbdf6e20b2af31582e981e20f39dbc2a
--- /dev/null
+++ b/chrome/browser/policy/user_cloud_policy_manager_factory.h
@@ -0,0 +1,66 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_POLICY_USER_CLOUD_POLICY_MANAGER_FACTORY_H_
+#define CHROME_BROWSER_POLICY_USER_CLOUD_POLICY_MANAGER_FACTORY_H_
+
+#include <map>
+
+#include "base/basictypes.h"
+#include "base/memory/singleton.h"
+#include "chrome/browser/profiles/profile_keyed_base_factory.h"
+
+class Profile;
+
+namespace policy {
+
+class UserCloudPolicyManager;
+
+// ProfileKeyedBaseFactory implementation for UserCloudPolicyManager
+// instances that initialize per-profile cloud policy settings on the desktop
+// platforms.
+//
+// UserCloudPolicyManager is handled different than other ProfileKeyedServices
+// because it is a dependency of PrefService. Therefore, Profile startup code
+// invokes InitForProfile() explicitly and the instance is only deleted after
+// PrefService destruction.
+//
+// TODO(mnissler): Remove the special lifetime management in favor of directly
+// depending on PrefService once the latter is a ProfileKeyedService.
Joao da Silva 2012/11/23 10:08:12 Mention bugs 131843 and 131844.
Mattias Nissler (ping if slow) 2012/11/23 17:36:06 Done.
+class UserCloudPolicyManagerFactory : public ProfileKeyedBaseFactory {
+ public:
+ // Returns an instance of the UserCloudPolicyManagerFactory singleton.
+ static UserCloudPolicyManagerFactory* GetInstance();
+
+ // Returns the UserCloudPolicyManager instance associated with |profile|.
+ static UserCloudPolicyManager* GetForProfile(Profile* profile);
+
+ private:
+ friend class UserCloudPolicyManager;
+ friend struct DefaultSingletonTraits<UserCloudPolicyManagerFactory>;
+
+ UserCloudPolicyManagerFactory();
+ virtual ~UserCloudPolicyManagerFactory();
+
+ // Returns the instance for |profile| or NULL if not found.
+ UserCloudPolicyManager* GetManagerForProfile(Profile* profile);
+
+ // ProfileKeyedBaseFactory:
+ virtual void ProfileShutdown(Profile* profile) OVERRIDE;
+ virtual void SetEmptyTestingFactory(Profile* profile) OVERRIDE;
+ virtual void CreateServiceNow(Profile* profile) OVERRIDE;
+
+ // Invoked by UserCloudPolicyManager to register/unregister instances.
+ void Register(Profile* profile, UserCloudPolicyManager* instance);
+ void Unregister(Profile* profile, UserCloudPolicyManager* instance);
+
+ typedef std::map<Profile*, UserCloudPolicyManager*> ManagerMap;
+ ManagerMap managers_;
+
+ DISALLOW_COPY_AND_ASSIGN(UserCloudPolicyManagerFactory);
+};
+
+} // namespace policy
+
+#endif // CHROME_BROWSER_POLICY_USER_CLOUD_POLICY_MANAGER_FACTORY_H_

Powered by Google App Engine
This is Rietveld 408576698