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