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

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

Issue 276573004: Bluetooth: Implement new socket API for Chrome OS (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix DCHECK nits Created 6 years, 7 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 | Annotate | Revision Log
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 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_SOCKET_THREAD_H_ 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_SOCKET_THREAD_H_
6 #define DEVICE_BLUETOOTH_BLUETOOTH_SOCKET_THREAD_H_ 6 #define DEVICE_BLUETOOTH_BLUETOOTH_SOCKET_THREAD_H_
7 7
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/threading/thread_checker.h" 10 #include "base/threading/thread_checker.h"
11 11
12 namespace base { 12 namespace base {
13 class SequencedTaskRunner; 13 class SequencedTaskRunner;
14 class Thread; 14 class Thread;
15 } // namespace base 15 } // namespace base
16 16
17 namespace device { 17 namespace device {
18 18
19 // Thread abstraction used by |BluetoothSocketChromeOS| and |BluetoothSocketWin| 19 // Thread abstraction used by |BluetoothSocketChromeOS| and |BluetoothSocketWin|
20 // to perform IO operations on the underlying platform sockets. An instance of 20 // to perform IO operations on the underlying platform sockets. An instance of
21 // this class can be shared by many active sockets. 21 // this class can be shared by many active sockets.
22 class BluetoothSocketThread 22 class BluetoothSocketThread
23 : public base::RefCountedThreadSafe<BluetoothSocketThread> { 23 : public base::RefCountedThreadSafe<BluetoothSocketThread> {
24 public: 24 public:
25 static scoped_refptr<BluetoothSocketThread> Get(); 25 static scoped_refptr<BluetoothSocketThread> Get();
26 static void CleanupForTesting();
27
26 void OnSocketActivate(); 28 void OnSocketActivate();
27 void OnSocketDeactivate(); 29 void OnSocketDeactivate();
28 30
29 scoped_refptr<base::SequencedTaskRunner> task_runner() const; 31 scoped_refptr<base::SequencedTaskRunner> task_runner() const;
30 32
31 private: 33 private:
32 friend class base::RefCountedThreadSafe<BluetoothSocketThread>; 34 friend class base::RefCountedThreadSafe<BluetoothSocketThread>;
33 BluetoothSocketThread(); 35 BluetoothSocketThread();
34 virtual ~BluetoothSocketThread(); 36 virtual ~BluetoothSocketThread();
35 37
36 void EnsureStarted(); 38 void EnsureStarted();
37 39
38 base::ThreadChecker thread_checker_; 40 base::ThreadChecker thread_checker_;
39 int active_socket_count_; 41 int active_socket_count_;
40 scoped_ptr<base::Thread> thread_; 42 scoped_ptr<base::Thread> thread_;
41 scoped_refptr<base::SequencedTaskRunner> task_runner_; 43 scoped_refptr<base::SequencedTaskRunner> task_runner_;
42 44
43 DISALLOW_COPY_AND_ASSIGN(BluetoothSocketThread); 45 DISALLOW_COPY_AND_ASSIGN(BluetoothSocketThread);
44 }; 46 };
45 47
46 } // namespace device 48 } // namespace device
47 49
48 #endif // DEVICE_BLUETOOTH_BLUETOOTH_SOCKET_THREAD_H_ 50 #endif // DEVICE_BLUETOOTH_BLUETOOTH_SOCKET_THREAD_H_
OLDNEW
« no previous file with comments | « device/bluetooth/bluetooth_socket_chromeos_unittest.cc ('k') | device/bluetooth/bluetooth_socket_thread.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698