Chromium Code Reviews| 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/remote_commands_invalid ator.h" | |
| 6 | |
| 7 #include "base/logging.h" | |
| 8 #include "base/thread_task_runner_handle.h" | |
| 9 #include "components/policy/core/common/cloud/cloud_policy_core.h" | |
|
bartfab (slow)
2015/05/15 13:28:07
Nit: Already included by header.
binjin
2015/05/15 14:50:38
Done.
| |
| 10 #include "components/policy/core/common/remote_commands/remote_commands_service. h" | |
| 11 | |
| 12 namespace policy { | |
| 13 | |
| 14 RemoteCommandsInvalidator::RemoteCommandsInvalidator(CloudPolicyCore* core) | |
| 15 : RemoteCommandsInvalidatorBase(base::ThreadTaskRunnerHandle::Get()), | |
| 16 core_(core) { | |
| 17 DCHECK(core_); | |
| 18 } | |
| 19 | |
| 20 RemoteCommandsInvalidator::~RemoteCommandsInvalidator() { | |
|
bartfab (slow)
2015/05/15 13:28:07
Nit: No need to override the destructor if you are
binjin
2015/05/15 14:50:38
Done.
| |
| 21 } | |
| 22 | |
| 23 void RemoteCommandsInvalidator::OnInitialize() { | |
| 24 core_->AddObserver(this); | |
| 25 if (core_->remote_commands_service()) | |
| 26 OnRemoteCommandsServiceStarted(core_); | |
| 27 } | |
| 28 | |
| 29 void RemoteCommandsInvalidator::OnShutdown() { | |
| 30 core_->RemoveObserver(this); | |
| 31 } | |
| 32 | |
| 33 void RemoteCommandsInvalidator::OnStart() { | |
| 34 OnStoreLoaded(core_->store()); | |
| 35 core_->store()->AddObserver(this); | |
|
bartfab (slow)
2015/05/15 13:28:07
Nit: Here, you simulate an event one-off and then
binjin
2015/05/15 14:50:38
Done.
| |
| 36 } | |
| 37 | |
| 38 void RemoteCommandsInvalidator::OnStop() { | |
| 39 core_->store()->RemoveObserver(this); | |
| 40 } | |
| 41 | |
| 42 void RemoteCommandsInvalidator::DoRemoteCommandsFetch() { | |
| 43 DCHECK(core_->remote_commands_service()); | |
| 44 core_->remote_commands_service()->FetchRemoteCommands(); | |
| 45 } | |
| 46 | |
| 47 void RemoteCommandsInvalidator::OnCoreConnected(CloudPolicyCore* core) { | |
| 48 } | |
| 49 | |
| 50 void RemoteCommandsInvalidator::OnRefreshSchedulerStarted( | |
| 51 CloudPolicyCore* core) { | |
| 52 } | |
| 53 | |
| 54 void RemoteCommandsInvalidator::OnCoreDisconnecting(CloudPolicyCore* core) { | |
| 55 Stop(); | |
| 56 } | |
| 57 | |
| 58 void RemoteCommandsInvalidator::OnRemoteCommandsServiceStarted( | |
| 59 CloudPolicyCore* core) { | |
| 60 Start(); | |
| 61 } | |
| 62 | |
| 63 void RemoteCommandsInvalidator::OnStoreLoaded(CloudPolicyStore* core) { | |
| 64 ReloadPolicyData(core_->store()->policy()); | |
| 65 } | |
| 66 | |
| 67 void RemoteCommandsInvalidator::OnStoreError(CloudPolicyStore* core) { | |
| 68 } | |
| 69 | |
| 70 AffiliatedRemoteCommandsInvalidator::AffiliatedRemoteCommandsInvalidator( | |
| 71 CloudPolicyCore* core, | |
| 72 AffiliatedInvalidationServiceProvider* invalidation_service_provider) | |
| 73 : core_(core), | |
| 74 invalidation_service_provider_(invalidation_service_provider) { | |
| 75 invalidation_service_provider_->RegisterConsumer(this); | |
| 76 } | |
| 77 | |
| 78 AffiliatedRemoteCommandsInvalidator::~AffiliatedRemoteCommandsInvalidator() { | |
| 79 invalidation_service_provider_->UnregisterConsumer(this); | |
| 80 } | |
| 81 | |
| 82 void AffiliatedRemoteCommandsInvalidator::OnInvalidationServiceSet( | |
| 83 invalidation::InvalidationService* invalidation_service) { | |
| 84 DestroyInvalidator(); | |
| 85 if (invalidation_service) | |
| 86 CreateInvalidator(invalidation_service); | |
| 87 } | |
| 88 | |
| 89 void AffiliatedRemoteCommandsInvalidator::CreateInvalidator( | |
| 90 invalidation::InvalidationService* invalidation_service) { | |
| 91 DCHECK(!invalidator_); | |
|
bartfab (slow)
2015/05/15 13:28:07
Nit: You can easily fold this method into OnInvali
binjin
2015/05/15 14:50:38
Done.
| |
| 92 invalidator_.reset(new RemoteCommandsInvalidator(core_)); | |
| 93 invalidator_->Initialize(invalidation_service); | |
| 94 } | |
| 95 | |
| 96 void AffiliatedRemoteCommandsInvalidator::DestroyInvalidator() { | |
| 97 if (!invalidator_) | |
| 98 return; | |
| 99 invalidator_->Shutdown(); | |
| 100 invalidator_.reset(); | |
| 101 } | |
| 102 | |
| 103 } // namespace policy | |
| OLD | NEW |