Chromium Code Reviews| 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. | |
| 29 // TODO(stepco): Investigate if we can update the invalidation service such | |
|
Mattias Nissler (ping if slow)
2013/09/05 14:54:04
OK, thanks for the stack trace. It turns out that
Steve Condie
2013/09/06 06:23:05
Thanks for looking into that and finding the exist
| |
| 30 // that it can be used immediately. | |
| 28 registrar_.Add(this, | 31 registrar_.Add(this, |
| 29 chrome::NOTIFICATION_PROFILE_ADDED, | 32 chrome::NOTIFICATION_PROFILE_ADDED, |
| 30 content::Source<Profile>(profile)); | 33 content::Source<Profile>(profile)); |
| 31 } | 34 } |
| 32 | 35 |
| 33 void UserCloudPolicyInvalidator::Shutdown() { | 36 void UserCloudPolicyInvalidator::Shutdown() { |
| 34 CloudPolicyInvalidator::Shutdown(); | 37 CloudPolicyInvalidator::Shutdown(); |
| 35 } | 38 } |
| 36 | 39 |
| 37 void UserCloudPolicyInvalidator::Observe( | 40 void UserCloudPolicyInvalidator::Observe( |
| 38 int type, | 41 int type, |
| 39 const content::NotificationSource& source, | 42 const content::NotificationSource& source, |
| 40 const content::NotificationDetails& details) { | 43 const content::NotificationDetails& details) { |
| 41 // Enable invalidations now that profile creation is complete. | 44 // Initialize now that profile creation is complete and the invalidation |
| 45 // service can safely be initialized. | |
| 42 DCHECK(type == chrome::NOTIFICATION_PROFILE_ADDED); | 46 DCHECK(type == chrome::NOTIFICATION_PROFILE_ADDED); |
| 43 policy_manager_->EnableInvalidations( | 47 Initialize(base::Bind( |
| 44 base::Bind( | 48 &invalidation::InvalidationServiceFactory::GetForProfile, |
|
Mattias Nissler (ping if slow)
2013/09/05 14:54:04
I guess you could just call GetForProfile here and
Steve Condie
2013/09/06 06:23:05
Since the invalidation service is initialized when
Mattias Nissler (ping if slow)
2013/09/06 08:51:54
Other consumers (such as the push messaging extens
Steve Condie
2013/09/06 18:01:40
Done.
| |
| 45 &CloudPolicyInvalidator::InitializeWithProfile, | 49 base::Unretained(profile_))); |
| 46 GetWeakPtr(), | |
| 47 base::Unretained(profile_))); | |
| 48 } | 50 } |
| 49 | 51 |
| 50 } // namespace policy | 52 } // namespace policy |
| OLD | NEW |