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 #include "chrome/browser/policy/cloud/user_cloud_policy_invalidator.h" | 5 #include "chrome/browser/policy/cloud/user_cloud_policy_invalidator.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/message_loop/message_loop_proxy.h" | 8 #include "base/message_loop/message_loop_proxy.h" |
9 #include "chrome/browser/chrome_notification_types.h" | 9 #include "chrome/browser/chrome_notification_types.h" |
10 #include "chrome/browser/policy/cloud/cloud_policy_core.h" | 10 #include "chrome/browser/invalidation/invalidation_service_factory.h" |
11 #include "chrome/browser/policy/cloud/cloud_policy_manager.h" | 11 #include "chrome/browser/policy/cloud/cloud_policy_manager.h" |
12 #include "content/public/browser/notification_source.h" | 12 #include "content/public/browser/notification_source.h" |
13 | 13 |
14 namespace policy { | 14 namespace policy { |
15 | 15 |
16 UserCloudPolicyInvalidator::UserCloudPolicyInvalidator( | 16 UserCloudPolicyInvalidator::UserCloudPolicyInvalidator( |
17 Profile* profile, | 17 Profile* profile, |
18 CloudPolicyManager* policy_manager) | 18 CloudPolicyManager* policy_manager) |
19 : CloudPolicyInvalidator( | 19 : CloudPolicyInvalidator( |
20 policy_manager, | 20 policy_manager->core(), |
21 policy_manager->core()->store(), | |
22 base::MessageLoopProxy::current()), | 21 base::MessageLoopProxy::current()), |
23 profile_(profile), | 22 profile_(profile) { |
24 policy_manager_(policy_manager) { | |
25 DCHECK(profile); | 23 DCHECK(profile); |
26 | 24 |
27 // Register for notification that profile creation is complete. | 25 // Register for notification that profile creation is complete. The |
26 // invalidator must not be initialized before then because the invalidation | |
27 // service cannot be started because it depends on components initialized | |
28 // after this object is instantiated. | |
Mattias Nissler (ping if slow)
2013/09/02 11:54:52
What are those? Shouldn't they be declared as depe
Steve Condie
2013/09/03 04:41:56
SSLConfigServiceManager::CreateDefaultManager must
| |
28 registrar_.Add(this, | 29 registrar_.Add(this, |
29 chrome::NOTIFICATION_PROFILE_ADDED, | 30 chrome::NOTIFICATION_PROFILE_ADDED, |
30 content::Source<Profile>(profile)); | 31 content::Source<Profile>(profile)); |
31 } | 32 } |
32 | 33 |
33 void UserCloudPolicyInvalidator::Shutdown() { | 34 void UserCloudPolicyInvalidator::Shutdown() { |
34 CloudPolicyInvalidator::Shutdown(); | 35 CloudPolicyInvalidator::Shutdown(); |
35 } | 36 } |
36 | 37 |
37 void UserCloudPolicyInvalidator::Observe( | 38 void UserCloudPolicyInvalidator::Observe( |
38 int type, | 39 int type, |
39 const content::NotificationSource& source, | 40 const content::NotificationSource& source, |
40 const content::NotificationDetails& details) { | 41 const content::NotificationDetails& details) { |
41 // Enable invalidations now that profile creation is complete. | 42 // Initialize now that profile creation is complete and the invalidation |
43 // service can safely be initialized. | |
42 DCHECK(type == chrome::NOTIFICATION_PROFILE_ADDED); | 44 DCHECK(type == chrome::NOTIFICATION_PROFILE_ADDED); |
43 policy_manager_->EnableInvalidations( | 45 Initialize(base::Bind( |
44 base::Bind( | 46 &invalidation::InvalidationServiceFactory::GetForProfile, |
45 &CloudPolicyInvalidator::InitializeWithProfile, | 47 base::Unretained(profile_))); |
46 GetWeakPtr(), | |
47 base::Unretained(profile_))); | |
48 } | 48 } |
49 | 49 |
50 } // namespace policy | 50 } // namespace policy |
OLD | NEW |