OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "chrome/browser/chromeos/arc/arc_watchdog_service.h" | |
6 | |
7 #include "base/bind.h" | |
8 #include "chrome/browser/chromeos/arc/arc_auth_service.h" | |
9 #include "content/public/browser/browser_thread.h" | |
10 | |
11 namespace arc { | |
12 | |
13 ArcWatchdogService::ArcWatchdogService(ArcBridgeService* bridge_service) | |
14 : ArcService(bridge_service), binding_(this), weak_factory_(this) { | |
15 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | |
16 arc_bridge_service()->AddObserver(this); | |
17 arc_bridge_service()->watchdog()->AddObserver(this); | |
18 } | |
19 | |
20 ArcWatchdogService::~ArcWatchdogService() { | |
21 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | |
22 | |
23 arc_bridge_service()->watchdog()->RemoveObserver(this); | |
24 arc_bridge_service()->RemoveObserver(this); | |
25 } | |
26 | |
27 void ArcWatchdogService::OnInstanceReady() { | |
28 arc_bridge_service()->watchdog()->instance()->Init( | |
29 binding_.CreateInterfacePtrAndBind()); | |
30 } | |
31 | |
32 void ArcWatchdogService::OnBridgeStopped(ArcBridgeService::StopReason reason) { | |
33 if (restart_required_) { | |
34 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, | |
35 base::Bind(&ArcWatchdogService::RestartArc, | |
36 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
| |
37 } | |
38 } | |
39 | |
40 void ArcWatchdogService::ClearArcData() { | |
41 restart_required_ = true; | |
42 ArcAuthService::Get()->StopArc(); | |
43 } | |
44 | |
45 void ArcWatchdogService::RestartArc() { | |
46 restart_required_ = false; | |
47 ArcAuthService::Get()->RestartArc(); | |
48 } | |
49 | |
50 } // namespace arc | |
OLD | NEW |