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

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

Issue 2476173002: bluetooth: Invalidate characteristics when disconnecting (Closed)
Patch Set: Fix test expectations 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
« no previous file with comments | « third_party/WebKit/Source/modules/bluetooth/BluetoothDevice.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/modules/bluetooth/BluetoothRemoteGATTCharacteristic.cpp
diff --git a/third_party/WebKit/Source/modules/bluetooth/BluetoothRemoteGATTCharacteristic.cpp b/third_party/WebKit/Source/modules/bluetooth/BluetoothRemoteGATTCharacteristic.cpp
index 1177d433d2343380f65a46325157c8119712f8ab..8bf9ff2a4bbd9fab9eec87a93abaad2369ea0fbb 100644
--- a/third_party/WebKit/Source/modules/bluetooth/BluetoothRemoteGATTCharacteristic.cpp
+++ b/third_party/WebKit/Source/modules/bluetooth/BluetoothRemoteGATTCharacteristic.cpp
@@ -26,6 +26,9 @@ const char kGATTServerDisconnected[] =
"GATT Server disconnected while performing a GATT operation.";
const char kGATTServerNotConnected[] =
"GATT Server is disconnected. Cannot perform GATT operations.";
+const char kInvalidCharacteristic[] =
+ "Characteristic is no longer valid. Remember to retrieve the "
+ "characteristic again after reconnecting.";
DOMDataView* ConvertWebVectorToDataView(const WebVector<uint8_t>& webVector) {
static_assert(sizeof(*webVector.data()) == 1,
@@ -178,6 +181,13 @@ ScriptPromise BluetoothRemoteGATTCharacteristic::readValue(
DOMException::create(NetworkError, kGATTServerNotConnected));
}
+ if (!gatt()->device()->isValidCharacteristic(
+ m_webCharacteristic->characteristicInstanceID)) {
+ return ScriptPromise::rejectWithDOMException(
+ scriptState,
+ DOMException::create(InvalidStateError, kInvalidCharacteristic));
+ }
+
WebBluetooth* webbluetooth =
BluetoothSupplement::fromScriptState(scriptState);
@@ -250,6 +260,13 @@ ScriptPromise BluetoothRemoteGATTCharacteristic::writeValue(
DOMException::create(NetworkError, kGATTServerNotConnected));
}
+ if (!gatt()->device()->isValidCharacteristic(
+ m_webCharacteristic->characteristicInstanceID)) {
+ return ScriptPromise::rejectWithDOMException(
+ scriptState,
+ DOMException::create(InvalidStateError, kInvalidCharacteristic));
+ }
+
WebBluetooth* webbluetooth =
BluetoothSupplement::fromScriptState(scriptState);
// Partial implementation of writeValue algorithm:
@@ -332,6 +349,13 @@ ScriptPromise BluetoothRemoteGATTCharacteristic::startNotifications(
DOMException::create(NetworkError, kGATTServerNotConnected));
}
+ if (!gatt()->device()->isValidCharacteristic(
+ m_webCharacteristic->characteristicInstanceID)) {
+ return ScriptPromise::rejectWithDOMException(
+ scriptState,
+ DOMException::create(InvalidStateError, kInvalidCharacteristic));
+ }
+
WebBluetooth* webbluetooth =
BluetoothSupplement::fromScriptState(scriptState);
ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState);
@@ -358,6 +382,13 @@ ScriptPromise BluetoothRemoteGATTCharacteristic::stopNotifications(
DOMException::create(NetworkError, kGATTServerNotConnected));
}
+ if (!gatt()->device()->isValidCharacteristic(
+ m_webCharacteristic->characteristicInstanceID)) {
+ return ScriptPromise::rejectWithDOMException(
+ scriptState,
+ DOMException::create(InvalidStateError, kInvalidCharacteristic));
+ }
+
WebBluetooth* webbluetooth =
BluetoothSupplement::fromScriptState(scriptState);
ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState);
« no previous file with comments | « third_party/WebKit/Source/modules/bluetooth/BluetoothDevice.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698