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

Side by Side Diff: third_party/WebKit/Source/modules/bluetooth/BluetoothRemoteGATTDescriptor.cpp

Issue 2466223002: Implement WebBluetooth getDescriptor[s] (Closed)
Patch Set: Updating cross-origin-objects-exceptions.html Created 4 years 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "modules/bluetooth/BluetoothRemoteGATTDescriptor.h"
6
7 #include "bindings/core/v8/CallbackPromiseAdapter.h"
8 #include "bindings/core/v8/ScriptPromise.h"
9 #include "bindings/core/v8/ScriptPromiseResolver.h"
10 #include "core/dom/DOMDataView.h"
11 #include "core/dom/DOMException.h"
12 #include "core/dom/ExceptionCode.h"
13 #include "core/events/Event.h"
14 #include "core/inspector/ConsoleMessage.h"
15 #include "modules/bluetooth/BluetoothError.h"
16 #include "modules/bluetooth/BluetoothRemoteGATTService.h"
17 #include "modules/bluetooth/BluetoothSupplement.h"
18 #include "public/platform/modules/bluetooth/WebBluetooth.h"
19 #include <memory>
20
21 namespace blink {
22
23 BluetoothRemoteGATTDescriptor::BluetoothRemoteGATTDescriptor(
24 std::unique_ptr<WebBluetoothRemoteGATTDescriptorInit> webDescriptor,
25 BluetoothRemoteGATTCharacteristic* characteristic)
26 : m_webDescriptor(std::move(webDescriptor)),
27 m_characteristic(characteristic) {}
28
29 BluetoothRemoteGATTDescriptor* BluetoothRemoteGATTDescriptor::create(
30 std::unique_ptr<WebBluetoothRemoteGATTDescriptorInit> webDescriptor,
31 BluetoothRemoteGATTCharacteristic* characteristic) {
32 if (!webDescriptor) {
33 return nullptr;
34 }
35
36 BluetoothRemoteGATTDescriptor* descriptor = new BluetoothRemoteGATTDescriptor(
37 std::move(webDescriptor), characteristic);
38 return descriptor;
39 }
40
41 ScriptPromise BluetoothRemoteGATTDescriptor::readValue(
42 ScriptState* scriptState) {
43 // TODO(668837): Implement WebBluetooth descriptor.readValue()
44 return ScriptPromise::rejectWithDOMException(
45 scriptState,
46 DOMException::create(NotSupportedError,
47 "descriptor readValue is not implemented "
48 "yet. See https://goo.gl/J6ASzs"));
49 }
50
51 ScriptPromise BluetoothRemoteGATTDescriptor::writeValue(
52 ScriptState* scriptState,
53 const DOMArrayPiece& value) {
54 // TODO(668838): Implement WebBluetooth descriptor.writeValue()
55 return ScriptPromise::rejectWithDOMException(
56 scriptState,
57 DOMException::create(NotSupportedError,
58 "descriptor writeValue is not implemented "
59 "yet. See https://goo.gl/J6ASzs"));
60 }
61
62 DEFINE_TRACE(BluetoothRemoteGATTDescriptor) {
63 visitor->trace(m_characteristic);
64 visitor->trace(m_value);
65 }
66
67 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698