Chromium Code Reviews| Index: chrome/browser/chromeos/policy/remote_commands/affiliated_remote_commands_invalidator.cc |
| diff --git a/chrome/browser/chromeos/policy/remote_commands/affiliated_remote_commands_invalidator.cc b/chrome/browser/chromeos/policy/remote_commands/affiliated_remote_commands_invalidator.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..f901e38e423fe7b04f4cd0ee3df9216afefa0cb5 |
| --- /dev/null |
| +++ b/chrome/browser/chromeos/policy/remote_commands/affiliated_remote_commands_invalidator.cc |
| @@ -0,0 +1,39 @@ |
| +// Copyright 2015 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/chromeos/policy/remote_commands/affiliated_remote_commands_invalidator.h" |
| + |
| +#include "base/logging.h" |
|
bartfab (slow)
2015/05/15 15:55:08
Nit: Not used.
binjin
2015/05/15 16:12:40
Done.
|
| +#include "base/thread_task_runner_handle.h" |
|
bartfab (slow)
2015/05/15 15:55:08
Nit: Not used.
binjin
2015/05/15 16:12:40
Done.
|
| +#include "components/policy/core/common/remote_commands/remote_commands_service.h" |
|
bartfab (slow)
2015/05/15 15:55:08
Nit: Not used.
binjin
2015/05/15 16:12:40
Done.
|
| + |
| +namespace policy { |
| + |
| +AffiliatedRemoteCommandsInvalidator::AffiliatedRemoteCommandsInvalidator( |
| + CloudPolicyCore* core, |
| + AffiliatedInvalidationServiceProvider* invalidation_service_provider) |
| + : core_(core), |
| + invalidation_service_provider_(invalidation_service_provider) { |
| + invalidation_service_provider_->RegisterConsumer(this); |
| +} |
| + |
| +AffiliatedRemoteCommandsInvalidator::~AffiliatedRemoteCommandsInvalidator() { |
| + invalidation_service_provider_->UnregisterConsumer(this); |
| +} |
| + |
| +void AffiliatedRemoteCommandsInvalidator::OnInvalidationServiceSet( |
| + invalidation::InvalidationService* invalidation_service) { |
| + // Destroy this invalidator if it exists. |
| + if (invalidator_) { |
| + invalidator_->Shutdown(); |
| + invalidator_.reset(); |
| + } |
| + // Create a new one if required. |
| + if (invalidation_service) { |
| + invalidator_.reset(new RemoteCommandsInvalidatorImpl(core_)); |
| + invalidator_->Initialize(invalidation_service); |
| + } |
| +} |
| + |
| +} // namespace policy |