OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 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/chromeos/policy/remote_commands/affiliated_remote_comma
nds_invalidator.h" |
| 6 |
| 7 #include "base/logging.h" |
| 8 #include "base/thread_task_runner_handle.h" |
| 9 #include "components/policy/core/common/remote_commands/remote_commands_service.
h" |
| 10 |
| 11 namespace policy { |
| 12 |
| 13 AffiliatedRemoteCommandsInvalidator::AffiliatedRemoteCommandsInvalidator( |
| 14 CloudPolicyCore* core, |
| 15 AffiliatedInvalidationServiceProvider* invalidation_service_provider) |
| 16 : core_(core), |
| 17 invalidation_service_provider_(invalidation_service_provider) { |
| 18 invalidation_service_provider_->RegisterConsumer(this); |
| 19 } |
| 20 |
| 21 AffiliatedRemoteCommandsInvalidator::~AffiliatedRemoteCommandsInvalidator() { |
| 22 invalidation_service_provider_->UnregisterConsumer(this); |
| 23 } |
| 24 |
| 25 void AffiliatedRemoteCommandsInvalidator::OnInvalidationServiceSet( |
| 26 invalidation::InvalidationService* invalidation_service) { |
| 27 // Destroy this invalidator if it exists. |
| 28 if (invalidator_) { |
| 29 invalidator_->Shutdown(); |
| 30 invalidator_.reset(); |
| 31 } |
| 32 // Create a new one if required. |
| 33 if (invalidation_service) { |
| 34 invalidator_.reset(new RemoteCommandsInvalidatorImpl(core_)); |
| 35 invalidator_->Initialize(invalidation_service); |
| 36 } |
| 37 } |
| 38 |
| 39 } // namespace policy |
OLD | NEW |