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

Side by Side Diff: device/bluetooth/bluetooth_device.cc

Issue 2625013003: bluetooth: bluez: Fixed issue with missing notifications after reconnect. (Closed)
Patch Set: Created 3 years, 11 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_device.h" 5 #include "device/bluetooth/bluetooth_device.h"
6 6
7 #include <iterator> 7 #include <iterator>
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 10
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 // Connection request should only be made if there are no active 463 // Connection request should only be made if there are no active
464 // connections. 464 // connections.
465 DCHECK(gatt_connections_.empty()); 465 DCHECK(gatt_connections_.empty());
466 466
467 for (const auto& error_callback : create_gatt_connection_error_callbacks_) 467 for (const auto& error_callback : create_gatt_connection_error_callbacks_)
468 error_callback.Run(error); 468 error_callback.Run(error);
469 create_gatt_connection_success_callbacks_.clear(); 469 create_gatt_connection_success_callbacks_.clear();
470 create_gatt_connection_error_callbacks_.clear(); 470 create_gatt_connection_error_callbacks_.clear();
471 } 471 }
472 472
473 void BluetoothDevice::DidDisconnectGatt() { 473 void BluetoothDevice::DidDisconnectGatt(bool notifyDeviceChanged) {
474 gatt_services_.clear();
475 device_uuids_.ClearServiceUUIDs();
476 SetGattServicesDiscoveryComplete(false);
477
474 // Pending calls to connect GATT are not expected, if they were then 478 // Pending calls to connect GATT are not expected, if they were then
475 // DidFailToConnectGatt should have been called. 479 // DidFailToConnectGatt should have been called.
476 DCHECK(create_gatt_connection_error_callbacks_.empty()); 480 DCHECK(create_gatt_connection_error_callbacks_.empty());
477 481
478 // Invalidate all BluetoothGattConnection objects. 482 // Invalidate all BluetoothGattConnection objects.
479 for (BluetoothGattConnection* connection : gatt_connections_) { 483 for (BluetoothGattConnection* connection : gatt_connections_) {
480 connection->InvalidateConnectionReference(); 484 connection->InvalidateConnectionReference();
481 } 485 }
482 gatt_connections_.clear(); 486 gatt_connections_.clear();
483 GetAdapter()->NotifyDeviceChanged(this); 487 if (notifyDeviceChanged)
488 GetAdapter()->NotifyDeviceChanged(this);
484 } 489 }
485 490
486 void BluetoothDevice::AddGattConnection(BluetoothGattConnection* connection) { 491 void BluetoothDevice::AddGattConnection(BluetoothGattConnection* connection) {
487 auto result = gatt_connections_.insert(connection); 492 auto result = gatt_connections_.insert(connection);
488 DCHECK(result.second); // Check insert happened; there was no duplicate. 493 DCHECK(result.second); // Check insert happened; there was no duplicate.
489 } 494 }
490 495
491 void BluetoothDevice::RemoveGattConnection( 496 void BluetoothDevice::RemoveGattConnection(
492 BluetoothGattConnection* connection) { 497 BluetoothGattConnection* connection) {
493 size_t erased_count = gatt_connections_.erase(connection); 498 size_t erased_count = gatt_connections_.erase(connection);
(...skipping 27 matching lines...) Expand all
521 if (power < INT8_MIN) { 526 if (power < INT8_MIN) {
522 return INT8_MIN; 527 return INT8_MIN;
523 } 528 }
524 if (power > INT8_MAX) { 529 if (power > INT8_MAX) {
525 return INT8_MAX; 530 return INT8_MAX;
526 } 531 }
527 return static_cast<int8_t>(power); 532 return static_cast<int8_t>(power);
528 } 533 }
529 534
530 } // namespace device 535 } // namespace device
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698