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

Unified Diff: components/arc/arc_service_manager.cc

Issue 1496193002: arc: Add ArcServiceManager to own all future ARC services (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: readded file Created 5 years 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 | « components/arc/arc_service_manager.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/arc/arc_service_manager.cc
diff --git a/components/arc/arc_service_manager.cc b/components/arc/arc_service_manager.cc
new file mode 100644
index 0000000000000000000000000000000000000000..57c8da2f29e49b12a82e097856ce7e6120384cf7
--- /dev/null
+++ b/components/arc/arc_service_manager.cc
@@ -0,0 +1,49 @@
+// 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_service_impl.h"
+
+namespace arc {
+
+namespace {
+
+// Weak pointer. This class is owned by ChromeBrowserMainPartsChromeos.
+ArcServiceManager* g_arc_service_manager = nullptr;
+
+} // namespace
+
+ArcServiceManager::ArcServiceManager(
+ const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner,
+ const scoped_refptr<base::SequencedTaskRunner>& file_task_runner)
+ : origin_task_runner_(base::ThreadTaskRunnerHandle::Get()),
+ arc_bridge_service_(
+ new ArcBridgeServiceImpl(io_task_runner, file_task_runner)) {
+ DCHECK(!g_arc_service_manager);
+ g_arc_service_manager = this;
+}
+
+ArcServiceManager::~ArcServiceManager() {
+ DCHECK(origin_task_runner_->RunsTasksOnCurrentThread());
+ DCHECK(g_arc_service_manager == this);
+ g_arc_service_manager = nullptr;
+}
+
+// static
+ArcServiceManager* ArcServiceManager::Get() {
+ DCHECK(
+ g_arc_service_manager->origin_task_runner_->RunsTasksOnCurrentThread());
+ DCHECK(g_arc_service_manager);
+ return g_arc_service_manager;
+}
+
+ArcBridgeService* ArcServiceManager::arc_bridge_service() {
+ DCHECK(origin_task_runner_->RunsTasksOnCurrentThread());
+ return arc_bridge_service_.get();
+}
+
+} // namespace arc
« no previous file with comments | « components/arc/arc_service_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698