| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "modules/bluetooth/BluetoothRemoteGATTCharacteristic.h" | 5 #include "modules/bluetooth/BluetoothRemoteGATTCharacteristic.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/CallbackPromiseAdapter.h" | 7 #include "bindings/core/v8/CallbackPromiseAdapter.h" |
| 8 #include "bindings/core/v8/ScriptPromise.h" | 8 #include "bindings/core/v8/ScriptPromise.h" |
| 9 #include "bindings/core/v8/ScriptPromiseResolver.h" | 9 #include "bindings/core/v8/ScriptPromiseResolver.h" |
| 10 #include "core/dom/DOMDataView.h" | 10 #include "core/dom/DOMDataView.h" |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 m_resolver->reject(BluetoothError::take(m_resolver, e)); | 165 m_resolver->reject(BluetoothError::take(m_resolver, e)); |
| 166 } | 166 } |
| 167 | 167 |
| 168 private: | 168 private: |
| 169 WeakPersistent<BluetoothRemoteGATTCharacteristic> m_webCharacteristic; | 169 WeakPersistent<BluetoothRemoteGATTCharacteristic> m_webCharacteristic; |
| 170 Persistent<ScriptPromiseResolver> m_resolver; | 170 Persistent<ScriptPromiseResolver> m_resolver; |
| 171 }; | 171 }; |
| 172 | 172 |
| 173 ScriptPromise BluetoothRemoteGATTCharacteristic::writeValue(ScriptState* scriptS
tate, const DOMArrayPiece& value) | 173 ScriptPromise BluetoothRemoteGATTCharacteristic::writeValue(ScriptState* scriptS
tate, const DOMArrayPiece& value) |
| 174 { | 174 { |
| 175 #if OS(MACOSX) | |
| 176 // TODO(jlebel): Remove when writeValue is implemented. | |
| 177 return ScriptPromise::rejectWithDOMException(scriptState, | |
| 178 DOMException::create(NotSupportedError, | |
| 179 "writeValue is not implemented yet. See https://goo.gl/J6ASzs")); | |
| 180 #endif // OS(MACOSX) | |
| 181 | |
| 182 WebBluetooth* webbluetooth = BluetoothSupplement::fromScriptState(scriptStat
e); | 175 WebBluetooth* webbluetooth = BluetoothSupplement::fromScriptState(scriptStat
e); |
| 183 // Partial implementation of writeValue algorithm: | 176 // Partial implementation of writeValue algorithm: |
| 184 // https://webbluetoothchrome.github.io/web-bluetooth/#dom-bluetoothgattchar
acteristic-writevalue | 177 // https://webbluetoothchrome.github.io/web-bluetooth/#dom-bluetoothgattchar
acteristic-writevalue |
| 185 | 178 |
| 186 // If bytes is more than 512 bytes long (the maximum length of an attribute | 179 // If bytes is more than 512 bytes long (the maximum length of an attribute |
| 187 // value, per Long Attribute Values) return a promise rejected with an | 180 // value, per Long Attribute Values) return a promise rejected with an |
| 188 // InvalidModificationError and abort. | 181 // InvalidModificationError and abort. |
| 189 if (value.byteLength() > 512) | 182 if (value.byteLength() > 512) |
| 190 return ScriptPromise::rejectWithDOMException(scriptState, DOMException::
create(InvalidModificationError, "Value can't exceed 512 bytes.")); | 183 return ScriptPromise::rejectWithDOMException(scriptState, DOMException::
create(InvalidModificationError, "Value can't exceed 512 bytes.")); |
| 191 | 184 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 | 228 |
| 236 DEFINE_TRACE(BluetoothRemoteGATTCharacteristic) | 229 DEFINE_TRACE(BluetoothRemoteGATTCharacteristic) |
| 237 { | 230 { |
| 238 visitor->trace(m_properties); | 231 visitor->trace(m_properties); |
| 239 visitor->trace(m_value); | 232 visitor->trace(m_value); |
| 240 EventTargetWithInlineData::trace(visitor); | 233 EventTargetWithInlineData::trace(visitor); |
| 241 ActiveDOMObject::trace(visitor); | 234 ActiveDOMObject::trace(visitor); |
| 242 } | 235 } |
| 243 | 236 |
| 244 } // namespace blink | 237 } // namespace blink |
| OLD | NEW |