OLD | NEW |
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 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
478 // Connection request should only be made if there are no active | 478 // Connection request should only be made if there are no active |
479 // connections. | 479 // connections. |
480 DCHECK(gatt_connections_.empty()); | 480 DCHECK(gatt_connections_.empty()); |
481 | 481 |
482 for (const auto& error_callback : create_gatt_connection_error_callbacks_) | 482 for (const auto& error_callback : create_gatt_connection_error_callbacks_) |
483 error_callback.Run(error); | 483 error_callback.Run(error); |
484 create_gatt_connection_success_callbacks_.clear(); | 484 create_gatt_connection_success_callbacks_.clear(); |
485 create_gatt_connection_error_callbacks_.clear(); | 485 create_gatt_connection_error_callbacks_.clear(); |
486 } | 486 } |
487 | 487 |
488 void BluetoothDevice::DidDisconnectGatt(bool notifyDeviceChanged) { | 488 void BluetoothDevice::DidDisconnectGatt() { |
489 gatt_services_.clear(); | |
490 device_uuids_.ClearServiceUUIDs(); | |
491 SetGattServicesDiscoveryComplete(false); | |
492 | |
493 // Pending calls to connect GATT are not expected, if they were then | 489 // Pending calls to connect GATT are not expected, if they were then |
494 // DidFailToConnectGatt should have been called. | 490 // DidFailToConnectGatt should have been called. |
495 DCHECK(create_gatt_connection_error_callbacks_.empty()); | 491 DCHECK(create_gatt_connection_error_callbacks_.empty()); |
496 | 492 |
497 // Invalidate all BluetoothGattConnection objects. | 493 // Invalidate all BluetoothGattConnection objects. |
498 for (BluetoothGattConnection* connection : gatt_connections_) { | 494 for (BluetoothGattConnection* connection : gatt_connections_) { |
499 connection->InvalidateConnectionReference(); | 495 connection->InvalidateConnectionReference(); |
500 } | 496 } |
501 gatt_connections_.clear(); | 497 gatt_connections_.clear(); |
502 if (notifyDeviceChanged) | 498 GetAdapter()->NotifyDeviceChanged(this); |
503 GetAdapter()->NotifyDeviceChanged(this); | |
504 } | 499 } |
505 | 500 |
506 void BluetoothDevice::AddGattConnection(BluetoothGattConnection* connection) { | 501 void BluetoothDevice::AddGattConnection(BluetoothGattConnection* connection) { |
507 auto result = gatt_connections_.insert(connection); | 502 auto result = gatt_connections_.insert(connection); |
508 DCHECK(result.second); // Check insert happened; there was no duplicate. | 503 DCHECK(result.second); // Check insert happened; there was no duplicate. |
509 } | 504 } |
510 | 505 |
511 void BluetoothDevice::RemoveGattConnection( | 506 void BluetoothDevice::RemoveGattConnection( |
512 BluetoothGattConnection* connection) { | 507 BluetoothGattConnection* connection) { |
513 size_t erased_count = gatt_connections_.erase(connection); | 508 size_t erased_count = gatt_connections_.erase(connection); |
(...skipping 27 matching lines...) Expand all Loading... |
541 if (power < INT8_MIN) { | 536 if (power < INT8_MIN) { |
542 return INT8_MIN; | 537 return INT8_MIN; |
543 } | 538 } |
544 if (power > INT8_MAX) { | 539 if (power > INT8_MAX) { |
545 return INT8_MAX; | 540 return INT8_MAX; |
546 } | 541 } |
547 return static_cast<int8_t>(power); | 542 return static_cast<int8_t>(power); |
548 } | 543 } |
549 | 544 |
550 } // namespace device | 545 } // namespace device |
OLD | NEW |