blob: 2fc0e0014921e6df8a6c5293b06fb4a0dbd50701 [file] [log] [blame]
// Copyright 2015 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 "components/arc/arc_service_manager.h"
#include "base/sequenced_task_runner.h"
#include "base/thread_task_runner_handle.h"
#include "components/arc/arc_bridge_bootstrap.h"
#include "components/arc/arc_bridge_service_impl.h"
#include "components/arc/input/arc_input_bridge.h"
namespace arc {
namespace {
// Weak pointer. This class is owned by ChromeBrowserMainPartsChromeos.
ArcServiceManager* g_arc_service_manager = nullptr;
} // namespace
ArcServiceManager::ArcServiceManager()
: arc_bridge_service_(
new ArcBridgeServiceImpl(ArcBridgeBootstrap::Create())) {
DCHECK(!g_arc_service_manager);
arc_input_bridge_ = ArcInputBridge::Create(arc_bridge_service_.get());
g_arc_service_manager = this;
}
ArcServiceManager::~ArcServiceManager() {
DCHECK(thread_checker_.CalledOnValidThread());
DCHECK(g_arc_service_manager == this);
g_arc_service_manager = nullptr;
}
// static
ArcServiceManager* ArcServiceManager::Get() {
DCHECK(g_arc_service_manager);
DCHECK(g_arc_service_manager->thread_checker_.CalledOnValidThread());
return g_arc_service_manager;
}
ArcBridgeService* ArcServiceManager::arc_bridge_service() {
DCHECK(thread_checker_.CalledOnValidThread());
return arc_bridge_service_.get();
}
} // namespace arc