| 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);
|
|
|