Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / content / browser / android / java / java_bridge_thread.cc
bloba221527b564f6a149b3fe48296e7a5fb610d9a19
1 // Copyright 2015 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.
5 #include "content/browser/android/java/java_bridge_thread.h"
7 #include "base/lazy_instance.h"
8 #include "base/message_loop/message_loop.h"
9 #include "base/task_runner_util.h"
11 #if !defined(OS_ANDROID)
12 #error "JavaBridge only supports OS_ANDROID"
13 #endif
15 namespace content {
17 namespace {
19 base::LazyInstance<JavaBridgeThread> g_background_thread =
20 LAZY_INSTANCE_INITIALIZER;
22 } // namespace
24 JavaBridgeThread::JavaBridgeThread()
25 : base::android::JavaHandlerThread("JavaBridge") {
26 Start();
29 JavaBridgeThread::~JavaBridgeThread() {
30 Stop();
33 // static
34 bool JavaBridgeThread::CurrentlyOn() {
35 return base::MessageLoop::current() ==
36 g_background_thread.Get().message_loop();
39 // static
40 base::TaskRunner* JavaBridgeThread::GetTaskRunner() {
41 return g_background_thread.Get().message_loop()->task_runner().get();
44 } // namespace content