Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(70)

Unified Diff: chrome/browser/chromeos/arc/arc_enterprise_reporting_service.cc

Issue 2195653002: arc: add enterprise_reporting.mojom interface. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2785
Patch Set: Corrected upstream branch. Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/arc/arc_enterprise_reporting_service.cc
diff --git a/chrome/browser/chromeos/arc/arc_enterprise_reporting_service.cc b/chrome/browser/chromeos/arc/arc_enterprise_reporting_service.cc
new file mode 100644
index 0000000000000000000000000000000000000000..47babc73befea5aab51591e2da828ba3027f9aa3
--- /dev/null
+++ b/chrome/browser/chromeos/arc/arc_enterprise_reporting_service.cc
@@ -0,0 +1,59 @@
+// Copyright 2016 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/arc/arc_enterprise_reporting_service.h"
+
+#include <utility>
+
+#include "base/bind.h"
+#include "base/logging.h"
+#include "chrome/browser/chromeos/arc/arc_auth_service.h"
+#include "components/arc/arc_service_manager.h"
+#include "components/arc/user_data/arc_user_data_service.h"
+
+namespace arc {
+
+ArcEnterpriseReportingService::ArcEnterpriseReportingService(
+ ArcBridgeService* bridge_service)
+ : ArcService(bridge_service), binding_(this), weak_ptr_factory_(this) {
+ arc_bridge_service()->enterprise_reporting()->AddObserver(this);
+}
+
+ArcEnterpriseReportingService::~ArcEnterpriseReportingService() {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ arc_bridge_service()->enterprise_reporting()->RemoveObserver(this);
+}
+
+void ArcEnterpriseReportingService::OnInstanceReady() {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ arc_bridge_service()->enterprise_reporting()->instance()->Init(
+ binding_.CreateInterfacePtrAndBind());
+}
+
+void ArcEnterpriseReportingService::ReportManagementState(
+ mojom::ManagementState state) {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ VLOG(1) << "ReportManagementState state=" << state;
+
+ if (state == mojom::ManagementState::MANAGED_DO_LOST) {
+ DCHECK(arc::ArcServiceManager::Get());
+ ArcServiceManager::Get()->arc_user_data_service()->RequireUserDataWiped(
+ base::Bind(&ArcEnterpriseReportingService::RestartArc,
+ weak_ptr_factory_.GetWeakPtr()));
+ ArcAuthService::Get()->StopArc();
+ }
+}
+
+void ArcEnterpriseReportingService::RestartArc(bool result) {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ if (!result)
+ LOG(ERROR) << "Required ARC user data wipe failed.";
+
+ // Restart ARC anyway. Let the enterprise reporting instance decide whether
+ // the ARC user data wipe is still required or not.
+ VLOG(1) << "Restart ARC";
+ ArcAuthService::Get()->EnableArc();
+}
+
+} // namespace arc
« no previous file with comments | « chrome/browser/chromeos/arc/arc_enterprise_reporting_service.h ('k') | chrome/browser/chromeos/arc/arc_service_launcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698