OLD | NEW |
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 #ifndef CHROME_BROWSER_POLICY_CLOUD_USER_CLOUD_POLICY_MANAGER_FACTORY_H_ | 5 #ifndef CHROME_BROWSER_POLICY_CLOUD_USER_CLOUD_POLICY_MANAGER_FACTORY_H_ |
6 #define CHROME_BROWSER_POLICY_CLOUD_USER_CLOUD_POLICY_MANAGER_FACTORY_H_ | 6 #define CHROME_BROWSER_POLICY_CLOUD_USER_CLOUD_POLICY_MANAGER_FACTORY_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 static UserCloudPolicyManager* GetForBrowserContext( | 47 static UserCloudPolicyManager* GetForBrowserContext( |
48 content::BrowserContext* context); | 48 content::BrowserContext* context); |
49 | 49 |
50 // Creates an instance for |context|. Note that the caller is responsible for | 50 // Creates an instance for |context|. Note that the caller is responsible for |
51 // managing the lifetime of the instance. Subsequent calls to | 51 // managing the lifetime of the instance. Subsequent calls to |
52 // GetForBrowserContext() will return the created instance as long as it | 52 // GetForBrowserContext() will return the created instance as long as it |
53 // lives. | 53 // lives. |
54 // | 54 // |
55 // If |force_immediate_load| is true, policy is loaded synchronously from | 55 // If |force_immediate_load| is true, policy is loaded synchronously from |
56 // UserCloudPolicyStore at startup. | 56 // UserCloudPolicyStore at startup. |
| 57 // |
| 58 // |background_task_runner| is used for the cloud policy store. |
| 59 // |file_task_runner| is used for file operations. Currently this must be the |
| 60 // FILE BrowserThread. |
| 61 // |io_task_runner| is used for network IO. Currently this must be the IO |
| 62 // BrowserThread. |
57 static scoped_ptr<UserCloudPolicyManager> CreateForOriginalBrowserContext( | 63 static scoped_ptr<UserCloudPolicyManager> CreateForOriginalBrowserContext( |
58 content::BrowserContext* context, | 64 content::BrowserContext* context, |
59 bool force_immediate_load, | 65 bool force_immediate_load, |
60 scoped_refptr<base::SequencedTaskRunner> background_task_runner); | 66 const scoped_refptr<base::SequencedTaskRunner>& background_task_runner, |
| 67 const scoped_refptr<base::SequencedTaskRunner>& file_task_runner, |
| 68 const scoped_refptr<base::SequencedTaskRunner>& io_task_runner); |
61 | 69 |
62 static UserCloudPolicyManager* RegisterForOffTheRecordBrowserContext( | 70 static UserCloudPolicyManager* RegisterForOffTheRecordBrowserContext( |
63 content::BrowserContext* original_context, | 71 content::BrowserContext* original_context, |
64 content::BrowserContext* off_the_record_context); | 72 content::BrowserContext* off_the_record_context); |
65 | 73 |
66 private: | 74 private: |
67 friend class UserCloudPolicyManager; | 75 friend class UserCloudPolicyManager; |
68 friend struct DefaultSingletonTraits<UserCloudPolicyManagerFactory>; | 76 friend struct DefaultSingletonTraits<UserCloudPolicyManagerFactory>; |
69 | 77 |
70 UserCloudPolicyManagerFactory(); | 78 UserCloudPolicyManagerFactory(); |
71 virtual ~UserCloudPolicyManagerFactory(); | 79 virtual ~UserCloudPolicyManagerFactory(); |
72 | 80 |
73 // See comments for the static versions above. | 81 // See comments for the static versions above. |
74 UserCloudPolicyManager* GetManagerForBrowserContext( | 82 UserCloudPolicyManager* GetManagerForBrowserContext( |
75 content::BrowserContext* context); | 83 content::BrowserContext* context); |
76 | 84 |
77 scoped_ptr<UserCloudPolicyManager> CreateManagerForOriginalBrowserContext( | 85 scoped_ptr<UserCloudPolicyManager> CreateManagerForOriginalBrowserContext( |
78 content::BrowserContext* context, | 86 content::BrowserContext* context, |
79 bool force_immediate_load, | 87 bool force_immediate_load, |
80 scoped_refptr<base::SequencedTaskRunner> background_task_runner); | 88 const scoped_refptr<base::SequencedTaskRunner>& background_task_runner, |
| 89 const scoped_refptr<base::SequencedTaskRunner>& file_task_runner, |
| 90 const scoped_refptr<base::SequencedTaskRunner>& io_task_runner); |
81 | 91 |
82 UserCloudPolicyManager* RegisterManagerForOffTheRecordBrowserContext( | 92 UserCloudPolicyManager* RegisterManagerForOffTheRecordBrowserContext( |
83 content::BrowserContext* original_context, | 93 content::BrowserContext* original_context, |
84 content::BrowserContext* off_the_record_context); | 94 content::BrowserContext* off_the_record_context); |
85 | 95 |
86 // BrowserContextKeyedBaseFactory: | 96 // BrowserContextKeyedBaseFactory: |
87 virtual void BrowserContextShutdown( | 97 virtual void BrowserContextShutdown( |
88 content::BrowserContext* context) OVERRIDE; | 98 content::BrowserContext* context) OVERRIDE; |
89 virtual void SetEmptyTestingFactory( | 99 virtual void SetEmptyTestingFactory( |
90 content::BrowserContext* context) OVERRIDE; | 100 content::BrowserContext* context) OVERRIDE; |
91 virtual void CreateServiceNow(content::BrowserContext* context) OVERRIDE; | 101 virtual void CreateServiceNow(content::BrowserContext* context) OVERRIDE; |
92 | 102 |
93 // Invoked by UserCloudPolicyManager to register/unregister instances. | 103 // Invoked by UserCloudPolicyManager to register/unregister instances. |
94 void Register(content::BrowserContext* context, | 104 void Register(content::BrowserContext* context, |
95 UserCloudPolicyManager* instance); | 105 UserCloudPolicyManager* instance); |
96 void Unregister(content::BrowserContext* context, | 106 void Unregister(content::BrowserContext* context, |
97 UserCloudPolicyManager* instance); | 107 UserCloudPolicyManager* instance); |
98 | 108 |
99 typedef std::map<content::BrowserContext*, UserCloudPolicyManager*> | 109 typedef std::map<content::BrowserContext*, UserCloudPolicyManager*> |
100 ManagerMap; | 110 ManagerMap; |
101 | 111 |
102 ManagerMap managers_; | 112 ManagerMap managers_; |
103 | 113 |
104 DISALLOW_COPY_AND_ASSIGN(UserCloudPolicyManagerFactory); | 114 DISALLOW_COPY_AND_ASSIGN(UserCloudPolicyManagerFactory); |
105 }; | 115 }; |
106 | 116 |
107 } // namespace policy | 117 } // namespace policy |
108 | 118 |
109 #endif // CHROME_BROWSER_POLICY_CLOUD_USER_CLOUD_POLICY_MANAGER_FACTORY_H_ | 119 #endif // CHROME_BROWSER_POLICY_CLOUD_USER_CLOUD_POLICY_MANAGER_FACTORY_H_ |
OLD | NEW |