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

Unified Diff: third_party/WebKit/Source/modules/bluetooth/BluetoothDevice.cpp

Issue 2478013002: bluetooth: Invalidate services upon disconnection (Closed)
Patch Set: Clean up Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
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);
+ 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) {

Powered by Google App Engine
This is Rietveld 408576698