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

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

Issue 267633003: Reimplement BluetoothSocketChromeOS (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_CHROMEOS_H_ 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_SOCKET_CHROMEOS_H_
6 #define DEVICE_BLUETOOTH_BLUETOOTH_SOCKET_CHROMEOS_H_ 6 #define DEVICE_BLUETOOTH_BLUETOOTH_SOCKET_CHROMEOS_H_
7 7
8 #include <string>
9
10 #include "base/basictypes.h"
11 #include "base/memory/ref_counted.h"
12 #include "chromeos/chromeos_export.h" 8 #include "chromeos/chromeos_export.h"
13 #include "device/bluetooth/bluetooth_socket.h" 9 #include "device/bluetooth/bluetooth_socket.h"
10 #include "device/bluetooth/bluetooth_socket_net.h"
14 11
15 namespace dbus { 12 namespace dbus {
16 class FileDescriptor; 13 class FileDescriptor;
17 } // namespace dbus 14 } // namespace dbus
18 15
19 namespace net {
20 class IOBuffer;
21 } // namespace net
22 16
23 namespace chromeos { 17 namespace chromeos {
24 18
25 // The BluetoothSocketChromeOS class implements BluetoothSocket for the 19 // The BluetoothSocketChromeOS class implements BluetoothSocket for the
26 // Chrome OS platform. 20 // Chrome OS platform.
27 class CHROMEOS_EXPORT BluetoothSocketChromeOS 21 class CHROMEOS_EXPORT BluetoothSocketChromeOS
28 : public device::BluetoothSocket { 22 : public device::BluetoothSocketNet {
29 public: 23 public:
30 // Overriden from BluetoothSocket: 24 static scoped_refptr<BluetoothSocketChromeOS> CreateBluetoothSocket(
31 virtual void Close() OVERRIDE; 25 scoped_refptr<base::SequencedTaskRunner> ui_task_runner,
32 virtual void Disconnect(const base::Closure& callback) OVERRIDE; 26 scoped_refptr<device::BluetoothSocketThread> socket_thread,
33 virtual void Receive(int buffer_size, 27 net::NetLog* net_log,
34 const ReceiveCompletionCallback& success_callback, 28 const net::NetLog::Source& source);
35 const ReceiveErrorCompletionCallback& error_callback)
36 OVERRIDE;
37 virtual void Send(scoped_refptr<net::IOBuffer> buffer,
38 int buffer_size,
39 const SendCompletionCallback& success_callback,
40 const ErrorCompletionCallback& error_callback) OVERRIDE;
41 29
42 // Create an instance of a BluetoothSocket from the passed file descriptor 30 virtual void Connect(scoped_ptr<dbus::FileDescriptor> fd,
43 // received over D-Bus in |fd|, the descriptor will be taken from that object 31 const base::Closure& success_callback,
44 // and ownership passed to the returned object. 32 const ErrorCompletionCallback& error_callback);
45 static scoped_refptr<device::BluetoothSocket> Create(
46 dbus::FileDescriptor* fd);
47 33
48 protected: 34 protected:
49 virtual ~BluetoothSocketChromeOS(); 35 virtual ~BluetoothSocketChromeOS();
50 36
51 private: 37 private:
52 BluetoothSocketChromeOS(int fd); 38 BluetoothSocketChromeOS(
39 scoped_refptr<base::SequencedTaskRunner> ui_task_runner,
40 scoped_refptr<device::BluetoothSocketThread> socket_thread,
41 net::NetLog* net_log,
42 const net::NetLog::Source& source);
53 43
54 // The different socket types have different reading patterns; l2cap sockets 44 void DoConnect(scoped_ptr<dbus::FileDescriptor> fd,
55 // have to be read with boundaries between datagrams preserved while rfcomm 45 const base::Closure& success_callback,
56 // sockets do not. 46 const ErrorCompletionCallback& error_callback);
57 enum SocketType {
58 L2CAP,
59 RFCOMM
60 };
61 47
62 // File descriptor and socket type of the socket.
63 const int fd_;
64 SocketType socket_type_;
65
66 // Last error message, set during Receive() and Send() and retrieved using
67 // GetLastErrorMessage().
68 std::string error_message_;
69 48
70 DISALLOW_COPY_AND_ASSIGN(BluetoothSocketChromeOS); 49 DISALLOW_COPY_AND_ASSIGN(BluetoothSocketChromeOS);
71 }; 50 };
72 51
73 } // namespace chromeos 52 } // namespace chromeos
74 53
75 #endif // DEVICE_BLUETOOTH_BLUETOOTH_SOCKET_CHROMEOS_H_ 54 #endif // DEVICE_BLUETOOTH_BLUETOOTH_SOCKET_CHROMEOS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698