Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(241)

Side by Side Diff: device/bluetooth/bluez/bluetooth_socket_bluez.h

Issue 2310883003: dbus: No dbus::FileDescriptor in BluetoothProfileServiceProvider (Closed)
Patch Set: Fix tests Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_BLUEZ_BLUETOOTH_SOCKET_BLUEZ_H_ 5 #ifndef DEVICE_BLUETOOTH_BLUEZ_BLUETOOTH_SOCKET_BLUEZ_H_
6 #define DEVICE_BLUETOOTH_BLUEZ_BLUETOOTH_SOCKET_BLUEZ_H_ 6 #define DEVICE_BLUETOOTH_BLUEZ_BLUETOOTH_SOCKET_BLUEZ_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <queue> 9 #include <queue>
10 #include <string> 10 #include <string>
11 11
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/linked_ptr.h" 13 #include "base/memory/linked_ptr.h"
14 #include "dbus/object_path.h" 14 #include "dbus/object_path.h"
15 #include "device/bluetooth/bluetooth_adapter.h" 15 #include "device/bluetooth/bluetooth_adapter.h"
16 #include "device/bluetooth/bluetooth_export.h" 16 #include "device/bluetooth/bluetooth_export.h"
17 #include "device/bluetooth/bluetooth_socket.h" 17 #include "device/bluetooth/bluetooth_socket.h"
18 #include "device/bluetooth/bluetooth_socket_net.h" 18 #include "device/bluetooth/bluetooth_socket_net.h"
19 #include "device/bluetooth/bluetooth_uuid.h" 19 #include "device/bluetooth/bluetooth_uuid.h"
20 #include "device/bluetooth/dbus/bluetooth_profile_manager_client.h" 20 #include "device/bluetooth/dbus/bluetooth_profile_manager_client.h"
21 #include "device/bluetooth/dbus/bluetooth_profile_service_provider.h" 21 #include "device/bluetooth/dbus/bluetooth_profile_service_provider.h"
22 22
23 namespace dbus {
24 class FileDescriptor;
25 } // namespace dbus
26
27 namespace bluez { 23 namespace bluez {
28 24
29 class BluetoothDeviceBlueZ; 25 class BluetoothDeviceBlueZ;
30 class BluetoothAdapterBlueZ; 26 class BluetoothAdapterBlueZ;
31 class BluetoothAdapterProfileBlueZ; 27 class BluetoothAdapterProfileBlueZ;
32 28
33 // The BluetoothSocketBlueZ class implements BluetoothSocket for platforms that 29 // The BluetoothSocketBlueZ class implements BluetoothSocket for platforms that
34 // use BlueZ. 30 // use BlueZ.
35 // 31 //
36 // This class is not thread-safe, but is only called from the UI thread. 32 // This class is not thread-safe, but is only called from the UI thread.
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 103
108 // Called by dbus:: on completion of the RegisterProfile() method call 104 // Called by dbus:: on completion of the RegisterProfile() method call
109 // triggered as a result of the adapter becoming present again. 105 // triggered as a result of the adapter becoming present again.
110 void OnInternalRegisterProfile(BluetoothAdapterProfileBlueZ* profile); 106 void OnInternalRegisterProfile(BluetoothAdapterProfileBlueZ* profile);
111 void OnInternalRegisterProfileError(const std::string& error_message); 107 void OnInternalRegisterProfileError(const std::string& error_message);
112 108
113 // bluez::BluetoothProfileServiceProvider::Delegate: 109 // bluez::BluetoothProfileServiceProvider::Delegate:
114 void Released() override; 110 void Released() override;
115 void NewConnection( 111 void NewConnection(
116 const dbus::ObjectPath& device_path, 112 const dbus::ObjectPath& device_path,
117 std::unique_ptr<dbus::FileDescriptor> fd, 113 base::ScopedFD fd,
118 const bluez::BluetoothProfileServiceProvider::Delegate::Options& options, 114 const bluez::BluetoothProfileServiceProvider::Delegate::Options& options,
119 const ConfirmationCallback& callback) override; 115 const ConfirmationCallback& callback) override;
120 void RequestDisconnection(const dbus::ObjectPath& device_path, 116 void RequestDisconnection(const dbus::ObjectPath& device_path,
121 const ConfirmationCallback& callback) override; 117 const ConfirmationCallback& callback) override;
122 void Cancel() override; 118 void Cancel() override;
123 119
124 // Method run to accept a single incoming connection. 120 // Method run to accept a single incoming connection.
125 void AcceptConnectionRequest(); 121 void AcceptConnectionRequest();
126 122
127 // Method run on the socket thread to validate the file descriptor of a new 123 // Method run on the socket thread to validate the file descriptor of a new
128 // connection and set up the underlying net::TCPSocket() for it. 124 // connection and set up the underlying net::TCPSocket() for it.
129 void DoNewConnection( 125 void DoNewConnection(
130 const dbus::ObjectPath& device_path, 126 const dbus::ObjectPath& device_path,
131 std::unique_ptr<dbus::FileDescriptor> fd, 127 base::ScopedFD fd,
132 const bluez::BluetoothProfileServiceProvider::Delegate::Options& options, 128 const bluez::BluetoothProfileServiceProvider::Delegate::Options& options,
133 const ConfirmationCallback& callback); 129 const ConfirmationCallback& callback);
134 130
135 // Method run on the UI thread after a new connection has been accepted and 131 // Method run on the UI thread after a new connection has been accepted and
136 // a socket allocated in |socket|. Takes care of calling the Accept() 132 // a socket allocated in |socket|. Takes care of calling the Accept()
137 // callback and |callback| with the right arguments based on |status|. 133 // callback and |callback| with the right arguments based on |status|.
138 void OnNewConnection(scoped_refptr<BluetoothSocket> socket, 134 void OnNewConnection(scoped_refptr<BluetoothSocket> socket,
139 const ConfirmationCallback& callback, 135 const ConfirmationCallback& callback,
140 Status status); 136 Status status);
141 137
142 // Method run on the socket thread with a valid file descriptor |fd|, once 138 // Method run on the socket thread with a valid file descriptor |fd|, once
143 // complete calls |callback| on the UI thread with an appropriate argument 139 // complete calls |callback| on the UI thread with an appropriate argument
144 // indicating success or failure. 140 // indicating success or failure.
145 void DoConnect(std::unique_ptr<dbus::FileDescriptor> fd, 141 void DoConnect(base::ScopedFD fd, const ConfirmationCallback& callback);
146 const ConfirmationCallback& callback);
147 142
148 // Method run to clean-up a listening socket. 143 // Method run to clean-up a listening socket.
149 void DoCloseListening(); 144 void DoCloseListening();
150 145
151 // Unregisters this socket's usage of the Bluetooth profile which cleans up 146 // Unregisters this socket's usage of the Bluetooth profile which cleans up
152 // the profile if no one is using it. 147 // the profile if no one is using it.
153 void UnregisterProfile(); 148 void UnregisterProfile();
154 149
155 // Adapter the profile is registered against 150 // Adapter the profile is registered against
156 scoped_refptr<device::BluetoothAdapter> adapter_; 151 scoped_refptr<device::BluetoothAdapter> adapter_;
(...skipping 21 matching lines...) Expand all
178 ErrorCompletionCallback error_callback; 173 ErrorCompletionCallback error_callback;
179 }; 174 };
180 std::unique_ptr<AcceptRequest> accept_request_; 175 std::unique_ptr<AcceptRequest> accept_request_;
181 176
182 // Queue of incoming connection requests. 177 // Queue of incoming connection requests.
183 struct ConnectionRequest { 178 struct ConnectionRequest {
184 ConnectionRequest(); 179 ConnectionRequest();
185 ~ConnectionRequest(); 180 ~ConnectionRequest();
186 181
187 dbus::ObjectPath device_path; 182 dbus::ObjectPath device_path;
188 std::unique_ptr<dbus::FileDescriptor> fd; 183 base::ScopedFD fd;
189 bluez::BluetoothProfileServiceProvider::Delegate::Options options; 184 bluez::BluetoothProfileServiceProvider::Delegate::Options options;
190 ConfirmationCallback callback; 185 ConfirmationCallback callback;
191 bool accepting; 186 bool accepting;
192 bool cancelled; 187 bool cancelled;
193 }; 188 };
194 std::queue<linked_ptr<ConnectionRequest>> connection_request_queue_; 189 std::queue<linked_ptr<ConnectionRequest>> connection_request_queue_;
195 190
196 DISALLOW_COPY_AND_ASSIGN(BluetoothSocketBlueZ); 191 DISALLOW_COPY_AND_ASSIGN(BluetoothSocketBlueZ);
197 }; 192 };
198 193
199 } // namespace bluez 194 } // namespace bluez
200 195
201 #endif // DEVICE_BLUETOOTH_BLUEZ_BLUETOOTH_SOCKET_BLUEZ_H_ 196 #endif // DEVICE_BLUETOOTH_BLUEZ_BLUETOOTH_SOCKET_BLUEZ_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698