| Index: chrome/browser/chromeos/policy/remote_commands/remote_commands_invalidator.cc
|
| diff --git a/chrome/browser/chromeos/policy/remote_commands/remote_commands_invalidator.cc b/chrome/browser/chromeos/policy/remote_commands/remote_commands_invalidator.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..a165a0b1464a0f425f361336424738ef732c1706
|
| --- /dev/null
|
| +++ b/chrome/browser/chromeos/policy/remote_commands/remote_commands_invalidator.cc
|
| @@ -0,0 +1,92 @@
|
| +// 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/remote_commands_invalidator.h"
|
| +
|
| +#include "base/logging.h"
|
| +#include "base/thread_task_runner_handle.h"
|
| +#include "components/policy/core/common/remote_commands/remote_commands_service.h"
|
| +
|
| +namespace policy {
|
| +
|
| +RemoteCommandsInvalidator::RemoteCommandsInvalidator(CloudPolicyCore* core)
|
| + : RemoteCommandsInvalidatorBase(base::ThreadTaskRunnerHandle::Get()),
|
| + core_(core) {
|
| + DCHECK(core_);
|
| +}
|
| +
|
| +void RemoteCommandsInvalidator::OnInitialize() {
|
| + core_->AddObserver(this);
|
| + if (core_->remote_commands_service())
|
| + OnRemoteCommandsServiceStarted(core_);
|
| +}
|
| +
|
| +void RemoteCommandsInvalidator::OnShutdown() {
|
| + core_->RemoveObserver(this);
|
| +}
|
| +
|
| +void RemoteCommandsInvalidator::OnStart() {
|
| + core_->store()->AddObserver(this);
|
| + OnStoreLoaded(core_->store());
|
| +}
|
| +
|
| +void RemoteCommandsInvalidator::OnStop() {
|
| + core_->store()->RemoveObserver(this);
|
| +}
|
| +
|
| +void RemoteCommandsInvalidator::DoRemoteCommandsFetch() {
|
| + DCHECK(core_->remote_commands_service());
|
| + core_->remote_commands_service()->FetchRemoteCommands();
|
| +}
|
| +
|
| +void RemoteCommandsInvalidator::OnCoreConnected(CloudPolicyCore* core) {
|
| +}
|
| +
|
| +void RemoteCommandsInvalidator::OnRefreshSchedulerStarted(
|
| + CloudPolicyCore* core) {
|
| +}
|
| +
|
| +void RemoteCommandsInvalidator::OnCoreDisconnecting(CloudPolicyCore* core) {
|
| + Stop();
|
| +}
|
| +
|
| +void RemoteCommandsInvalidator::OnRemoteCommandsServiceStarted(
|
| + CloudPolicyCore* core) {
|
| + Start();
|
| +}
|
| +
|
| +void RemoteCommandsInvalidator::OnStoreLoaded(CloudPolicyStore* core) {
|
| + ReloadPolicyData(core_->store()->policy());
|
| +}
|
| +
|
| +void RemoteCommandsInvalidator::OnStoreError(CloudPolicyStore* core) {
|
| +}
|
| +
|
| +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 RemoteCommandsInvalidator(core_));
|
| + invalidator_->Initialize(invalidation_service);
|
| + }
|
| +}
|
| +
|
| +} // namespace policy
|
|
|