Chromium Code Reviews| Index: third_party/WebKit/Source/modules/bluetooth/BluetoothDevice.cpp |
| diff --git a/third_party/WebKit/Source/modules/bluetooth/BluetoothDevice.cpp b/third_party/WebKit/Source/modules/bluetooth/BluetoothDevice.cpp |
| index 1b2008e1860d509bf5671d3eeaa8752e39731fdf..bb80f7bd03bbd04c06b07374f8c0c1fb64ff5659 100644 |
| --- a/third_party/WebKit/Source/modules/bluetooth/BluetoothDevice.cpp |
| +++ b/third_party/WebKit/Source/modules/bluetooth/BluetoothDevice.cpp |
| @@ -45,6 +45,10 @@ BluetoothDevice::getOrCreateBluetoothRemoteGATTService( |
| std::move(webService)); |
| } |
| +bool BluetoothDevice::isValidService(const String& serviceInstanceId) { |
| + return m_attributeInstanceMap->containsService(serviceInstanceId); |
| +} |
| + |
| void BluetoothDevice::dispose() { |
| disconnectGATTIfConnected(); |
| } |
| @@ -64,6 +68,13 @@ bool BluetoothDevice::disconnectGATTIfConnected() { |
| return false; |
| } |
| +void BluetoothDevice::CleanupDisconnectedDeviceAndFireEvent() { |
| + m_gatt->setConnected(false); |
|
scheib
2016/11/04 22:53:50
Here can we either if (connected), or DCHECK(conne
ortuno
2016/11/06 22:44:12
Done.
|
| + m_gatt->ClearActiveAlgorithms(); |
| + m_attributeInstanceMap->Clear(); |
| + dispatchEvent(Event::createBubble(EventTypeNames::gattserverdisconnected)); |
| +} |
| + |
| const WTF::AtomicString& BluetoothDevice::interfaceName() const { |
| return EventTargetNames::BluetoothDevice; |
| } |
| @@ -73,11 +84,10 @@ ExecutionContext* BluetoothDevice::getExecutionContext() const { |
| } |
| void BluetoothDevice::dispatchGattServerDisconnected() { |
| - if (m_gatt->connected()) { |
| - m_gatt->setConnected(false); |
| - m_gatt->ClearActiveAlgorithms(); |
| - dispatchEvent(Event::createBubble(EventTypeNames::gattserverdisconnected)); |
| + if (!m_gatt->connected()) { |
| + return; |
| } |
| + CleanupDisconnectedDeviceAndFireEvent(); |
| } |
| DEFINE_TRACE(BluetoothDevice) { |