OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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_H_ | 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_PROFILE_H_ |
6 #define DEVICE_BLUETOOTH_BLUETOOTH_PROFILE_H_ | 6 #define DEVICE_BLUETOOTH_BLUETOOTH_PROFILE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "device/bluetooth/bluetooth_uuid.h" | |
13 | 12 |
14 namespace device { | 13 namespace device { |
15 | 14 |
16 class BluetoothDevice; | 15 class BluetoothDevice; |
17 class BluetoothProfileMac; | 16 class BluetoothProfileMac; |
18 class BluetoothSocket; | 17 class BluetoothSocket; |
19 class MockBluetoothProfile; | 18 class MockBluetoothProfile; |
20 | 19 |
21 // BluetoothProfile represents an implementation of either a client or server | 20 // BluetoothProfile represents an implementation of either a client or server |
22 // of a particular specified profile (aka service or protocol in other | 21 // of a particular specified profile (aka service or protocol in other |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 }; | 71 }; |
73 | 72 |
74 // Register an implementation of the profile with UUID |uuid| and | 73 // Register an implementation of the profile with UUID |uuid| and |
75 // additional details specified in |options|. The corresponding profile | 74 // additional details specified in |options|. The corresponding profile |
76 // object will be created and returned by |callback|. If the profile cannot | 75 // object will be created and returned by |callback|. If the profile cannot |
77 // be registered, NULL will be passed. | 76 // be registered, NULL will be passed. |
78 // | 77 // |
79 // This pointer is not owned by the receiver, but will not be freed unless | 78 // This pointer is not owned by the receiver, but will not be freed unless |
80 // its Unregister() method is called. | 79 // its Unregister() method is called. |
81 typedef base::Callback<void(BluetoothProfile*)> ProfileCallback; | 80 typedef base::Callback<void(BluetoothProfile*)> ProfileCallback; |
82 static void Register(const BluetoothUUID& uuid, | 81 static void Register(const std::string& uuid, |
83 const Options& options, | 82 const Options& options, |
84 const ProfileCallback& callback); | 83 const ProfileCallback& callback); |
85 | 84 |
86 // Unregister the profile. This deletes the profile object so, once called, | 85 // Unregister the profile. This deletes the profile object so, once called, |
87 // any pointers to the profile should be discarded. | 86 // any pointers to the profile should be discarded. |
88 virtual void Unregister() = 0; | 87 virtual void Unregister() = 0; |
89 | 88 |
90 // Set the connection callback for the profile to |callback|, any successful | 89 // Set the connection callback for the profile to |callback|, any successful |
91 // connection initiated by BluetoothDevice::ConnectToProfile() or incoming | 90 // connection initiated by BluetoothDevice::ConnectToProfile() or incoming |
92 // connections from devices, will have a BluetoothSocket created and passed | 91 // connections from devices, will have a BluetoothSocket created and passed |
93 // to this callback. | 92 // to this callback. |
94 // | 93 // |
95 // The socket will be closed when all references are released; none of the | 94 // The socket will be closed when all references are released; none of the |
96 // BluetoothProfile, or BluetoothAdapter or BluetoothDevice objects are | 95 // BluetoothProfile, or BluetoothAdapter or BluetoothDevice objects are |
97 // guaranteed to hold a reference so this may outlive all of them. | 96 // guaranteed to hold a reference so this may outlive all of them. |
98 typedef base::Callback<void( | 97 typedef base::Callback<void( |
99 const BluetoothDevice*, | 98 const BluetoothDevice*, |
100 scoped_refptr<BluetoothSocket>)> ConnectionCallback; | 99 scoped_refptr<BluetoothSocket>)> ConnectionCallback; |
101 virtual void SetConnectionCallback(const ConnectionCallback& callback) = 0; | 100 virtual void SetConnectionCallback(const ConnectionCallback& callback) = 0; |
102 | 101 |
103 protected: | 102 protected: |
104 BluetoothProfile(); | 103 BluetoothProfile(); |
105 virtual ~BluetoothProfile(); | 104 virtual ~BluetoothProfile(); |
106 }; | 105 }; |
107 | 106 |
108 } // namespace device | 107 } // namespace device |
109 | 108 |
110 #endif // DEVICE_BLUETOOTH_BLUETOOTH_PROFILE_H_ | 109 #endif // DEVICE_BLUETOOTH_BLUETOOTH_PROFILE_H_ |
OLD | NEW |