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

Side by Side Diff: content/browser/android/java/java_bridge_thread.cc

Issue 2116643002: Revert of Remove calls to MessageLoop::current() in content. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 months 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 unified diff | Download patch
« no previous file with comments | « no previous file | content/browser/appcache/appcache_request_handler_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/android/java/java_bridge_thread.h" 5 #include "content/browser/android/java/java_bridge_thread.h"
6 6
7 #include "base/lazy_instance.h" 7 #include "base/lazy_instance.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/single_thread_task_runner.h"
10 #include "base/task_runner_util.h" 9 #include "base/task_runner_util.h"
11 #include "build/build_config.h" 10 #include "build/build_config.h"
12 11
13 #if !defined(OS_ANDROID) 12 #if !defined(OS_ANDROID)
14 #error "JavaBridge only supports OS_ANDROID" 13 #error "JavaBridge only supports OS_ANDROID"
15 #endif 14 #endif
16 15
17 namespace content { 16 namespace content {
18 17
19 namespace { 18 namespace {
20 19
21 base::LazyInstance<JavaBridgeThread> g_background_thread = 20 base::LazyInstance<JavaBridgeThread> g_background_thread =
22 LAZY_INSTANCE_INITIALIZER; 21 LAZY_INSTANCE_INITIALIZER;
23 22
24 } // namespace 23 } // namespace
25 24
26 JavaBridgeThread::JavaBridgeThread() 25 JavaBridgeThread::JavaBridgeThread()
27 : base::android::JavaHandlerThread("JavaBridge") { 26 : base::android::JavaHandlerThread("JavaBridge") {
28 Start(); 27 Start();
29 } 28 }
30 29
31 JavaBridgeThread::~JavaBridgeThread() { 30 JavaBridgeThread::~JavaBridgeThread() {
32 Stop(); 31 Stop();
33 } 32 }
34 33
35 // static 34 // static
36 bool JavaBridgeThread::CurrentlyOn() { 35 bool JavaBridgeThread::CurrentlyOn() {
37 return g_background_thread.Get() 36 return base::MessageLoop::current() ==
38 .message_loop() 37 g_background_thread.Get().message_loop();
39 ->task_runner()
40 ->BelongsToCurrentThread();
41 } 38 }
42 39
43 // static 40 // static
44 base::TaskRunner* JavaBridgeThread::GetTaskRunner() { 41 base::TaskRunner* JavaBridgeThread::GetTaskRunner() {
45 return g_background_thread.Get().message_loop()->task_runner().get(); 42 return g_background_thread.Get().message_loop()->task_runner().get();
46 } 43 }
47 44
48 } // namespace content 45 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/appcache/appcache_request_handler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698