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

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

Issue 1427653003: bluetooth: Implement TxPower and RSSI of BluetoothAdvertisementData (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@my-origin
Patch Set: Change PowerValueAdapter to int8_t Created 5 years, 1 month 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/BluetoothDevice.h" 6 #include "modules/bluetooth/BluetoothDevice.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/BluetoothError.h" 13 #include "modules/bluetooth/BluetoothError.h"
14 #include "modules/bluetooth/BluetoothGATTRemoteServer.h" 14 #include "modules/bluetooth/BluetoothGATTRemoteServer.h"
15 #include "modules/bluetooth/BluetoothSupplement.h" 15 #include "modules/bluetooth/BluetoothSupplement.h"
16 #include "public/platform/modules/bluetooth/WebBluetooth.h" 16 #include "public/platform/modules/bluetooth/WebBluetooth.h"
17 17
18 namespace blink { 18 namespace blink {
19 19
20 BluetoothDevice::BluetoothDevice(PassOwnPtr<WebBluetoothDevice> webDevice) 20 BluetoothDevice::BluetoothDevice(PassOwnPtr<WebBluetoothDevice> webDevice)
21 : m_webDevice(webDevice) 21 : m_webDevice(webDevice)
22 , m_adData(BluetoothAdvertisingData::create(m_webDevice->txPower,
23 m_webDevice->rssi))
22 { 24 {
23 } 25 }
24 26
25 BluetoothDevice* BluetoothDevice::take(ScriptPromiseResolver*, PassOwnPtr<WebBlu etoothDevice> webDevice) 27 BluetoothDevice* BluetoothDevice::take(ScriptPromiseResolver*, PassOwnPtr<WebBlu etoothDevice> webDevice)
26 { 28 {
27 ASSERT(webDevice); 29 ASSERT(webDevice);
28 return new BluetoothDevice(webDevice); 30 return new BluetoothDevice(webDevice);
29 } 31 }
30 32
33 DEFINE_TRACE(BluetoothDevice)
34 {
35 visitor->trace(m_adData);
36 }
37
31 unsigned BluetoothDevice::deviceClass(bool& isNull) 38 unsigned BluetoothDevice::deviceClass(bool& isNull)
32 { 39 {
33 isNull = false; 40 isNull = false;
34 return m_webDevice->deviceClass; 41 return m_webDevice->deviceClass;
35 } 42 }
36 43
37 String BluetoothDevice::vendorIDSource() 44 String BluetoothDevice::vendorIDSource()
38 { 45 {
39 switch (m_webDevice->vendorIDSource) { 46 switch (m_webDevice->vendorIDSource) {
40 case WebBluetoothDevice::VendorIDSource::Unknown: return String(); 47 case WebBluetoothDevice::VendorIDSource::Unknown: return String();
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 WebBluetooth* webbluetooth = BluetoothSupplement::fromScriptState(scriptStat e); 88 WebBluetooth* webbluetooth = BluetoothSupplement::fromScriptState(scriptStat e);
82 if (!webbluetooth) 89 if (!webbluetooth)
83 return ScriptPromise::rejectWithDOMException(scriptState, DOMException:: create(NotSupportedError)); 90 return ScriptPromise::rejectWithDOMException(scriptState, DOMException:: create(NotSupportedError));
84 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState) ; 91 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState) ;
85 ScriptPromise promise = resolver->promise(); 92 ScriptPromise promise = resolver->promise();
86 webbluetooth->connectGATT(id(), new CallbackPromiseAdapter<BluetoothGATTRemo teServer, BluetoothError>(resolver)); 93 webbluetooth->connectGATT(id(), new CallbackPromiseAdapter<BluetoothGATTRemo teServer, BluetoothError>(resolver));
87 return promise; 94 return promise;
88 } 95 }
89 96
90 } // namespace blink 97 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698