OLD | NEW |
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_PROFILE_MAC_H_ | 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_PROFILE_MAC_H_ |
6 #define DEVICE_BLUETOOTH_BLUETOOTH_PROFILE_MAC_H_ | 6 #define DEVICE_BLUETOOTH_BLUETOOTH_PROFILE_MAC_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/callback.h" | 11 #include "base/callback.h" |
12 #include "device/bluetooth/bluetooth_profile.h" | 12 #include "device/bluetooth/bluetooth_profile.h" |
13 #include "device/bluetooth/bluetooth_uuid.h" | 13 #include "device/bluetooth/bluetooth_uuid.h" |
14 | 14 |
15 #ifdef __OBJC__ | 15 #ifdef __OBJC__ |
16 @class IOBluetoothDevice; | 16 @class IOBluetoothDevice; |
17 #else | 17 #else |
18 class IOBluetoothDevice; | 18 class IOBluetoothDevice; |
19 #endif | 19 #endif |
20 | 20 |
| 21 namespace base { |
| 22 class SequencedTaskRunner; |
| 23 } // namespace base |
| 24 |
21 namespace device { | 25 namespace device { |
22 | 26 |
23 class BluetoothProfileMac : public BluetoothProfile { | 27 class BluetoothProfileMac : public BluetoothProfile { |
24 public: | 28 public: |
25 // BluetoothProfile override. | 29 // BluetoothProfile override. |
26 virtual void Unregister() OVERRIDE; | 30 virtual void Unregister() OVERRIDE; |
27 virtual void SetConnectionCallback( | 31 virtual void SetConnectionCallback( |
28 const ConnectionCallback& callback) OVERRIDE; | 32 const ConnectionCallback& callback) OVERRIDE; |
29 | 33 |
30 // Makes an outgoing connection to |device|. | 34 typedef base::Callback<void(const std::string&)> ErrorCallback; |
31 // This method runs |socket_callback_| with the socket and returns true if the | 35 |
32 // connection is made successfully. | 36 // Makes an outgoing connection to |device|, calling |callback| on succes or |
33 bool Connect(IOBluetoothDevice* device); | 37 // |error_callback| on error. If successful, this method also calls |
| 38 // |connection_callback_| before calling |callback|. |
| 39 void Connect(const scoped_refptr<base::SequencedTaskRunner>& ui_task_runner, |
| 40 IOBluetoothDevice* device, |
| 41 const base::Closure& callback, |
| 42 const ErrorCallback& error_callback); |
34 | 43 |
35 private: | 44 private: |
36 friend BluetoothProfile; | 45 friend BluetoothProfile; |
37 | 46 |
38 BluetoothProfileMac(const BluetoothUUID& uuid, const std::string& name); | 47 BluetoothProfileMac(const BluetoothUUID& uuid, const std::string& name); |
39 virtual ~BluetoothProfileMac(); | 48 virtual ~BluetoothProfileMac(); |
40 | 49 |
41 const BluetoothUUID uuid_; | 50 const BluetoothUUID uuid_; |
42 const std::string name_; | 51 const std::string name_; |
43 ConnectionCallback connection_callback_; | 52 ConnectionCallback connection_callback_; |
44 }; | 53 }; |
45 | 54 |
46 } // namespace device | 55 } // namespace device |
47 | 56 |
48 #endif // DEVICE_BLUETOOTH_BLUETOOTH_PROFILE_MAC_H_ | 57 #endif // DEVICE_BLUETOOTH_BLUETOOTH_PROFILE_MAC_H_ |
OLD | NEW |