OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "device/bluetooth/dbus/bluetooth_media_transport_client.h" | 5 #include "device/bluetooth/dbus/bluetooth_media_transport_client.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 DCHECK(response); | 216 DCHECK(response); |
217 callback.Run(); | 217 callback.Run(); |
218 } | 218 } |
219 | 219 |
220 // Called when a response for |Acquire|/|TryAcquire| method call is received. | 220 // Called when a response for |Acquire|/|TryAcquire| method call is received. |
221 void OnAcquireSuccess(const AcquireCallback& callback, | 221 void OnAcquireSuccess(const AcquireCallback& callback, |
222 const ErrorCallback& error_callback, | 222 const ErrorCallback& error_callback, |
223 dbus::Response* response) { | 223 dbus::Response* response) { |
224 DCHECK(response); | 224 DCHECK(response); |
225 | 225 |
226 dbus::FileDescriptor fd; | 226 base::ScopedFD fd; |
227 uint16_t read_mtu; | 227 uint16_t read_mtu; |
228 uint16_t write_mtu; | 228 uint16_t write_mtu; |
229 | 229 |
230 // Parse the response. | 230 // Parse the response. |
231 dbus::MessageReader reader(response); | 231 dbus::MessageReader reader(response); |
232 if (reader.PopFileDescriptor(&fd) && reader.PopUint16(&read_mtu) && | 232 if (reader.PopFileDescriptor(&fd) && reader.PopUint16(&read_mtu) && |
233 reader.PopUint16(&write_mtu)) { | 233 reader.PopUint16(&write_mtu)) { |
234 fd.CheckValidity(); | |
235 DCHECK(fd.is_valid()); | 234 DCHECK(fd.is_valid()); |
236 | 235 |
237 VLOG(1) << "OnAcquireSuccess - fd: " << fd.value() | 236 VLOG(1) << "OnAcquireSuccess - fd: " << fd.get() |
238 << ", read MTU: " << read_mtu << ", write MTU: " << write_mtu; | 237 << ", read MTU: " << read_mtu << ", write MTU: " << write_mtu; |
239 | 238 |
240 // The ownership of the file descriptor is transferred to the user | 239 // The ownership of the file descriptor is transferred to the user |
241 // application. | 240 // application. |
242 callback.Run(&fd, read_mtu, write_mtu); | 241 callback.Run(std::move(fd), read_mtu, write_mtu); |
243 return; | 242 return; |
244 } | 243 } |
245 | 244 |
246 error_callback.Run( | 245 error_callback.Run( |
247 kUnexpectedResponse, | 246 kUnexpectedResponse, |
248 "Failed to retrieve file descriptor, read MTU and write MTU."); | 247 "Failed to retrieve file descriptor, read MTU and write MTU."); |
249 } | 248 } |
250 | 249 |
251 // Called when a response for a failed method call is received. | 250 // Called when a response for a failed method call is received. |
252 void OnError(const ErrorCallback& error_callback, | 251 void OnError(const ErrorCallback& error_callback, |
(...skipping 25 matching lines...) Expand all Loading... |
278 | 277 |
279 BluetoothMediaTransportClient::BluetoothMediaTransportClient() {} | 278 BluetoothMediaTransportClient::BluetoothMediaTransportClient() {} |
280 | 279 |
281 BluetoothMediaTransportClient::~BluetoothMediaTransportClient() {} | 280 BluetoothMediaTransportClient::~BluetoothMediaTransportClient() {} |
282 | 281 |
283 BluetoothMediaTransportClient* BluetoothMediaTransportClient::Create() { | 282 BluetoothMediaTransportClient* BluetoothMediaTransportClient::Create() { |
284 return new BluetoothMediaTransportClientImpl(); | 283 return new BluetoothMediaTransportClientImpl(); |
285 } | 284 } |
286 | 285 |
287 } // namespace bluez | 286 } // namespace bluez |
OLD | NEW |