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

Side by Side Diff: device/bluetooth/bluetooth_remote_gatt_characteristic_mac.mm

Issue 2347133002: bluetooth: Call error callback when characteristics get destroyed during a GATT Event (mac) (Closed)
Patch Set: 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 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
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
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.
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698