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_PROXIMITY_AUTH_BLUETOOTH_CONNECTION_H | 5 #ifndef COMPONENTS_PROXIMITY_AUTH_BLUETOOTH_CONNECTION_H |
6 #define COMPONENTS_PROXIMITY_AUTH_BLUETOOTH_CONNECTION_H | 6 #define COMPONENTS_PROXIMITY_AUTH_BLUETOOTH_CONNECTION_H |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 // Represents a Bluetooth connection with a remote device. The connection is a | 26 // Represents a Bluetooth connection with a remote device. The connection is a |
27 // persistent bidirectional channel for sending and receiving wire messages. | 27 // persistent bidirectional channel for sending and receiving wire messages. |
28 class BluetoothConnection : public Connection, | 28 class BluetoothConnection : public Connection, |
29 public device::BluetoothAdapter::Observer { | 29 public device::BluetoothAdapter::Observer { |
30 public: | 30 public: |
31 // Constructs a Bluetooth connection to the service with |uuid| on the | 31 // Constructs a Bluetooth connection to the service with |uuid| on the |
32 // |remote_device|. The |remote_device| must already be known to the system | 32 // |remote_device|. The |remote_device| must already be known to the system |
33 // Bluetooth daemon. | 33 // Bluetooth daemon. |
34 BluetoothConnection(const RemoteDevice& remote_device, | 34 BluetoothConnection(const RemoteDevice& remote_device, |
35 const device::BluetoothUUID& uuid); | 35 const device::BluetoothUUID& uuid); |
36 virtual ~BluetoothConnection(); | 36 ~BluetoothConnection() override; |
37 | 37 |
38 protected: | 38 protected: |
39 // Connection: | 39 // Connection: |
40 virtual void Connect() override; | 40 void Connect() override; |
41 virtual void Disconnect() override; | 41 void Disconnect() override; |
42 virtual void SendMessageImpl(scoped_ptr<WireMessage> message) override; | 42 void SendMessageImpl(scoped_ptr<WireMessage> message) override; |
43 | 43 |
44 // BluetoothAdapter::Observer: | 44 // BluetoothAdapter::Observer: |
45 virtual void DeviceRemoved(device::BluetoothAdapter* adapter, | 45 void DeviceRemoved(device::BluetoothAdapter* adapter, |
46 device::BluetoothDevice* device) override; | 46 device::BluetoothDevice* device) override; |
47 | 47 |
48 private: | 48 private: |
49 // Registers receive callbacks with the backing |socket_|. | 49 // Registers receive callbacks with the backing |socket_|. |
50 void StartReceive(); | 50 void StartReceive(); |
51 | 51 |
52 // Callbacks for asynchronous Bluetooth operations. | 52 // Callbacks for asynchronous Bluetooth operations. |
53 void OnAdapterInitialized(scoped_refptr<device::BluetoothAdapter> adapter); | 53 void OnAdapterInitialized(scoped_refptr<device::BluetoothAdapter> adapter); |
54 void OnConnected(scoped_refptr<device::BluetoothSocket> socket); | 54 void OnConnected(scoped_refptr<device::BluetoothSocket> socket); |
55 void OnConnectionError(const std::string& error_message); | 55 void OnConnectionError(const std::string& error_message); |
56 void OnSend(int bytes_sent); | 56 void OnSend(int bytes_sent); |
(...skipping 19 matching lines...) Expand all Loading... |
76 scoped_ptr<WireMessage> pending_message_; | 76 scoped_ptr<WireMessage> pending_message_; |
77 | 77 |
78 base::WeakPtrFactory<BluetoothConnection> weak_ptr_factory_; | 78 base::WeakPtrFactory<BluetoothConnection> weak_ptr_factory_; |
79 | 79 |
80 DISALLOW_COPY_AND_ASSIGN(BluetoothConnection); | 80 DISALLOW_COPY_AND_ASSIGN(BluetoothConnection); |
81 }; | 81 }; |
82 | 82 |
83 } // namespace proximity_auth | 83 } // namespace proximity_auth |
84 | 84 |
85 #endif // COMPONENTS_PROXIMITY_AUTH_BLUETOOTH_CONNECTION_H | 85 #endif // COMPONENTS_PROXIMITY_AUTH_BLUETOOTH_CONNECTION_H |
OLD | NEW |