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

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

Issue 2733283002: Require explicit selection of traits for LazyInstance (Closed)
Patch Set: Created 3 years, 9 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
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" 9 #include "base/single_thread_task_runner.h"
10 #include "base/task_runner_util.h" 10 #include "base/task_runner_util.h"
11 #include "build/build_config.h" 11 #include "build/build_config.h"
12 12
13 #if !defined(OS_ANDROID) 13 #if !defined(OS_ANDROID)
14 #error "JavaBridge only supports OS_ANDROID" 14 #error "JavaBridge only supports OS_ANDROID"
15 #endif 15 #endif
16 16
17 namespace content { 17 namespace content {
18 18
19 namespace { 19 namespace {
20 20
21 base::LazyInstance<JavaBridgeThread> g_background_thread = 21 base::LazyInstance<JavaBridgeThread>::DestructorAtExit g_background_thread =
22 LAZY_INSTANCE_INITIALIZER; 22 LAZY_INSTANCE_INITIALIZER;
23 23
24 } // namespace 24 } // namespace
25 25
26 JavaBridgeThread::JavaBridgeThread() 26 JavaBridgeThread::JavaBridgeThread()
27 : base::android::JavaHandlerThread("JavaBridge") { 27 : base::android::JavaHandlerThread("JavaBridge") {
28 Start(); 28 Start();
29 } 29 }
30 30
31 JavaBridgeThread::~JavaBridgeThread() { 31 JavaBridgeThread::~JavaBridgeThread() {
32 Stop(); 32 Stop();
33 } 33 }
34 34
35 // static 35 // static
36 bool JavaBridgeThread::CurrentlyOn() { 36 bool JavaBridgeThread::CurrentlyOn() {
37 return g_background_thread.Get() 37 return g_background_thread.Get()
38 .message_loop() 38 .message_loop()
39 ->task_runner() 39 ->task_runner()
40 ->BelongsToCurrentThread(); 40 ->BelongsToCurrentThread();
41 } 41 }
42 42
43 // static 43 // static
44 base::TaskRunner* JavaBridgeThread::GetTaskRunner() { 44 base::TaskRunner* JavaBridgeThread::GetTaskRunner() {
45 return g_background_thread.Get().message_loop()->task_runner().get(); 45 return g_background_thread.Get().message_loop()->task_runner().get();
46 } 46 }
47 47
48 } // namespace content 48 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698