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 27 matching lines...) Expand all Loading... |
38 protected: | 38 protected: |
39 // Connection: | 39 // Connection: |
40 virtual void Connect() override; | 40 virtual void Connect() override; |
41 virtual void Disconnect() override; | 41 virtual void Disconnect() override; |
42 virtual void SendMessageImpl(scoped_ptr<WireMessage> message) override; | 42 virtual void SendMessageImpl(scoped_ptr<WireMessage> message) override; |
43 | 43 |
44 // BluetoothAdapter::Observer: | 44 // BluetoothAdapter::Observer: |
45 virtual void DeviceRemoved(device::BluetoothAdapter* adapter, | 45 virtual void DeviceRemoved(device::BluetoothAdapter* adapter, |
46 device::BluetoothDevice* device) override; | 46 device::BluetoothDevice* device) override; |
47 | 47 |
48 // Exposed for testing. | |
49 virtual void ConnectToService( | |
50 device::BluetoothDevice* device, | |
51 const device::BluetoothUUID& uuid, | |
52 const device::BluetoothDevice::ConnectToServiceCallback& callback, | |
53 const device::BluetoothDevice::ConnectToServiceErrorCallback& | |
54 error_callback); | |
55 | |
56 private: | 48 private: |
57 // Registers receive callbacks with the backing |socket_|. | 49 // Registers receive callbacks with the backing |socket_|. |
58 void StartReceive(); | 50 void StartReceive(); |
59 | 51 |
60 // Callbacks for asynchronous Bluetooth operations. | 52 // Callbacks for asynchronous Bluetooth operations. |
61 void OnAdapterInitialized(scoped_refptr<device::BluetoothAdapter> adapter); | 53 void OnAdapterInitialized(scoped_refptr<device::BluetoothAdapter> adapter); |
62 void OnConnected(scoped_refptr<device::BluetoothSocket> socket); | 54 void OnConnected(scoped_refptr<device::BluetoothSocket> socket); |
63 void OnConnectionError(const std::string& error_message); | 55 void OnConnectionError(const std::string& error_message); |
64 void OnSend(int bytes_sent); | 56 void OnSend(int bytes_sent); |
65 void OnSendError(const std::string& error_message); | 57 void OnSendError(const std::string& error_message); |
(...skipping 18 matching lines...) Expand all Loading... |
84 scoped_ptr<WireMessage> pending_message_; | 76 scoped_ptr<WireMessage> pending_message_; |
85 | 77 |
86 base::WeakPtrFactory<BluetoothConnection> weak_ptr_factory_; | 78 base::WeakPtrFactory<BluetoothConnection> weak_ptr_factory_; |
87 | 79 |
88 DISALLOW_COPY_AND_ASSIGN(BluetoothConnection); | 80 DISALLOW_COPY_AND_ASSIGN(BluetoothConnection); |
89 }; | 81 }; |
90 | 82 |
91 } // namespace proximity_auth | 83 } // namespace proximity_auth |
92 | 84 |
93 #endif // COMPONENTS_PROXIMITY_AUTH_BLUETOOTH_CONNECTION_H | 85 #endif // COMPONENTS_PROXIMITY_AUTH_BLUETOOTH_CONNECTION_H |
OLD | NEW |