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

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

Issue 2165643004: arc: add enterprise_reporting.mojom interface. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed. 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
« no previous file with comments | « chrome/browser/chromeos/arc/arc_watchdog_service.h ('k') | chrome/chrome_browser_chromeos.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/arc/arc_watchdog_service.cc
diff --git a/chrome/browser/chromeos/arc/arc_watchdog_service.cc b/chrome/browser/chromeos/arc/arc_watchdog_service.cc
new file mode 100644
index 0000000000000000000000000000000000000000..0425f5bfb4d221e2a5015cdb80e79917afd9d8bc
--- /dev/null
+++ b/chrome/browser/chromeos/arc/arc_watchdog_service.cc
@@ -0,0 +1,50 @@
+// 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_watchdog_service.h"
+
+#include "base/bind.h"
+#include "chrome/browser/chromeos/arc/arc_auth_service.h"
+#include "content/public/browser/browser_thread.h"
+
+namespace arc {
+
+ArcWatchdogService::ArcWatchdogService(ArcBridgeService* bridge_service)
+ : ArcService(bridge_service), binding_(this), weak_factory_(this) {
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+ arc_bridge_service()->AddObserver(this);
+ arc_bridge_service()->watchdog()->AddObserver(this);
+}
+
+ArcWatchdogService::~ArcWatchdogService() {
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+
+ arc_bridge_service()->watchdog()->RemoveObserver(this);
+ arc_bridge_service()->RemoveObserver(this);
+}
+
+void ArcWatchdogService::OnInstanceReady() {
+ arc_bridge_service()->watchdog()->instance()->Init(
+ binding_.CreateInterfacePtrAndBind());
+}
+
+void ArcWatchdogService::OnBridgeStopped(ArcBridgeService::StopReason reason) {
+ if (restart_required_) {
+ content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE,
+ base::Bind(&ArcWatchdogService::RestartArc,
+ weak_factory_.GetWeakPtr()));
uekawa- 2016/07/21 11:55:38 is it safe to immediately restart ? I recall there
Polina Bondarenko 2016/07/22 08:16:54 Fixed a CL, but the call, that you're talking abou
+ }
+}
+
+void ArcWatchdogService::ClearArcData() {
+ restart_required_ = true;
+ ArcAuthService::Get()->StopArc();
+}
+
+void ArcWatchdogService::RestartArc() {
+ restart_required_ = false;
+ ArcAuthService::Get()->RestartArc();
+}
+
+} // namespace arc
« no previous file with comments | « chrome/browser/chromeos/arc/arc_watchdog_service.h ('k') | chrome/chrome_browser_chromeos.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698