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

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

Issue 2478013002: bluetooth: Invalidate services upon disconnection (Closed)
Patch Set: Address scheib's comments 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..2fbb88fd7f6e473e0d698cea5b1e1e263972ef98 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();
}
@@ -53,15 +57,21 @@ void BluetoothDevice::contextDestroyed() {
disconnectGATTIfConnected();
}
-bool BluetoothDevice::disconnectGATTIfConnected() {
+void BluetoothDevice::disconnectGATTIfConnected() {
if (m_gatt->connected()) {
m_gatt->setConnected(false);
m_gatt->ClearActiveAlgorithms();
BluetoothSupplement::fromExecutionContext(getExecutionContext())
->disconnect(id());
- return true;
}
- return false;
+}
+
+void BluetoothDevice::cleanupDisconnectedDeviceAndFireEvent() {
+ DCHECK(m_gatt->connected());
+ m_gatt->setConnected(false);
+ m_gatt->ClearActiveAlgorithms();
+ m_attributeInstanceMap->Clear();
+ dispatchEvent(Event::createBubble(EventTypeNames::gattserverdisconnected));
}
const WTF::AtomicString& BluetoothDevice::interfaceName() const {
@@ -73,11 +83,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