| Index: chrome/browser/chromeos/arc/arc_user_data_host.cc
|
| diff --git a/chrome/browser/chromeos/arc/arc_user_data_host.cc b/chrome/browser/chromeos/arc/arc_user_data_host.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..285a9ffdec04b80c83a2a6b181b4d09bca3502d3
|
| --- /dev/null
|
| +++ b/chrome/browser/chromeos/arc/arc_user_data_host.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_user_data_host.h"
|
| +
|
| +#include "base/bind.h"
|
| +#include "chrome/browser/chromeos/arc/arc_auth_service.h"
|
| +#include "content/public/browser/browser_thread.h"
|
| +
|
| +namespace arc {
|
| +
|
| +ArcUserDataHost::ArcUserDataHost(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()->user_data()->AddObserver(this);
|
| +}
|
| +
|
| +ArcUserDataHost::~ArcUserDataHost() {
|
| + DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
|
| +
|
| + arc_bridge_service()->user_data()->RemoveObserver(this);
|
| + arc_bridge_service()->RemoveObserver(this);
|
| +}
|
| +
|
| +void ArcUserDataHost::OnInstanceReady() {
|
| + arc_bridge_service()->user_data()->instance()->Init(
|
| + binding_.CreateInterfacePtrAndBind());
|
| +}
|
| +
|
| +void ArcUserDataHost::OnBridgeStopped(ArcBridgeService::StopReason reason) {
|
| + if (restart_required_) {
|
| + content::BrowserThread::PostTask(
|
| + content::BrowserThread::UI, FROM_HERE,
|
| + base::Bind(&ArcUserDataHost::RestartArc, weak_factory_.GetWeakPtr()));
|
| + }
|
| +}
|
| +
|
| +void ArcUserDataHost::ClearArcData() {
|
| + restart_required_ = true;
|
| + ArcAuthService::Get()->StopArcAndWipeData();
|
| +}
|
| +
|
| +void ArcUserDataHost::RestartArc() {
|
| + restart_required_ = false;
|
| + ArcAuthService::Get()->RestartArc();
|
| +}
|
| +
|
| +} // namespace arc
|
|
|