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.
5 #include "chrome/browser/chromeos/policy/remote_commands/affiliated_remote_commands_invalidator.h"
7 #include "chrome/browser/policy/cloud/remote_commands_invalidator_impl.h"
11 AffiliatedRemoteCommandsInvalidator::AffiliatedRemoteCommandsInvalidator(
12 CloudPolicyCore
* core
,
13 AffiliatedInvalidationServiceProvider
* invalidation_service_provider
)
15 invalidation_service_provider_(invalidation_service_provider
) {
16 invalidation_service_provider_
->RegisterConsumer(this);
19 AffiliatedRemoteCommandsInvalidator::~AffiliatedRemoteCommandsInvalidator() {
20 invalidation_service_provider_
->UnregisterConsumer(this);
23 void AffiliatedRemoteCommandsInvalidator::OnInvalidationServiceSet(
24 invalidation::InvalidationService
* invalidation_service
) {
25 // Destroy this invalidator if it exists.
27 invalidator_
->Shutdown();
30 // Create a new one if required.
31 if (invalidation_service
) {
32 invalidator_
.reset(new RemoteCommandsInvalidatorImpl(core_
));
33 invalidator_
->Initialize(invalidation_service
);