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

Side by Side Diff: device/bluetooth/bluetooth_socket_thread.cc

Issue 507053002: Remove implicit conversions from scoped_refptr to T* in device/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Regenerate Created 6 years, 3 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 | « device/bluetooth/bluetooth_socket_net.cc ('k') | device/hid/hid_connection_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 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> > g_instance =
14 LAZY_INSTANCE_INITIALIZER; 14 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
25 void BluetoothSocketThread::CleanupForTesting() { 25 void BluetoothSocketThread::CleanupForTesting() {
26 DCHECK(g_instance.Get()); 26 DCHECK(g_instance.Get().get());
27 g_instance.Get() = NULL; 27 g_instance.Get() = NULL;
28 } 28 }
29 29
30 BluetoothSocketThread::BluetoothSocketThread() 30 BluetoothSocketThread::BluetoothSocketThread()
31 : active_socket_count_(0) {} 31 : active_socket_count_(0) {}
32 32
33 BluetoothSocketThread::~BluetoothSocketThread() { 33 BluetoothSocketThread::~BluetoothSocketThread() {
34 if (thread_) { 34 if (thread_) {
35 thread_->Stop(); 35 thread_->Stop();
36 thread_.reset(NULL); 36 thread_.reset(NULL);
(...skipping 26 matching lines...) Expand all
63 thread_options.message_loop_type = base::MessageLoop::TYPE_IO; 63 thread_options.message_loop_type = base::MessageLoop::TYPE_IO;
64 thread_.reset(new base::Thread("BluetoothSocketThread")); 64 thread_.reset(new base::Thread("BluetoothSocketThread"));
65 thread_->StartWithOptions(thread_options); 65 thread_->StartWithOptions(thread_options);
66 task_runner_ = thread_->message_loop_proxy(); 66 task_runner_ = thread_->message_loop_proxy();
67 } 67 }
68 68
69 scoped_refptr<base::SequencedTaskRunner> BluetoothSocketThread::task_runner() 69 scoped_refptr<base::SequencedTaskRunner> BluetoothSocketThread::task_runner()
70 const { 70 const {
71 DCHECK(active_socket_count_ > 0); 71 DCHECK(active_socket_count_ > 0);
72 DCHECK(thread_); 72 DCHECK(thread_);
73 DCHECK(task_runner_); 73 DCHECK(task_runner_.get());
74 74
75 return task_runner_; 75 return task_runner_;
76 } 76 }
77 77
78 } // namespace device 78 } // namespace device
OLDNEW
« no previous file with comments | « device/bluetooth/bluetooth_socket_net.cc ('k') | device/hid/hid_connection_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698