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_DBUS_BLUETOOTH_PROFILE_SERVICE_PROVIDER_H_ | 5 #ifndef DEVICE_BLUETOOTH_DBUS_BLUETOOTH_PROFILE_SERVICE_PROVIDER_H_ |
6 #define DEVICE_BLUETOOTH_DBUS_BLUETOOTH_PROFILE_SERVICE_PROVIDER_H_ | 6 #define DEVICE_BLUETOOTH_DBUS_BLUETOOTH_PROFILE_SERVICE_PROVIDER_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
11 #include <string> | 11 #include <string> |
12 | 12 |
13 #include "base/callback.h" | 13 #include "base/callback.h" |
| 14 #include "base/files/scoped_file.h" |
14 #include "base/macros.h" | 15 #include "base/macros.h" |
15 #include "dbus/bus.h" | 16 #include "dbus/bus.h" |
16 #include "dbus/file_descriptor.h" | |
17 #include "dbus/object_path.h" | 17 #include "dbus/object_path.h" |
18 #include "device/bluetooth/bluetooth_export.h" | 18 #include "device/bluetooth/bluetooth_export.h" |
19 | 19 |
20 namespace bluez { | 20 namespace bluez { |
21 | 21 |
22 // BluetoothProfileServiceProvider is used to provide a D-Bus object that the | 22 // BluetoothProfileServiceProvider is used to provide a D-Bus object that the |
23 // Bluetooth daemon can communicate with to connect application profiles. | 23 // Bluetooth daemon can communicate with to connect application profiles. |
24 // | 24 // |
25 // Instantiate with a chosen D-Bus object path and delegate object, and pass | 25 // Instantiate with a chosen D-Bus object path and delegate object, and pass |
26 // the D-Bus object path as the |agent_path| argument to the | 26 // the D-Bus object path as the |agent_path| argument to the |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 // with base::Refcounted<T>. | 68 // with base::Refcounted<T>. |
69 virtual void Released() = 0; | 69 virtual void Released() = 0; |
70 | 70 |
71 // This method will be called when a profile connection to the device | 71 // This method will be called when a profile connection to the device |
72 // with object path |device_path| is established. |callback| must be called | 72 // with object path |device_path| is established. |callback| must be called |
73 // to confirm the connection, or indicate rejection or cancellation. | 73 // to confirm the connection, or indicate rejection or cancellation. |
74 // | 74 // |
75 // A file descriptor for the connection socket is provided in |fd|, and | 75 // A file descriptor for the connection socket is provided in |fd|, and |
76 // details about the specific implementation of the profile in |options|. | 76 // details about the specific implementation of the profile in |options|. |
77 // | 77 // |
78 // IMPORTANT: Ownership of the file descriptor object |fd| is passed to | |
79 // the delegate by this call. The delegate is responsible for checking the | |
80 // validity of |fd| on a thread where I/O is permitted before taking the | |
81 // value. If the value is not taken, the file descriptor is closed. | |
82 // | |
83 // Ownership of |options| is NOT passed so information out of it must be | 78 // Ownership of |options| is NOT passed so information out of it must be |
84 // copied if required. | 79 // copied if required. |
85 virtual void NewConnection(const dbus::ObjectPath& device_path, | 80 virtual void NewConnection(const dbus::ObjectPath& device_path, |
86 std::unique_ptr<dbus::FileDescriptor> fd, | 81 base::ScopedFD fd, |
87 const Options& options, | 82 const Options& options, |
88 const ConfirmationCallback& callback) = 0; | 83 const ConfirmationCallback& callback) = 0; |
89 | 84 |
90 // This method will be called when a profile connection to the device | 85 // This method will be called when a profile connection to the device |
91 // with object path |device_path| is disconnected. Any file descriptors | 86 // with object path |device_path| is disconnected. Any file descriptors |
92 // owned by the service should be cleaned up and |callback| called to | 87 // owned by the service should be cleaned up and |callback| called to |
93 // confirm, or indicate rejection or cancellation of the disconnection. | 88 // confirm, or indicate rejection or cancellation of the disconnection. |
94 virtual void RequestDisconnection(const dbus::ObjectPath& device_path, | 89 virtual void RequestDisconnection(const dbus::ObjectPath& device_path, |
95 const ConfirmationCallback& callback) = 0; | 90 const ConfirmationCallback& callback) = 0; |
96 | 91 |
(...skipping 16 matching lines...) Expand all Loading... |
113 protected: | 108 protected: |
114 BluetoothProfileServiceProvider(); | 109 BluetoothProfileServiceProvider(); |
115 | 110 |
116 private: | 111 private: |
117 DISALLOW_COPY_AND_ASSIGN(BluetoothProfileServiceProvider); | 112 DISALLOW_COPY_AND_ASSIGN(BluetoothProfileServiceProvider); |
118 }; | 113 }; |
119 | 114 |
120 } // namespace bluez | 115 } // namespace bluez |
121 | 116 |
122 #endif // DEVICE_BLUETOOTH_DBUS_BLUETOOTH_PROFILE_SERVICE_PROVIDER_H_ | 117 #endif // DEVICE_BLUETOOTH_DBUS_BLUETOOTH_PROFILE_SERVICE_PROVIDER_H_ |
OLD | NEW |