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

Side by Side Diff: Source/modules/bluetooth/BluetoothGATTCharacteristic.cpp

Issue 1147243004: bluetooth: readValue Blink implementation (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@bluetooth-read-value-interface
Patch Set: readValue blink Implementation. Created 5 years, 6 months 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
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 "config.h" 5 #include "config.h"
6 #include "modules/bluetooth/BluetoothGATTCharacteristic.h" 6 #include "modules/bluetooth/BluetoothGATTCharacteristic.h"
7 7
8 #include "bindings/core/v8/CallbackPromiseAdapter.h" 8 #include "bindings/core/v8/CallbackPromiseAdapter.h"
9 #include "bindings/core/v8/ScriptPromise.h" 9 #include "bindings/core/v8/ScriptPromise.h"
10 #include "bindings/core/v8/ScriptPromiseResolver.h" 10 #include "bindings/core/v8/ScriptPromiseResolver.h"
11 #include "core/dom/DOMException.h" 11 #include "core/dom/DOMException.h"
12 #include "core/dom/ExceptionCode.h" 12 #include "core/dom/ExceptionCode.h"
13 #include "modules/bluetooth/BluetoothArrayBuffer.h"
13 #include "modules/bluetooth/BluetoothError.h" 14 #include "modules/bluetooth/BluetoothError.h"
14 #include "public/platform/Platform.h" 15 #include "public/platform/Platform.h"
15 #include "public/platform/modules/bluetooth/WebBluetooth.h" 16 #include "public/platform/modules/bluetooth/WebBluetooth.h"
16 #include "wtf/OwnPtr.h" 17 #include "wtf/OwnPtr.h"
17 18
18 namespace blink { 19 namespace blink {
19 20
20 BluetoothGATTCharacteristic::BluetoothGATTCharacteristic(PassOwnPtr<WebBluetooth GATTCharacteristic> webCharacteristic) 21 BluetoothGATTCharacteristic::BluetoothGATTCharacteristic(PassOwnPtr<WebBluetooth GATTCharacteristic> webCharacteristic)
21 : m_webCharacteristic(webCharacteristic) 22 : m_webCharacteristic(webCharacteristic)
22 { 23 {
23 } 24 }
24 25
25 BluetoothGATTCharacteristic* BluetoothGATTCharacteristic::take(ScriptPromiseReso lver*, WebBluetoothGATTCharacteristic* webCharacteristicRawPointer) 26 BluetoothGATTCharacteristic* BluetoothGATTCharacteristic::take(ScriptPromiseReso lver*, WebBluetoothGATTCharacteristic* webCharacteristicRawPointer)
26 { 27 {
27 if (!webCharacteristicRawPointer) { 28 if (!webCharacteristicRawPointer) {
28 return nullptr; 29 return nullptr;
29 } 30 }
30 return new BluetoothGATTCharacteristic(adoptPtr(webCharacteristicRawPointer) ); 31 return new BluetoothGATTCharacteristic(adoptPtr(webCharacteristicRawPointer) );
31 } 32 }
32 33
33 void BluetoothGATTCharacteristic::dispose(WebBluetoothGATTCharacteristic* webCha racteristic) 34 void BluetoothGATTCharacteristic::dispose(WebBluetoothGATTCharacteristic* webCha racteristic)
34 { 35 {
35 delete webCharacteristic; 36 delete webCharacteristic;
36 } 37 }
37 38
39 ScriptPromise BluetoothGATTCharacteristic::readValue(ScriptState* scriptState)
40 {
41 WebBluetooth * webbluetooth = Platform::current()->bluetooth();
Jeffrey Yasskin 2015/06/10 21:12:25 Only put a space on one side of the '*'.
ortuno 2015/06/11 00:10:52 Done.
42
43 RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver:: create(scriptState);
44 ScriptPromise promise = resolver->promise();
45 webbluetooth->readValue(m_webCharacteristic->characteristicInstanceID, new C allbackPromiseAdapter<BluetoothArrayBuffer, BluetoothError>(resolver));
46
47 return promise;
48 }
49
38 } // namespace blink 50 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698