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

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

Issue 2466223002: Implement WebBluetooth getDescriptor[s] (Closed)
Patch Set: Rebase 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 void BluetoothRemoteGATTDescriptor::setValue(DOMDataView* domDataView) {
42 m_value = domDataView;
43 }
44
45 ScriptPromise BluetoothRemoteGATTDescriptor::readValue(
46 ScriptState* scriptState) {
47 // TODO(668837): Implement WebBluetooth descriptor.readValue()
48 return ScriptPromise::rejectWithDOMException(
49 scriptState,
50 DOMException::create(NotSupportedError,
51 "descriptor readValue is not implemented "
52 "yet. See https://goo.gl/J6ASzs"));
53 }
54
55 ScriptPromise BluetoothRemoteGATTDescriptor::writeValue(
56 ScriptState* scriptState,
57 const DOMArrayPiece& value) {
58 // TODO(668838): Implement WebBluetooth descriptor.writeValue()
59 return ScriptPromise::rejectWithDOMException(
60 scriptState,
61 DOMException::create(NotSupportedError,
62 "descriptor writeValue is not implemented "
63 "yet. See https://goo.gl/J6ASzs"));
64 }
65
66 DEFINE_TRACE(BluetoothRemoteGATTDescriptor) {
67 visitor->trace(m_characteristic);
68 visitor->trace(m_value);
69 }
70
71 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698