Chromium Code Reviews| Index: chrome/browser/policy/cloud/user_cloud_policy_invalidator.cc |
| diff --git a/chrome/browser/policy/cloud/user_cloud_policy_invalidator.cc b/chrome/browser/policy/cloud/user_cloud_policy_invalidator.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..bd90334f98fc82c790e8403c690aeb6fa9365466 |
| --- /dev/null |
| +++ b/chrome/browser/policy/cloud/user_cloud_policy_invalidator.cc |
| @@ -0,0 +1,52 @@ |
| +// Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chrome/browser/policy/cloud/user_cloud_policy_invalidator.h" |
| + |
| +#include "base/bind.h" |
| +#include "base/message_loop/message_loop.h" |
| +#include "chrome/browser/chrome_notification_types.h" |
| +#include "chrome/browser/policy/cloud/cloud_policy_core.h" |
| +#include "chrome/browser/policy/cloud/cloud_policy_manager.h" |
| +#include "content/public/browser/notification_source.h" |
| + |
| +namespace policy { |
| + |
| +UserCloudPolicyInvalidator::UserCloudPolicyInvalidator( |
| + Profile* profile, |
| + CloudPolicyManager* policy_manager) |
| + : CloudPolicyInvalidator( |
| + policy_manager, |
| + policy_manager->core()->store(), |
| + 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.
|
| + profile_(profile), |
| + policy_manager_(policy_manager) { |
| + DCHECK(profile); |
| + |
| + // Register for notification that profile creation is complete. |
| + registrar_.Add(this, |
| + chrome::NOTIFICATION_PROFILE_ADDED, |
| + content::Source<Profile>(profile)); |
| +} |
| + |
| +void UserCloudPolicyInvalidator::Shutdown() { |
| + CloudPolicyInvalidator::Shutdown(); |
| +} |
| + |
| +void UserCloudPolicyInvalidator::Observe( |
| + int type, |
| + const content::NotificationSource& source, |
| + const content::NotificationDetails& details) { |
| + // Initialize the invalidator now that profile creation is complete. |
| + DCHECK(type == chrome::NOTIFICATION_PROFILE_ADDED); |
| + void (CloudPolicyInvalidator::*initialize)(Profile*) = |
| + &CloudPolicyInvalidator::Initialize; |
|
Joao da Silva
2013/07/29 19:44:32
Rename
Steve Condie
2013/07/29 20:44:51
Done.
|
| + policy_manager_->EnableInvalidations( |
| + base::Bind( |
| + initialize, |
| + 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.
|
| + 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.
|
| +} |
| + |
| +} // namespace policy |