OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2013 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 #include "chrome/browser/policy/cloud/user_cloud_policy_invalidator.h" | |
6 | |
7 #include "base/bind.h" | |
8 #include "base/message_loop/message_loop.h" | |
9 #include "chrome/browser/chrome_notification_types.h" | |
10 #include "chrome/browser/policy/cloud/cloud_policy_core.h" | |
11 #include "chrome/browser/policy/cloud/cloud_policy_manager.h" | |
12 #include "content/public/browser/notification_source.h" | |
13 | |
14 namespace policy { | |
15 | |
16 UserCloudPolicyInvalidator::UserCloudPolicyInvalidator( | |
17 Profile* profile, | |
18 CloudPolicyManager* policy_manager) | |
19 : CloudPolicyInvalidator( | |
20 policy_manager, | |
21 policy_manager->core()->store(), | |
22 base::MessageLoop::current()->message_loop_proxy()), | |
Joao da Silva
2013/07/29 19:44:32
base::MessageLoopProxy::current()
Steve Condie
2013/07/29 20:44:51
Done.
| |
23 profile_(profile), | |
24 policy_manager_(policy_manager) { | |
25 DCHECK(profile); | |
26 | |
27 // Register for notification that profile creation is complete. | |
28 registrar_.Add(this, | |
29 chrome::NOTIFICATION_PROFILE_ADDED, | |
30 content::Source<Profile>(profile)); | |
31 } | |
32 | |
33 void UserCloudPolicyInvalidator::Shutdown() { | |
34 CloudPolicyInvalidator::Shutdown(); | |
35 } | |
36 | |
37 void UserCloudPolicyInvalidator::Observe( | |
38 int type, | |
39 const content::NotificationSource& source, | |
40 const content::NotificationDetails& details) { | |
41 // Initialize the invalidator now that profile creation is complete. | |
42 DCHECK(type == chrome::NOTIFICATION_PROFILE_ADDED); | |
43 void (CloudPolicyInvalidator::*initialize)(Profile*) = | |
44 &CloudPolicyInvalidator::Initialize; | |
Joao da Silva
2013/07/29 19:44:32
Rename
Steve Condie
2013/07/29 20:44:51
Done.
| |
45 policy_manager_->EnableInvalidations( | |
46 base::Bind( | |
47 initialize, | |
48 base::Unretained(this), | |
Joao da Silva
2013/07/29 19:44:32
This should be a WeakPtr, because |this| might hav
Steve Condie
2013/07/29 20:44:51
Done.
| |
49 base::Unretained(profile_))); | |
Joao da Silva
2013/07/29 19:44:32
This is fine though; if the WeakPtr is invalidated
Steve Condie
2013/07/29 20:44:51
Done.
| |
50 } | |
51 | |
52 } // namespace policy | |
OLD | NEW |