| 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 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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(bool notifyDeviceChanged) { | 473 void BluetoothDevice::DidDisconnectGatt() { |
| 474 gatt_services_.clear(); | |
| 475 device_uuids_.ClearServiceUUIDs(); | |
| 476 SetGattServicesDiscoveryComplete(false); | |
| 477 | |
| 478 // Pending calls to connect GATT are not expected, if they were then | 474 // Pending calls to connect GATT are not expected, if they were then |
| 479 // DidFailToConnectGatt should have been called. | 475 // DidFailToConnectGatt should have been called. |
| 480 DCHECK(create_gatt_connection_error_callbacks_.empty()); | 476 DCHECK(create_gatt_connection_error_callbacks_.empty()); |
| 481 | 477 |
| 482 // Invalidate all BluetoothGattConnection objects. | 478 // Invalidate all BluetoothGattConnection objects. |
| 483 for (BluetoothGattConnection* connection : gatt_connections_) { | 479 for (BluetoothGattConnection* connection : gatt_connections_) { |
| 484 connection->InvalidateConnectionReference(); | 480 connection->InvalidateConnectionReference(); |
| 485 } | 481 } |
| 486 gatt_connections_.clear(); | 482 gatt_connections_.clear(); |
| 487 if (notifyDeviceChanged) | 483 GetAdapter()->NotifyDeviceChanged(this); |
| 488 GetAdapter()->NotifyDeviceChanged(this); | |
| 489 } | 484 } |
| 490 | 485 |
| 491 void BluetoothDevice::AddGattConnection(BluetoothGattConnection* connection) { | 486 void BluetoothDevice::AddGattConnection(BluetoothGattConnection* connection) { |
| 492 auto result = gatt_connections_.insert(connection); | 487 auto result = gatt_connections_.insert(connection); |
| 493 DCHECK(result.second); // Check insert happened; there was no duplicate. | 488 DCHECK(result.second); // Check insert happened; there was no duplicate. |
| 494 } | 489 } |
| 495 | 490 |
| 496 void BluetoothDevice::RemoveGattConnection( | 491 void BluetoothDevice::RemoveGattConnection( |
| 497 BluetoothGattConnection* connection) { | 492 BluetoothGattConnection* connection) { |
| 498 size_t erased_count = gatt_connections_.erase(connection); | 493 size_t erased_count = gatt_connections_.erase(connection); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 526 if (power < INT8_MIN) { | 521 if (power < INT8_MIN) { |
| 527 return INT8_MIN; | 522 return INT8_MIN; |
| 528 } | 523 } |
| 529 if (power > INT8_MAX) { | 524 if (power > INT8_MAX) { |
| 530 return INT8_MAX; | 525 return INT8_MAX; |
| 531 } | 526 } |
| 532 return static_cast<int8_t>(power); | 527 return static_cast<int8_t>(power); |
| 533 } | 528 } |
| 534 | 529 |
| 535 } // namespace device | 530 } // namespace device |
| OLD | NEW |