OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_mac.h" | 5 #include "device/bluetooth/bluetooth_remote_gatt_characteristic_mac.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
9 #include "base/strings/sys_string_conversions.h" | 9 #include "base/strings/sys_string_conversions.h" |
10 #include "base/threading/thread_task_runner_handle.h" | 10 #include "base/threading/thread_task_runner_handle.h" |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 characteristic_value_read_or_write_in_progress_(false), | 73 characteristic_value_read_or_write_in_progress_(false), |
74 start_notifications_in_progress_(false), | 74 start_notifications_in_progress_(false), |
75 weak_ptr_factory_(this) { | 75 weak_ptr_factory_(this) { |
76 uuid_ = BluetoothAdapterMac::BluetoothUUIDWithCBUUID( | 76 uuid_ = BluetoothAdapterMac::BluetoothUUIDWithCBUUID( |
77 [cb_characteristic_.get() UUID]); | 77 [cb_characteristic_.get() UUID]); |
78 identifier_ = base::SysNSStringToUTF8( | 78 identifier_ = base::SysNSStringToUTF8( |
79 [NSString stringWithFormat:@"%s-%p", uuid_.canonical_value().c_str(), | 79 [NSString stringWithFormat:@"%s-%p", uuid_.canonical_value().c_str(), |
80 (void*)cb_characteristic_]); | 80 (void*)cb_characteristic_]); |
81 } | 81 } |
82 | 82 |
83 BluetoothRemoteGattCharacteristicMac::~BluetoothRemoteGattCharacteristicMac() {} | 83 BluetoothRemoteGattCharacteristicMac::~BluetoothRemoteGattCharacteristicMac() { |
| 84 if (!read_characteristic_value_callbacks_.first.is_null()) { |
| 85 std::pair<ValueCallback, ErrorCallback> callbacks; |
| 86 callbacks.swap(read_characteristic_value_callbacks_); |
| 87 callbacks.second.Run(BluetoothGattService::GATT_ERROR_FAILED); |
| 88 } |
| 89 if (!write_characteristic_value_callbacks_.first.is_null()) { |
| 90 std::pair<base::Closure, ErrorCallback> callbacks; |
| 91 callbacks.swap(write_characteristic_value_callbacks_); |
| 92 callbacks.second.Run(BluetoothGattService::GATT_ERROR_FAILED); |
| 93 } |
| 94 } |
84 | 95 |
85 std::string BluetoothRemoteGattCharacteristicMac::GetIdentifier() const { | 96 std::string BluetoothRemoteGattCharacteristicMac::GetIdentifier() const { |
86 return identifier_; | 97 return identifier_; |
87 } | 98 } |
88 | 99 |
89 BluetoothUUID BluetoothRemoteGattCharacteristicMac::GetUUID() const { | 100 BluetoothUUID BluetoothRemoteGattCharacteristicMac::GetUUID() const { |
90 return uuid_; | 101 return uuid_; |
91 } | 102 } |
92 | 103 |
93 BluetoothGattCharacteristic::Properties | 104 BluetoothGattCharacteristic::Properties |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
357 return (GetProperties() & BluetoothGattCharacteristic::PROPERTY_WRITE) | 368 return (GetProperties() & BluetoothGattCharacteristic::PROPERTY_WRITE) |
358 ? CBCharacteristicWriteWithResponse | 369 ? CBCharacteristicWriteWithResponse |
359 : CBCharacteristicWriteWithoutResponse; | 370 : CBCharacteristicWriteWithoutResponse; |
360 } | 371 } |
361 | 372 |
362 CBCharacteristic* BluetoothRemoteGattCharacteristicMac::GetCBCharacteristic() | 373 CBCharacteristic* BluetoothRemoteGattCharacteristicMac::GetCBCharacteristic() |
363 const { | 374 const { |
364 return cb_characteristic_.get(); | 375 return cb_characteristic_.get(); |
365 } | 376 } |
366 } // namespace device. | 377 } // namespace device. |
OLD | NEW |