Roll src/third_party/WebKit d9c6159:8139f33 (svn 201974:201975)
[chromium-blink-merge.git] / chrome / browser / chromeos / policy / remote_commands / affiliated_remote_commands_invalidator.cc
blob63bb35a991797f909f1adbeb4d0390425ec7f99c
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"
9 namespace policy {
11 AffiliatedRemoteCommandsInvalidator::AffiliatedRemoteCommandsInvalidator(
12 CloudPolicyCore* core,
13 AffiliatedInvalidationServiceProvider* invalidation_service_provider)
14 : core_(core),
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.
26 if (invalidator_) {
27 invalidator_->Shutdown();
28 invalidator_.reset();
30 // Create a new one if required.
31 if (invalidation_service) {
32 invalidator_.reset(new RemoteCommandsInvalidatorImpl(core_));
33 invalidator_->Initialize(invalidation_service);
37 } // namespace policy