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

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

Issue 2357993002: Don't send a value changed notification when a characteristic is written (Closed)
Patch Set: Adding #if to avoid the test for windows (and with the todo and the bug number) Created 4 years, 2 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
« no previous file with comments | « no previous file | device/bluetooth/bluetooth_remote_gatt_characteristic_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 characteristic_value_read_or_write_in_progress_ = false; 309 characteristic_value_read_or_write_in_progress_ = false;
310 if (error) { 310 if (error) {
311 VLOG(1) << "Bluetooth error while writing for characteristic, domain: " 311 VLOG(1) << "Bluetooth error while writing for characteristic, domain: "
312 << base::SysNSStringToUTF8(error.domain) 312 << base::SysNSStringToUTF8(error.domain)
313 << ", error code: " << error.code; 313 << ", error code: " << error.code;
314 BluetoothGattService::GattErrorCode error_code = 314 BluetoothGattService::GattErrorCode error_code =
315 BluetoothDeviceMac::GetGattErrorCodeFromNSError(error); 315 BluetoothDeviceMac::GetGattErrorCodeFromNSError(error);
316 callbacks.second.Run(error_code); 316 callbacks.second.Run(error_code);
317 return; 317 return;
318 } 318 }
319 NSData* nsdata_value = cb_characteristic_.get().value;
320 const uint8_t* buffer = static_cast<const uint8_t*>(nsdata_value.bytes);
321 std::vector<uint8_t> gatt_value(buffer, buffer + nsdata_value.length);
322 gatt_service_->GetMacAdapter()->NotifyGattCharacteristicValueChanged(this,
323 value_);
324 callbacks.first.Run(); 319 callbacks.first.Run();
325 } 320 }
326 321
327 void BluetoothRemoteGattCharacteristicMac::DidUpdateNotificationState( 322 void BluetoothRemoteGattCharacteristicMac::DidUpdateNotificationState(
328 NSError* error) { 323 NSError* error) {
329 std::vector<std::pair<NotifySessionCallback, ErrorCallback>> 324 std::vector<std::pair<NotifySessionCallback, ErrorCallback>>
330 reentrant_safe_callbacks; 325 reentrant_safe_callbacks;
331 reentrant_safe_callbacks.swap(start_notify_session_callbacks_); 326 reentrant_safe_callbacks.swap(start_notify_session_callbacks_);
332 start_notifications_in_progress_ = false; 327 start_notifications_in_progress_ = false;
333 if (error) { 328 if (error) {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 return (GetProperties() & BluetoothGattCharacteristic::PROPERTY_WRITE) 365 return (GetProperties() & BluetoothGattCharacteristic::PROPERTY_WRITE)
371 ? CBCharacteristicWriteWithResponse 366 ? CBCharacteristicWriteWithResponse
372 : CBCharacteristicWriteWithoutResponse; 367 : CBCharacteristicWriteWithoutResponse;
373 } 368 }
374 369
375 CBCharacteristic* BluetoothRemoteGattCharacteristicMac::GetCBCharacteristic() 370 CBCharacteristic* BluetoothRemoteGattCharacteristicMac::GetCBCharacteristic()
376 const { 371 const {
377 return cb_characteristic_.get(); 372 return cb_characteristic_.get();
378 } 373 }
379 } // namespace device. 374 } // namespace device.
OLDNEW
« no previous file with comments | « no previous file | device/bluetooth/bluetooth_remote_gatt_characteristic_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698