OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "device/bluetooth/bluetooth_socket_thread.h" | 5 #include "device/bluetooth/bluetooth_socket_thread.h" |
6 | 6 |
7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
8 #include "base/sequenced_task_runner.h" | 8 #include "base/sequenced_task_runner.h" |
9 #include "base/threading/thread.h" | 9 #include "base/threading/thread.h" |
10 | 10 |
11 namespace device { | 11 namespace device { |
12 | 12 |
13 base::LazyInstance<scoped_refptr<BluetoothSocketThread> > g_instance = | 13 base::LazyInstance<scoped_refptr<BluetoothSocketThread>>::DestructorAtExit |
14 LAZY_INSTANCE_INITIALIZER; | 14 g_instance = LAZY_INSTANCE_INITIALIZER; |
15 | 15 |
16 // static | 16 // static |
17 scoped_refptr<BluetoothSocketThread> BluetoothSocketThread::Get() { | 17 scoped_refptr<BluetoothSocketThread> BluetoothSocketThread::Get() { |
18 if (!g_instance.Get().get()) { | 18 if (!g_instance.Get().get()) { |
19 g_instance.Get() = new BluetoothSocketThread(); | 19 g_instance.Get() = new BluetoothSocketThread(); |
20 } | 20 } |
21 return g_instance.Get(); | 21 return g_instance.Get(); |
22 } | 22 } |
23 | 23 |
24 // static | 24 // static |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 scoped_refptr<base::SequencedTaskRunner> BluetoothSocketThread::task_runner() | 64 scoped_refptr<base::SequencedTaskRunner> BluetoothSocketThread::task_runner() |
65 const { | 65 const { |
66 DCHECK(active_socket_count_ > 0); | 66 DCHECK(active_socket_count_ > 0); |
67 DCHECK(thread_); | 67 DCHECK(thread_); |
68 DCHECK(task_runner_.get()); | 68 DCHECK(task_runner_.get()); |
69 | 69 |
70 return task_runner_; | 70 return task_runner_; |
71 } | 71 } |
72 | 72 |
73 } // namespace device | 73 } // namespace device |
OLD | NEW |