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 "chromeos/dbus/bluetooth_media_transport_client.h" | 5 #include "chromeos/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/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/observer_list.h" | 10 #include "base/observer_list.h" |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 | 234 |
235 dbus::FileDescriptor fd; | 235 dbus::FileDescriptor fd; |
236 uint16_t read_mtu; | 236 uint16_t read_mtu; |
237 uint16_t write_mtu; | 237 uint16_t write_mtu; |
238 | 238 |
239 // Parse the response. | 239 // Parse the response. |
240 dbus::MessageReader reader(response); | 240 dbus::MessageReader reader(response); |
241 if (reader.PopFileDescriptor(&fd) && | 241 if (reader.PopFileDescriptor(&fd) && |
242 reader.PopUint16(&read_mtu) && | 242 reader.PopUint16(&read_mtu) && |
243 reader.PopUint16(&write_mtu)) { | 243 reader.PopUint16(&write_mtu)) { |
244 callback.Run(fd, read_mtu, write_mtu); | 244 fd.CheckValidity(); |
| 245 DCHECK(fd.is_valid()); |
| 246 |
| 247 VLOG(1) << "OnAcquireSuccess - fd: "<< fd.value() |
| 248 <<", read MTU: " << read_mtu |
| 249 <<", write MTU: " << write_mtu; |
| 250 |
| 251 // The ownership of the file descriptor is transferred to the user |
| 252 // application. |
| 253 callback.Run(&fd, read_mtu, write_mtu); |
245 return; | 254 return; |
246 } | 255 } |
247 | 256 |
248 error_callback.Run( | 257 error_callback.Run( |
249 kUnexpectedResponse, | 258 kUnexpectedResponse, |
250 "Failed to retrieve file descriptor, read MTU and write MTU."); | 259 "Failed to retrieve file descriptor, read MTU and write MTU."); |
251 } | 260 } |
252 | 261 |
253 // Called when a response for a failed method call is received. | 262 // Called when a response for a failed method call is received. |
254 void OnError(const ErrorCallback& error_callback, | 263 void OnError(const ErrorCallback& error_callback, |
(...skipping 27 matching lines...) Expand all Loading... |
282 } | 291 } |
283 | 292 |
284 BluetoothMediaTransportClient::~BluetoothMediaTransportClient() { | 293 BluetoothMediaTransportClient::~BluetoothMediaTransportClient() { |
285 } | 294 } |
286 | 295 |
287 BluetoothMediaTransportClient* BluetoothMediaTransportClient::Create() { | 296 BluetoothMediaTransportClient* BluetoothMediaTransportClient::Create() { |
288 return new BluetoothMediaTransportClientImpl(); | 297 return new BluetoothMediaTransportClientImpl(); |
289 } | 298 } |
290 | 299 |
291 } // namespace chromeos | 300 } // namespace chromeos |
OLD | NEW |