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

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

Issue 1991063002: Implement the gattserverdisconnected event. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@rename-web-bluetooth-device
Patch Set: Skip the new tests on Mac, where getCharacteristic isn't implemented yet. Created 4 years, 7 months 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/BluetoothRemoteGATTServer.cpp
diff --git a/third_party/WebKit/Source/modules/bluetooth/BluetoothRemoteGATTServer.cpp b/third_party/WebKit/Source/modules/bluetooth/BluetoothRemoteGATTServer.cpp
index 9c7c35de669077161c8e4d9e1d8415d5cfeb0036..4cccb105fbb2582b107ea8bf2e05cd4ad7e3ea32 100644
--- a/third_party/WebKit/Source/modules/bluetooth/BluetoothRemoteGATTServer.cpp
+++ b/third_party/WebKit/Source/modules/bluetooth/BluetoothRemoteGATTServer.cpp
@@ -9,6 +9,7 @@
#include "bindings/core/v8/ScriptPromiseResolver.h"
#include "core/dom/DOMException.h"
#include "core/dom/ExceptionCode.h"
+#include "core/events/Event.h"
#include "modules/bluetooth/BluetoothError.h"
#include "modules/bluetooth/BluetoothRemoteGATTService.h"
#include "modules/bluetooth/BluetoothSupplement.h"
@@ -67,15 +68,18 @@ ScriptPromise BluetoothRemoteGATTServer::connect(ScriptState* scriptState)
ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState);
ScriptPromise promise = resolver->promise();
- webbluetooth->connect(device()->id(), new ConnectCallback(device(), resolver));
+ webbluetooth->connect(device()->id(), device(), new ConnectCallback(device(), resolver));
return promise;
}
void BluetoothRemoteGATTServer::disconnect(ScriptState* scriptState)
{
+ if (!m_connected)
+ return;
m_connected = false;
WebBluetooth* webbluetooth = BluetoothSupplement::fromScriptState(scriptState);
webbluetooth->disconnect(device()->id());
+ device()->dispatchEvent(Event::createBubble(EventTypeNames::gattserverdisconnected));
}
ScriptPromise BluetoothRemoteGATTServer::getPrimaryService(ScriptState* scriptState, const StringOrUnsignedLong& service, ExceptionState& exceptionState)

Powered by Google App Engine
This is Rietveld 408576698