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 #ifndef COMPONENTS_COPRESENCE_SOCKETS_TRANSPORTS_COPRESENCE_SOCKET_BLUETOOTH_H_ | 5 #ifndef COMPONENTS_COPRESENCE_SOCKETS_TRANSPORTS_COPRESENCE_SOCKET_BLUETOOTH_H_ |
6 #define COMPONENTS_COPRESENCE_SOCKETS_TRANSPORTS_COPRESENCE_SOCKET_BLUETOOTH_H_ | 6 #define COMPONENTS_COPRESENCE_SOCKETS_TRANSPORTS_COPRESENCE_SOCKET_BLUETOOTH_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
13 #include "components/copresence_sockets/public/copresence_socket.h" | 13 #include "components/copresence_sockets/public/copresence_socket.h" |
14 #include "device/bluetooth/bluetooth_socket.h" | 14 #include "device/bluetooth/bluetooth_socket.h" |
15 | 15 |
16 namespace net { | 16 namespace net { |
17 class IOBuffer; | 17 class IOBuffer; |
18 } | 18 } |
19 | 19 |
20 namespace copresence_sockets { | 20 namespace copresence_sockets { |
21 | 21 |
22 // A CopresenceSocketBluetooth is the Bluetooth implementation of a | 22 // A CopresenceSocketBluetooth is the Bluetooth implementation of a |
23 // CopresenceSocket. This is currently a thin wrapper around BluetoothSocket. | 23 // CopresenceSocket. This is currently a thin wrapper around BluetoothSocket. |
24 class CopresenceSocketBluetooth : public CopresenceSocket { | 24 class CopresenceSocketBluetooth : public CopresenceSocket { |
25 public: | 25 public: |
26 explicit CopresenceSocketBluetooth( | 26 explicit CopresenceSocketBluetooth( |
27 const scoped_refptr<device::BluetoothSocket>& socket); | 27 const scoped_refptr<device::BluetoothSocket>& socket); |
28 virtual ~CopresenceSocketBluetooth(); | 28 ~CopresenceSocketBluetooth() override; |
29 | 29 |
30 // CopresenceSocket overrides: | 30 // CopresenceSocket overrides: |
31 virtual bool Send(const scoped_refptr<net::IOBuffer>& buffer, | 31 bool Send(const scoped_refptr<net::IOBuffer>& buffer, |
32 int buffer_size) override; | 32 int buffer_size) override; |
33 virtual void Receive(const ReceiveCallback& callback) override; | 33 void Receive(const ReceiveCallback& callback) override; |
34 | 34 |
35 private: | 35 private: |
36 void OnSendComplete(int status); | 36 void OnSendComplete(int status); |
37 void OnSendError(const std::string& message); | 37 void OnSendError(const std::string& message); |
38 | 38 |
39 void OnReceive(int size, scoped_refptr<net::IOBuffer> io_buffer); | 39 void OnReceive(int size, scoped_refptr<net::IOBuffer> io_buffer); |
40 void OnReceiveError(device::BluetoothSocket::ErrorReason reason, | 40 void OnReceiveError(device::BluetoothSocket::ErrorReason reason, |
41 const std::string& message); | 41 const std::string& message); |
42 | 42 |
43 scoped_refptr<device::BluetoothSocket> socket_; | 43 scoped_refptr<device::BluetoothSocket> socket_; |
44 ReceiveCallback receive_callback_; | 44 ReceiveCallback receive_callback_; |
45 | 45 |
46 base::WeakPtrFactory<CopresenceSocketBluetooth> weak_ptr_factory_; | 46 base::WeakPtrFactory<CopresenceSocketBluetooth> weak_ptr_factory_; |
47 | 47 |
48 DISALLOW_COPY_AND_ASSIGN(CopresenceSocketBluetooth); | 48 DISALLOW_COPY_AND_ASSIGN(CopresenceSocketBluetooth); |
49 }; | 49 }; |
50 | 50 |
51 } // namespace copresence_sockets | 51 } // namespace copresence_sockets |
52 | 52 |
53 #endif // COMPONENTS_COPRESENCE_SOCKETS_TRANSPORTS_COPRESENCE_SOCKET_BLUETOOTH_
H_ | 53 #endif // COMPONENTS_COPRESENCE_SOCKETS_TRANSPORTS_COPRESENCE_SOCKET_BLUETOOTH_
H_ |
OLD | NEW |