| 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/bluetooth_remote_gatt_characteristic_bluez.h" | 5 #include "device/bluetooth/bluetooth_remote_gatt_characteristic_bluez.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 #include <utility> |
| 8 | 9 |
| 9 #include "base/logging.h" | 10 #include "base/logging.h" |
| 10 #include "base/strings/stringprintf.h" | 11 #include "base/strings/stringprintf.h" |
| 11 #include "device/bluetooth/bluetooth_adapter_bluez.h" | 12 #include "device/bluetooth/bluetooth_adapter_bluez.h" |
| 12 #include "device/bluetooth/bluetooth_device.h" | 13 #include "device/bluetooth/bluetooth_device.h" |
| 13 #include "device/bluetooth/bluetooth_gatt_notify_session_bluez.h" | 14 #include "device/bluetooth/bluetooth_gatt_notify_session_bluez.h" |
| 14 #include "device/bluetooth/bluetooth_remote_gatt_characteristic_bluez.h" | 15 #include "device/bluetooth/bluetooth_remote_gatt_characteristic_bluez.h" |
| 15 #include "device/bluetooth/bluetooth_remote_gatt_descriptor_bluez.h" | 16 #include "device/bluetooth/bluetooth_remote_gatt_descriptor_bluez.h" |
| 16 #include "device/bluetooth/bluetooth_remote_gatt_service_bluez.h" | 17 #include "device/bluetooth/bluetooth_remote_gatt_service_bluez.h" |
| 17 #include "device/bluetooth/dbus/bluez_dbus_manager.h" | 18 #include "device/bluetooth/dbus/bluez_dbus_manager.h" |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 } | 245 } |
| 245 | 246 |
| 246 ++num_notify_sessions_; | 247 ++num_notify_sessions_; |
| 247 DCHECK(service_); | 248 DCHECK(service_); |
| 248 DCHECK(service_->GetAdapter()); | 249 DCHECK(service_->GetAdapter()); |
| 249 DCHECK(service_->GetDevice()); | 250 DCHECK(service_->GetDevice()); |
| 250 scoped_ptr<device::BluetoothGattNotifySession> session( | 251 scoped_ptr<device::BluetoothGattNotifySession> session( |
| 251 new BluetoothGattNotifySessionBlueZ( | 252 new BluetoothGattNotifySessionBlueZ( |
| 252 service_->GetAdapter(), service_->GetDevice()->GetAddress(), | 253 service_->GetAdapter(), service_->GetDevice()->GetAddress(), |
| 253 service_->GetIdentifier(), GetIdentifier(), object_path_)); | 254 service_->GetIdentifier(), GetIdentifier(), object_path_)); |
| 254 callback.Run(session.Pass()); | 255 callback.Run(std::move(session)); |
| 255 return; | 256 return; |
| 256 } | 257 } |
| 257 | 258 |
| 258 num_notify_sessions_ = 0; | 259 num_notify_sessions_ = 0; |
| 259 } | 260 } |
| 260 | 261 |
| 261 // Queue the callbacks if there is a pending call to bluetoothd. | 262 // Queue the callbacks if there is a pending call to bluetoothd. |
| 262 if (notify_call_pending_) { | 263 if (notify_call_pending_) { |
| 263 pending_start_notify_calls_.push(std::make_pair(callback, error_callback)); | 264 pending_start_notify_calls_.push(std::make_pair(callback, error_callback)); |
| 264 return; | 265 return; |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 410 ++num_notify_sessions_; | 411 ++num_notify_sessions_; |
| 411 notify_call_pending_ = false; | 412 notify_call_pending_ = false; |
| 412 | 413 |
| 413 // Invoke the queued callbacks for this operation. | 414 // Invoke the queued callbacks for this operation. |
| 414 DCHECK(service_); | 415 DCHECK(service_); |
| 415 DCHECK(service_->GetDevice()); | 416 DCHECK(service_->GetDevice()); |
| 416 scoped_ptr<device::BluetoothGattNotifySession> session( | 417 scoped_ptr<device::BluetoothGattNotifySession> session( |
| 417 new BluetoothGattNotifySessionBlueZ( | 418 new BluetoothGattNotifySessionBlueZ( |
| 418 service_->GetAdapter(), service_->GetDevice()->GetAddress(), | 419 service_->GetAdapter(), service_->GetDevice()->GetAddress(), |
| 419 service_->GetIdentifier(), GetIdentifier(), object_path_)); | 420 service_->GetIdentifier(), GetIdentifier(), object_path_)); |
| 420 callback.Run(session.Pass()); | 421 callback.Run(std::move(session)); |
| 421 | 422 |
| 422 ProcessStartNotifyQueue(); | 423 ProcessStartNotifyQueue(); |
| 423 } | 424 } |
| 424 | 425 |
| 425 void BluetoothRemoteGattCharacteristicBlueZ::OnStartNotifyError( | 426 void BluetoothRemoteGattCharacteristicBlueZ::OnStartNotifyError( |
| 426 const ErrorCallback& error_callback, | 427 const ErrorCallback& error_callback, |
| 427 const std::string& error_name, | 428 const std::string& error_name, |
| 428 const std::string& error_message) { | 429 const std::string& error_message) { |
| 429 VLOG(1) << "Failed to start notifications from characteristic: " | 430 VLOG(1) << "Failed to start notifications from characteristic: " |
| 430 << object_path_.value() << ": " << error_name << ", " | 431 << object_path_.value() << ": " << error_name << ", " |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 466 | 467 |
| 467 void BluetoothRemoteGattCharacteristicBlueZ::ProcessStartNotifyQueue() { | 468 void BluetoothRemoteGattCharacteristicBlueZ::ProcessStartNotifyQueue() { |
| 468 while (!pending_start_notify_calls_.empty()) { | 469 while (!pending_start_notify_calls_.empty()) { |
| 469 PendingStartNotifyCall callbacks = pending_start_notify_calls_.front(); | 470 PendingStartNotifyCall callbacks = pending_start_notify_calls_.front(); |
| 470 pending_start_notify_calls_.pop(); | 471 pending_start_notify_calls_.pop(); |
| 471 StartNotifySession(callbacks.first, callbacks.second); | 472 StartNotifySession(callbacks.first, callbacks.second); |
| 472 } | 473 } |
| 473 } | 474 } |
| 474 | 475 |
| 475 } // namespace bluez | 476 } // namespace bluez |
| OLD | NEW |