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 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 m_resolver->reject(BluetoothError::take(m_resolver, e)); | 167 m_resolver->reject(BluetoothError::take(m_resolver, e)); |
168 } | 168 } |
169 | 169 |
170 private: | 170 private: |
171 WeakPersistent<BluetoothRemoteGATTCharacteristic> m_webCharacteristic; | 171 WeakPersistent<BluetoothRemoteGATTCharacteristic> m_webCharacteristic; |
172 Persistent<ScriptPromiseResolver> m_resolver; | 172 Persistent<ScriptPromiseResolver> m_resolver; |
173 }; | 173 }; |
174 | 174 |
175 ScriptPromise BluetoothRemoteGATTCharacteristic::writeValue(ScriptState* scriptS
tate, const DOMArrayPiece& value) | 175 ScriptPromise BluetoothRemoteGATTCharacteristic::writeValue(ScriptState* scriptS
tate, const DOMArrayPiece& value) |
176 { | 176 { |
177 #if OS(MACOSX) | |
178 // TODO(jlebel): Remove when writeValue is implemented. | |
179 return ScriptPromise::rejectWithDOMException(scriptState, | |
180 DOMException::create(NotSupportedError, | |
181 "writeValue is not implemented yet. See https://goo.gl/J6ASzs")); | |
182 #endif // OS(MACOSX) | |
183 | |
184 WebBluetooth* webbluetooth = BluetoothSupplement::fromScriptState(scriptStat
e); | 177 WebBluetooth* webbluetooth = BluetoothSupplement::fromScriptState(scriptStat
e); |
185 // Partial implementation of writeValue algorithm: | 178 // Partial implementation of writeValue algorithm: |
186 // https://webbluetoothchrome.github.io/web-bluetooth/#dom-bluetoothgattchar
acteristic-writevalue | 179 // https://webbluetoothchrome.github.io/web-bluetooth/#dom-bluetoothgattchar
acteristic-writevalue |
187 | 180 |
188 // If bytes is more than 512 bytes long (the maximum length of an attribute | 181 // If bytes is more than 512 bytes long (the maximum length of an attribute |
189 // value, per Long Attribute Values) return a promise rejected with an | 182 // value, per Long Attribute Values) return a promise rejected with an |
190 // InvalidModificationError and abort. | 183 // InvalidModificationError and abort. |
191 if (value.byteLength() > 512) | 184 if (value.byteLength() > 512) |
192 return ScriptPromise::rejectWithDOMException(scriptState, DOMException::
create(InvalidModificationError, "Value can't exceed 512 bytes.")); | 185 return ScriptPromise::rejectWithDOMException(scriptState, DOMException::
create(InvalidModificationError, "Value can't exceed 512 bytes.")); |
193 | 186 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 DEFINE_TRACE(BluetoothRemoteGATTCharacteristic) | 231 DEFINE_TRACE(BluetoothRemoteGATTCharacteristic) |
239 { | 232 { |
240 visitor->trace(m_service); | 233 visitor->trace(m_service); |
241 visitor->trace(m_properties); | 234 visitor->trace(m_properties); |
242 visitor->trace(m_value); | 235 visitor->trace(m_value); |
243 EventTargetWithInlineData::trace(visitor); | 236 EventTargetWithInlineData::trace(visitor); |
244 ActiveDOMObject::trace(visitor); | 237 ActiveDOMObject::trace(visitor); |
245 } | 238 } |
246 | 239 |
247 } // namespace blink | 240 } // namespace blink |
OLD | NEW |