OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_INVALIDATOR_H_ | 5 #ifndef CHROME_BROWSER_POLICY_CLOUD_USER_CLOUD_POLICY_INVALIDATOR_H_ |
6 #define CHROME_BROWSER_POLICY_CLOUD_USER_CLOUD_POLICY_INVALIDATOR_H_ | 6 #define CHROME_BROWSER_POLICY_CLOUD_USER_CLOUD_POLICY_INVALIDATOR_H_ |
7 | 7 |
| 8 #include "base/memory/weak_ptr.h" |
8 #include "chrome/browser/policy/cloud/cloud_policy_invalidator.h" | 9 #include "chrome/browser/policy/cloud/cloud_policy_invalidator.h" |
9 #include "components/browser_context_keyed_service/browser_context_keyed_service
.h" | 10 #include "components/browser_context_keyed_service/browser_context_keyed_service
.h" |
10 #include "content/public/browser/notification_observer.h" | 11 #include "content/public/browser/notification_observer.h" |
11 #include "content/public/browser/notification_registrar.h" | 12 #include "content/public/browser/notification_registrar.h" |
12 | 13 |
13 class Profile; | 14 class Profile; |
14 | 15 |
15 namespace policy { | 16 namespace policy { |
16 | 17 |
17 class CloudPolicyManager; | 18 class CloudPolicyManager; |
18 | 19 |
19 // Provides invalidations to user policy. Implemented as a | 20 // Provides invalidations to user policy. Implemented as a |
20 // BrowserContextKeyedService to allow profile-based lifetime management. | 21 // BrowserContextKeyedService to allow profile-based lifetime management. |
21 class UserCloudPolicyInvalidator : public CloudPolicyInvalidator, | 22 class UserCloudPolicyInvalidator : public CloudPolicyInvalidator, |
22 public BrowserContextKeyedService, | 23 public BrowserContextKeyedService, |
23 public content::NotificationObserver { | 24 public content::NotificationObserver { |
24 public: | 25 public: |
25 // |profile| is profile associated with the invalidator. It is used to get | 26 // |profile| is profile associated with the invalidator. It is used to get |
26 // a reference to the profile's invalidation service. Both the profile and | 27 // a reference to the profile's invalidation service. Both the profile and |
27 // invalidation service must remain valid until Shutdown is called. | 28 // invalidation service must remain valid until Shutdown is called. |
28 // |policy_manager| is the policy manager for the user policy and must remain | 29 // |policy_manager| is the policy manager for the user policy and must remain |
29 // valid until Shutdown is called. | 30 // valid until Shutdown is called. |
30 UserCloudPolicyInvalidator( | 31 UserCloudPolicyInvalidator( |
31 Profile* profile, | 32 Profile* profile, |
32 CloudPolicyManager* policy_manager); | 33 CloudPolicyManager* policy_manager); |
33 | 34 |
| 35 virtual ~UserCloudPolicyInvalidator(); |
| 36 |
34 // BrowserContextKeyedService: | 37 // BrowserContextKeyedService: |
35 virtual void Shutdown() OVERRIDE; | 38 virtual void Shutdown() OVERRIDE; |
36 | 39 |
37 // content::NotificationObserver implementation: | 40 // content::NotificationObserver implementation: |
38 virtual void Observe(int type, | 41 virtual void Observe(int type, |
39 const content::NotificationSource& source, | 42 const content::NotificationSource& source, |
40 const content::NotificationDetails& details) OVERRIDE; | 43 const content::NotificationDetails& details) OVERRIDE; |
41 | 44 |
42 private: | 45 private: |
43 // The profile associated with the invalidator. | |
44 Profile* profile_; | |
45 | |
46 // The policy manager for the user policy. | 46 // The policy manager for the user policy. |
47 CloudPolicyManager* policy_manager_; | 47 CloudPolicyManager* policy_manager_; |
48 | 48 |
49 // Used to register for notification that profile creation is complete. | 49 // Used to register for notification that profile creation is complete. |
50 content::NotificationRegistrar registrar_; | 50 content::NotificationRegistrar registrar_; |
51 | 51 |
| 52 // WeakPtrFactory used to create a reference to this object used by the |
| 53 // policy manager. |
| 54 base::WeakPtrFactory<CloudPolicyInvalidator> weak_factory_; |
| 55 |
52 DISALLOW_COPY_AND_ASSIGN(UserCloudPolicyInvalidator); | 56 DISALLOW_COPY_AND_ASSIGN(UserCloudPolicyInvalidator); |
53 }; | 57 }; |
54 | 58 |
55 } // namespace policy | 59 } // namespace policy |
56 | 60 |
57 #endif // CHROME_BROWSER_POLICY_CLOUD_USER_CLOUD_POLICY_INVALIDATOR_H_ | 61 #endif // CHROME_BROWSER_POLICY_CLOUD_USER_CLOUD_POLICY_INVALIDATOR_H_ |
OLD | NEW |