| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/chromeos/arc/enterprise/arc_enterprise_reporting_servic
e.h" | 5 #include "chrome/browser/chromeos/arc/enterprise/arc_enterprise_reporting_servic
e.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "chrome/browser/chromeos/arc/arc_session_manager.h" | 11 #include "chrome/browser/chromeos/arc/arc_session_manager.h" |
| 12 #include "components/arc/arc_bridge_service.h" | 12 #include "components/arc/arc_bridge_service.h" |
| 13 #include "components/arc/arc_service_manager.h" | 13 #include "components/arc/arc_service_manager.h" |
| 14 | 14 |
| 15 namespace arc { | 15 namespace arc { |
| 16 | 16 |
| 17 ArcEnterpriseReportingService::ArcEnterpriseReportingService( | 17 ArcEnterpriseReportingService::ArcEnterpriseReportingService( |
| 18 ArcBridgeService* bridge_service) | 18 ArcBridgeService* bridge_service) |
| 19 : ArcService(bridge_service), binding_(this), weak_ptr_factory_(this) { | 19 : ArcService(bridge_service), binding_(this), weak_ptr_factory_(this) { |
| 20 arc_bridge_service()->enterprise_reporting()->AddObserver(this); | 20 arc_bridge_service()->enterprise_reporting()->AddObserver(this); |
| 21 } | 21 } |
| 22 | 22 |
| 23 ArcEnterpriseReportingService::~ArcEnterpriseReportingService() { | 23 ArcEnterpriseReportingService::~ArcEnterpriseReportingService() { |
| 24 DCHECK(thread_checker_.CalledOnValidThread()); | 24 DCHECK(thread_checker_.CalledOnValidThread()); |
| 25 arc_bridge_service()->enterprise_reporting()->RemoveObserver(this); | 25 arc_bridge_service()->enterprise_reporting()->RemoveObserver(this); |
| 26 } | 26 } |
| 27 | 27 |
| 28 void ArcEnterpriseReportingService::OnInstanceReady() { | 28 void ArcEnterpriseReportingService::OnInstanceReady() { |
| 29 DCHECK(thread_checker_.CalledOnValidThread()); | 29 DCHECK(thread_checker_.CalledOnValidThread()); |
| 30 auto* instance = | 30 auto* instance = GET_INSTANCE_FOR_METHOD( |
| 31 arc_bridge_service()->enterprise_reporting()->GetInstanceForMethod( | 31 arc_bridge_service()->enterprise_reporting(), Init); |
| 32 "Init"); | |
| 33 DCHECK(instance); | 32 DCHECK(instance); |
| 34 instance->Init(binding_.CreateInterfacePtrAndBind()); | 33 instance->Init(binding_.CreateInterfacePtrAndBind()); |
| 35 } | 34 } |
| 36 | 35 |
| 37 void ArcEnterpriseReportingService::ReportManagementState( | 36 void ArcEnterpriseReportingService::ReportManagementState( |
| 38 mojom::ManagementState state) { | 37 mojom::ManagementState state) { |
| 39 DCHECK(thread_checker_.CalledOnValidThread()); | 38 DCHECK(thread_checker_.CalledOnValidThread()); |
| 40 VLOG(1) << "ReportManagementState state=" << state; | 39 VLOG(1) << "ReportManagementState state=" << state; |
| 41 | 40 |
| 42 if (state == mojom::ManagementState::MANAGED_DO_LOST) { | 41 if (state == mojom::ManagementState::MANAGED_DO_LOST) { |
| 43 DCHECK(ArcServiceManager::Get()); | 42 DCHECK(ArcServiceManager::Get()); |
| 44 ArcSessionManager::Get()->RemoveArcData(); | 43 ArcSessionManager::Get()->RemoveArcData(); |
| 45 ArcSessionManager::Get()->StopAndEnableArc(); | 44 ArcSessionManager::Get()->StopAndEnableArc(); |
| 46 } | 45 } |
| 47 } | 46 } |
| 48 | 47 |
| 49 } // namespace arc | 48 } // namespace arc |
| OLD | NEW |