diff options
author | ortuno <ortuno@chromium.org> | 2015-11-04 19:45:31 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-11-05 03:46:52 +0000 |
commit | 04751f481d8c83e2f1cc5630100477e51d2e2946 (patch) | |
tree | 1a50fee391d000f26e95ed825a0a9653d9ec9705 | |
parent | d396b11774ae6277de7d124a0775504e48db524f (diff) | |
download | chromium_src-04751f481d8c83e2f1cc5630100477e51d2e2946.zip chromium_src-04751f481d8c83e2f1cc5630100477e51d2e2946.tar.gz chromium_src-04751f481d8c83e2f1cc5630100477e51d2e2946.tar.bz2 |
bluetooth: Implement TxPower and RSSI of BluetoothAdvertisementData
Implements the TxPower member and RSSI member of BluetoothAdvertisementData:
https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothadvertisingdata-txpower
BUG=542756
Review URL: https://codereview.chromium.org/1427653003
Cr-Commit-Position: refs/heads/master@{#357993}
17 files changed, 379 insertions, 13 deletions
diff --git a/content/browser/bluetooth/bluetooth_dispatcher_host.cc b/content/browser/bluetooth/bluetooth_dispatcher_host.cc index 8c6c7d8..bc13e95 100644 --- a/content/browser/bluetooth/bluetooth_dispatcher_host.cc +++ b/content/browser/bluetooth/bluetooth_dispatcher_host.cc @@ -944,14 +944,18 @@ void BluetoothDispatcherHost::FinishClosingChooser( VLOG(1) << "\t" << uuid.canonical_value(); content::BluetoothDevice device_ipc( - device->GetAddress(), // id - device->GetName(), // name - device->GetBluetoothClass(), // device_class - device->GetVendorIDSource(), // vendor_id_source - device->GetVendorID(), // vendor_id - device->GetProductID(), // product_id - device->GetDeviceID(), // product_version - device->IsPaired(), // paired + device->GetAddress(), // id + device->GetName(), // name + content::BluetoothDevice::ValidatePower( + device->GetInquiryTxPower()), // tx_power + content::BluetoothDevice::ValidatePower( + device->GetInquiryRSSI()), // rssi + device->GetBluetoothClass(), // device_class + device->GetVendorIDSource(), // vendor_id_source + device->GetVendorID(), // vendor_id + device->GetProductID(), // product_id + device->GetDeviceID(), // product_version + device->IsPaired(), // paired content::BluetoothDevice::UUIDsFromBluetoothUUIDs( device->GetUUIDs())); // uuids RecordRequestDeviceOutcome(UMARequestDeviceOutcome::SUCCESS); diff --git a/content/common/bluetooth/bluetooth_device.cc b/content/common/bluetooth/bluetooth_device.cc index baf930c..ece3ce4 100644 --- a/content/common/bluetooth/bluetooth_device.cc +++ b/content/common/bluetooth/bluetooth_device.cc @@ -11,6 +11,8 @@ namespace content { BluetoothDevice::BluetoothDevice() : id(""), name(base::string16()), + tx_power(device::BluetoothDevice::kUnknownPower), + rssi(device::BluetoothDevice::kUnknownPower), device_class(0), vendor_id_source( device::BluetoothDevice::VendorIDSource::VENDOR_ID_UNKNOWN), @@ -23,6 +25,8 @@ BluetoothDevice::BluetoothDevice() BluetoothDevice::BluetoothDevice( const std::string& id, const base::string16& name, + int8_t tx_power, + int8_t rssi, uint32 device_class, device::BluetoothDevice::VendorIDSource vendor_id_source, uint16 vendor_id, @@ -32,6 +36,8 @@ BluetoothDevice::BluetoothDevice( const std::vector<std::string>& uuids) : id(id), name(name), + tx_power(tx_power), + rssi(rssi), device_class(device_class), vendor_id_source(vendor_id_source), vendor_id(vendor_id), @@ -53,4 +59,10 @@ std::vector<std::string> BluetoothDevice::UUIDsFromBluetoothUUIDs( return uuids; } +// static +int8_t BluetoothDevice::ValidatePower(int16_t power) { + return ((power < -127) || (power > 127)) ? BluetoothDevice::kUnknownPower + : power; +} + } // namespace content diff --git a/content/common/bluetooth/bluetooth_device.h b/content/common/bluetooth/bluetooth_device.h index 73aef99..575f43a 100644 --- a/content/common/bluetooth/bluetooth_device.h +++ b/content/common/bluetooth/bluetooth_device.h @@ -20,6 +20,8 @@ struct CONTENT_EXPORT BluetoothDevice { BluetoothDevice(); BluetoothDevice(const std::string& id, const base::string16& name, + int8_t tx_power, + int8_t rssi, uint32 device_class, device::BluetoothDevice::VendorIDSource vendor_id_source, uint16 vendor_id, @@ -31,9 +33,18 @@ struct CONTENT_EXPORT BluetoothDevice { static std::vector<std::string> UUIDsFromBluetoothUUIDs( const device::BluetoothDevice::UUIDList& uuid_list); + // 127 is used as Unknown Power. According to the Bluetooth spec valid powers + // are between [-127, 127]. Anything outside this range will be considered + // Unknown Power. + static int8_t ValidatePower(int16_t power); + // TODO(ortuno): RSSI Unknown and Tx Power Unknown should have different + // values. Add kUnknownTxPower when implemented: http://crbug.com/551572 + const static int8_t kUnknownPower = 127; std::string id; base::string16 name; + int8_t tx_power; + int8_t rssi; uint32 device_class; device::BluetoothDevice::VendorIDSource vendor_id_source; uint16 vendor_id; diff --git a/content/common/bluetooth/bluetooth_messages.h b/content/common/bluetooth/bluetooth_messages.h index 85100ff..b7518c1 100644 --- a/content/common/bluetooth/bluetooth_messages.h +++ b/content/common/bluetooth/bluetooth_messages.h @@ -92,6 +92,8 @@ IPC_ENUM_TRAITS_MAX_VALUE( IPC_STRUCT_TRAITS_BEGIN(content::BluetoothDevice) IPC_STRUCT_TRAITS_MEMBER(id) IPC_STRUCT_TRAITS_MEMBER(name) + IPC_STRUCT_TRAITS_MEMBER(tx_power) + IPC_STRUCT_TRAITS_MEMBER(rssi) IPC_STRUCT_TRAITS_MEMBER(device_class) IPC_STRUCT_TRAITS_MEMBER(vendor_id_source) IPC_STRUCT_TRAITS_MEMBER(vendor_id) diff --git a/content/renderer/bluetooth/bluetooth_dispatcher.cc b/content/renderer/bluetooth/bluetooth_dispatcher.cc index a5097d8..5687bf7 100644 --- a/content/renderer/bluetooth/bluetooth_dispatcher.cc +++ b/content/renderer/bluetooth/bluetooth_dispatcher.cc @@ -551,9 +551,9 @@ void BluetoothDispatcher::OnRequestDeviceSuccess( pending_requests_.Lookup(request_id) ->onSuccess(blink::adoptWebPtr(new WebBluetoothDevice( WebString::fromUTF8(device.id), WebString(device.name), - device.device_class, GetWebVendorIdSource(device.vendor_id_source), - device.vendor_id, device.product_id, device.product_version, - device.paired, uuids))); + device.tx_power, device.rssi, device.device_class, + GetWebVendorIdSource(device.vendor_id_source), device.vendor_id, + device.product_id, device.product_version, device.paired, uuids))); pending_requests_.Remove(request_id); } diff --git a/content/shell/browser/layout_test/layout_test_bluetooth_adapter_provider.cc b/content/shell/browser/layout_test/layout_test_bluetooth_adapter_provider.cc index 054fb95..fc35b28 100644 --- a/content/shell/browser/layout_test/layout_test_bluetooth_adapter_provider.cc +++ b/content/shell/browser/layout_test/layout_test_bluetooth_adapter_provider.cc @@ -8,6 +8,9 @@ #include "base/bind_helpers.h" #include "base/format_macros.h" #include "base/location.h" +#include "base/strings/string_number_conversions.h" +#include "base/strings/string_split.h" +#include "base/strings/string_util.h" #include "base/strings/stringprintf.h" #include "base/thread_task_runner_handle.h" #include "device/bluetooth/bluetooth_adapter.h" @@ -20,6 +23,7 @@ #include "device/bluetooth/test/mock_bluetooth_gatt_notify_session.h" #include "testing/gmock/include/gmock/gmock.h" +using base::StringPiece; using device::BluetoothAdapter; using device::BluetoothDevice; using device::BluetoothGattCharacteristic; @@ -62,6 +66,10 @@ const char kHeartRateMeasurementUUID[] = "2a37"; const char kBodySensorLocation[] = "2a38"; const char kDeviceNameUUID[] = "2a00"; +const int kDefaultTxPower = -10; // TxPower of a device broadcasting at 0.1mW. +const int kDefaultRssi = -51; // RSSI at 1m from a device broadcasting at + // 0.1mW. + // Invokes Run() on the k-th argument of the function with no arguments. ACTION_TEMPLATE(RunCallback, HAS_1_TEMPLATE_PARAMS(int, k), @@ -143,6 +151,40 @@ LayoutTestBluetoothAdapterProvider::GetBluetoothAdapter( else if (fake_adapter_name == "") return NULL; + if (base::StartsWith(fake_adapter_name, "PowerValueAdapter", + base::CompareCase::SENSITIVE)) { + std::vector<StringPiece> args = + base::SplitStringPiece(fake_adapter_name, ":", base::KEEP_WHITESPACE, + base::SPLIT_WANT_NONEMPTY); + DCHECK(args[0] == "PowerValueAdapter"); + DCHECK(args.size() == 3) << "Should contain AdapterName:TxPower:RSSI"; + + int tx_power; + base::StringToInt(args[1], &tx_power); + DCHECK(tx_power >= INT8_MIN && tx_power <= INT8_MAX) + << "Must be between [-128, 127]"; + int rssi; + base::StringToInt(args[2], &rssi); + DCHECK(rssi >= INT8_MIN && rssi <= INT8_MAX) + << "Must be between [-128, 127]"; + return GetPowerValueAdapter(tx_power, rssi); + } + + if (base::StartsWith(fake_adapter_name, "PowerPresenceAdapter", + base::CompareCase::SENSITIVE)) { + std::vector<StringPiece> args = + base::SplitStringPiece(fake_adapter_name, ":", base::KEEP_WHITESPACE, + base::SPLIT_WANT_NONEMPTY); + DCHECK(args[0] == "PowerPresenceAdapter"); + DCHECK(args.size() == 3) + << "Should contain AdapterName:TxPowerPresent:RSSIPResent"; + DCHECK(args[1] == "true" || args[1] == "false"); + DCHECK(args[2] == "true" || args[2] == "false"); + + return GetPowerPresenceAdapter(args[1] == "true" /* tx_power_present */, + args[2] == "true" /* rssi_present */); + } + NOTREACHED() << fake_adapter_name; return NULL; } @@ -257,6 +299,35 @@ LayoutTestBluetoothAdapterProvider::GetEmptyAdapter() { // static scoped_refptr<NiceMockBluetoothAdapter> +LayoutTestBluetoothAdapterProvider::GetPowerValueAdapter(int8_t tx_power, + int8_t rssi) { + scoped_refptr<NiceMockBluetoothAdapter> adapter(GetEmptyAdapter()); + scoped_ptr<NiceMockBluetoothDevice> device(GetHeartRateDevice(adapter.get())); + + ON_CALL(*device, GetInquiryTxPower()).WillByDefault(Return(tx_power)); + ON_CALL(*device, GetInquiryRSSI()).WillByDefault(Return(rssi)); + + adapter->AddMockDevice(device.Pass()); + + return adapter; +} + +// static +scoped_refptr<NiceMockBluetoothAdapter> +LayoutTestBluetoothAdapterProvider::GetPowerPresenceAdapter( + bool tx_power_present, + bool rssi_present) { + // TODO(ortuno): RSSI Unknown and Tx Power Unknown should have different + // values. Add kUnknownTxPower when implemented: http://crbug.com/551572 + int tx_power = + tx_power_present ? kDefaultTxPower : BluetoothDevice::kUnknownPower; + int rssi = rssi_present ? kDefaultRssi : BluetoothDevice::kUnknownPower; + + return GetPowerValueAdapter(tx_power, rssi); +} + +// static +scoped_refptr<NiceMockBluetoothAdapter> LayoutTestBluetoothAdapterProvider::GetGlucoseHeartRateAdapter() { scoped_refptr<NiceMockBluetoothAdapter> adapter(GetEmptyAdapter()); diff --git a/content/shell/browser/layout_test/layout_test_bluetooth_adapter_provider.h b/content/shell/browser/layout_test/layout_test_bluetooth_adapter_provider.h index ca23237..39431b2 100644 --- a/content/shell/browser/layout_test/layout_test_bluetooth_adapter_provider.h +++ b/content/shell/browser/layout_test/layout_test_bluetooth_adapter_provider.h @@ -114,6 +114,32 @@ class LayoutTestBluetoothAdapterProvider { static scoped_refptr<testing::NiceMock<device::MockBluetoothAdapter>> GetEmptyAdapter(); + // |PowerValueAdapter|(tx_power, rssi) + // Inherits from |EmptyAdapter| + // Internal Structure: + // - |HeartRateDevice| + // - Mock Functions: + // - GetInquiryTxPower(): Returns tx_power + // - GetInquiryRSSI(): Returns rssi + static scoped_refptr<testing::NiceMock<device::MockBluetoothAdapter>> + GetPowerValueAdapter(int8_t tx_power, int8_t rssi); + + // |PowerPresenceAdapter|(tx_power_present, rssi_present) + // Inherits from |EmptyAdapter| + // Internal Structure: + // - |HeartRateDevice| + // - Mock Functions: + // - GetInquiryTxPower(): If tx_power_present is true, returns -10, + // the TxPower of a device broadcasting at 0.1mW. Otherwise + // returns 127 which denotes a missing Tx Power. + // TODO(ortuno): Change 127 to -128 when Tx Power Unknown value gets + // fixed: http://crbug.com/551572 + // - GetInquiryRSSI(): If rssi_present is true returns -51, + // the RSSI at 1m from a device broadcasting at 0.1mW. Otherwise + // returns 127 which denotes a missing RSSI. + static scoped_refptr<testing::NiceMock<device::MockBluetoothAdapter>> + GetPowerPresenceAdapter(bool tx_power_present, bool rssi_present); + // |GlucoseHeartRateAdapter| // Inherits from |EmptyAdapter| // Devices added: diff --git a/third_party/WebKit/LayoutTests/bluetooth/advertising-data.html b/third_party/WebKit/LayoutTests/bluetooth/advertising-data.html new file mode 100644 index 0000000..703ab81 --- /dev/null +++ b/third_party/WebKit/LayoutTests/bluetooth/advertising-data.html @@ -0,0 +1,116 @@ +<!DOCTYPE html> +<script src="../resources/testharness.js"></script> +<script src="../resources/testharnessreport.js"></script> +<script src="resources/bluetooth-helpers.js"></script> +<script> +'use strict'; + +test(function(t) { assert_true(window.testRunner instanceof Object); t.done(); }, + 'window.testRunner is required for the following tests.'); +// Tests that we are handling values returned from the underlying platform +// correctly. Only meant to be used by chromium. +[{ + name: 'Tx Power too low must result in nulled txPower.', + tx_power: -128, + expected_tx_power: null, + rssi: 0, + expected_rssi: 0 +}, { + name: 'RSSI too low must result in nulled rssi.', + tx_power: 0, + expected_tx_power: 0, + rssi: -128, + expected_rssi: null +}, { + name: 'Low Tx Power should appear in adData.', + tx_power: -127, + expected_tx_power: -127, + rssi: 0, + expected_rssi: 0 +}, { + name: 'Low RSSI should appear in adData.', + tx_power: 0, + expected_tx_power: 0, + rssi: -127, + expected_rssi: -127 +}, { + name: 'High Tx Power should appear in adData.', + // TODO(ortuno): According to the Bluetooth Spec Supplement, 127 is the + // the hightest possible valid value for Tx Power. Change to 127 when + // fixed: http://crbug.com/551572 + tx_power: 126, + expected_tx_power: 126, + rssi: 0, + expected_rssi: 0 +}, { + name: 'High RSSI should appear in adData.', + tx_power: 0, + expected_tx_power: 0, + rssi: 126, + expected_rssi: 126 +}, { + // TODO(ortuno): Remove this test since 127 is both a valid Tx Power + // and the max value of a int8. + // http://crbug.com/551572 + name: 'Tx Power too high must result in nulled txPower.', + tx_power: 127, + expected_tx_power: null, + rssi: 0, + expected_rssi: 0 +}, { + name: 'RSSI too high must result in nulled rssi.', + tx_power: 0, + expected_tx_power: 0, + rssi: 127, + expected_rssi: null +}].forEach(power_test => { + promise_test(() => { + testRunner.setBluetoothMockDataSet('PowerValueAdapter:' + + power_test.tx_power + ':' + + power_test.rssi); + return requestDeviceWithKeyDown({filters: [{services: ['heart_rate']}]}) + .then(device => { + let adv_data = device.adData; + assert_equals(adv_data.txPower, power_test.expected_tx_power); + assert_equals(adv_data.rssi, power_test.expected_rssi); + }); + }, power_test.name); +}); + +// Tests for all platforms. +[{ + name: 'TxPower not present, RSSI not present.', + tx_power_present: false, + rssi_present: false +}, { + name: 'TxPower not present, RSSI present.', + tx_power_present: false, + rssi_present: true +}, { + name: 'TxPower present, RSSI not present.', + tx_power_present: true, + rssi_present: false, +}, { + name: 'TxPower present, RSSI present.', + tx_power_present: true, + rssi_present: true +}].forEach(power_test => { + promise_test(() => { + testRunner.setBluetoothMockDataSet('PowerPresenceAdapter:' + + power_test.tx_power_present + ':' + + power_test.rssi_present); + return requestDeviceWithKeyDown({filters: [{services: ['heart_rate']}]}) + .then(device => { + let adv_data = device.adData; + let expected_tx_power = power_test.tx_power_present ? + -10 /* broadcasting at 0.1mW */ + : null; + let expected_rssi = power_test.rssi_present ? + -51 /* power at 1m from device broadcasting at 0.1mW */ + : null; + assert_equals(adv_data.txPower, expected_tx_power); + assert_equals(adv_data.rssi, expected_rssi); + }); + }, power_test.name) +}); +</script> diff --git a/third_party/WebKit/LayoutTests/webexposed/global-interface-listing-expected.txt b/third_party/WebKit/LayoutTests/webexposed/global-interface-listing-expected.txt index 70d1d6b..cc69615 100644 --- a/third_party/WebKit/LayoutTests/webexposed/global-interface-listing-expected.txt +++ b/third_party/WebKit/LayoutTests/webexposed/global-interface-listing-expected.txt @@ -289,6 +289,10 @@ interface Blob interface BlobEvent : Event getter data method constructor +interface BluetoothAdvertisingData + getter rssi + getter txPower + method constructor interface BluetoothCharacteristicProperties getter authenticatedSignedWrites getter broadcast @@ -301,6 +305,7 @@ interface BluetoothCharacteristicProperties getter writeWithoutResponse method constructor interface BluetoothDevice + getter adData getter deviceClass getter id getter instanceID diff --git a/third_party/WebKit/Source/modules/bluetooth/BluetoothAdvertisingData.cpp b/third_party/WebKit/Source/modules/bluetooth/BluetoothAdvertisingData.cpp new file mode 100644 index 0000000..89d94fd --- /dev/null +++ b/third_party/WebKit/Source/modules/bluetooth/BluetoothAdvertisingData.cpp @@ -0,0 +1,43 @@ +// Copyright 2015 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "config.h" +#include "modules/bluetooth/BluetoothAdvertisingData.h" + +namespace blink { + +namespace { +// TODO(ortuno): RSSI Unknown and Tx Power Unknown should have different +// values. Add kUnknownTxPower when implemented: http://crbug.com/551572 +const int kUnknownPower = 127; +} // namespace + +BluetoothAdvertisingData* BluetoothAdvertisingData::create(int8_t txPower, int8_t rssi) +{ + return new BluetoothAdvertisingData(txPower, rssi); +} + +int8_t BluetoothAdvertisingData::txPower(bool& isNull) +{ + if (m_txPower == kUnknownPower) { + isNull = true; + } + return m_txPower; +} + +int8_t BluetoothAdvertisingData::rssi(bool& isNull) +{ + if (m_rssi == kUnknownPower) { + isNull = true; + } + return m_rssi; +} + +BluetoothAdvertisingData::BluetoothAdvertisingData(int8_t txPower, int8_t rssi) + : m_txPower(txPower) + , m_rssi(rssi) +{ +} + +} // namespace blink diff --git a/third_party/WebKit/Source/modules/bluetooth/BluetoothAdvertisingData.h b/third_party/WebKit/Source/modules/bluetooth/BluetoothAdvertisingData.h new file mode 100644 index 0000000..4aef9b8 --- /dev/null +++ b/third_party/WebKit/Source/modules/bluetooth/BluetoothAdvertisingData.h @@ -0,0 +1,37 @@ +// Copyright 2015 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef BluetoothAdvertisingData_h +#define BluetoothAdvertisingData_h + +#include "bindings/core/v8/ScriptWrappable.h" +#include "platform/heap/Handle.h" + +namespace blink { + +// Represents the data a BLE device is advertising. +class BluetoothAdvertisingData final + : public GarbageCollected<BluetoothAdvertisingData> + , public ScriptWrappable { + DEFINE_WRAPPERTYPEINFO(); +public: + static BluetoothAdvertisingData* create(int8_t txPower, int8_t rssi); + + // IDL exposed interface: + int8_t txPower(bool& isNull); + int8_t rssi(bool& isNull); + + // Interface required by garbage collection. + DEFINE_INLINE_TRACE() { } + +private: + explicit BluetoothAdvertisingData(int8_t txPower, int8_t rssi); + + int8_t m_txPower; + int8_t m_rssi; +}; + +} // namespace blink + +#endif // BluetoothAdvertisingData_h diff --git a/third_party/WebKit/Source/modules/bluetooth/BluetoothAdvertisingData.idl b/third_party/WebKit/Source/modules/bluetooth/BluetoothAdvertisingData.idl new file mode 100644 index 0000000..6e0454d --- /dev/null +++ b/third_party/WebKit/Source/modules/bluetooth/BluetoothAdvertisingData.idl @@ -0,0 +1,18 @@ +// Copyright 2015 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// https://webbluetoothcg.github.io/web-bluetooth/#bluetoothadvertisingdata + +// Implement BluetoothAdvertisingData interface: http://crbug.com/542756 + +[ + GarbageCollected, + RuntimeEnabled=WebBluetooth, +] interface BluetoothAdvertisingData { + // readonly attribute unsigned short? appearance; + readonly attribute byte? txPower; + readonly attribute byte? rssi; + // readonly attribute ManufacturerDataMap manufacturerData; + // readonly attribute ServiceDataMap serviceData; +}; diff --git a/third_party/WebKit/Source/modules/bluetooth/BluetoothDevice.cpp b/third_party/WebKit/Source/modules/bluetooth/BluetoothDevice.cpp index da50dfd..2129c98 100644 --- a/third_party/WebKit/Source/modules/bluetooth/BluetoothDevice.cpp +++ b/third_party/WebKit/Source/modules/bluetooth/BluetoothDevice.cpp @@ -19,6 +19,8 @@ namespace blink { BluetoothDevice::BluetoothDevice(PassOwnPtr<WebBluetoothDevice> webDevice) : m_webDevice(webDevice) + , m_adData(BluetoothAdvertisingData::create(m_webDevice->txPower, + m_webDevice->rssi)) { } @@ -28,6 +30,11 @@ BluetoothDevice* BluetoothDevice::take(ScriptPromiseResolver*, PassOwnPtr<WebBlu return new BluetoothDevice(webDevice); } +DEFINE_TRACE(BluetoothDevice) +{ + visitor->trace(m_adData); +} + unsigned BluetoothDevice::deviceClass(bool& isNull) { isNull = false; diff --git a/third_party/WebKit/Source/modules/bluetooth/BluetoothDevice.h b/third_party/WebKit/Source/modules/bluetooth/BluetoothDevice.h index 096cda7..a0ec5db 100644 --- a/third_party/WebKit/Source/modules/bluetooth/BluetoothDevice.h +++ b/third_party/WebKit/Source/modules/bluetooth/BluetoothDevice.h @@ -6,6 +6,7 @@ #define BluetoothDevice_h #include "bindings/core/v8/ScriptWrappable.h" +#include "modules/bluetooth/BluetoothAdvertisingData.h" #include "platform/heap/Heap.h" #include "public/platform/modules/bluetooth/WebBluetoothDevice.h" #include "wtf/OwnPtr.h" @@ -38,11 +39,12 @@ public: static BluetoothDevice* take(ScriptPromiseResolver*, PassOwnPtr<WebBluetoothDevice>); // Interface required by Garbage Collection: - DEFINE_INLINE_TRACE() { } + DECLARE_VIRTUAL_TRACE(); // IDL exposed interface: String id() { return m_webDevice->id; } String name() { return m_webDevice->name; } + BluetoothAdvertisingData* adData() { return m_adData; } unsigned deviceClass(bool& isNull); String vendorIDSource(); unsigned vendorID(bool& isNull); @@ -53,6 +55,7 @@ public: private: OwnPtr<WebBluetoothDevice> m_webDevice; + Member<BluetoothAdvertisingData> m_adData; }; } // namespace blink diff --git a/third_party/WebKit/Source/modules/bluetooth/BluetoothDevice.idl b/third_party/WebKit/Source/modules/bluetooth/BluetoothDevice.idl index 03c25e06..86ad3a9 100644 --- a/third_party/WebKit/Source/modules/bluetooth/BluetoothDevice.idl +++ b/third_party/WebKit/Source/modules/bluetooth/BluetoothDevice.idl @@ -22,7 +22,7 @@ enum VendorIDSource { [DeprecateAs=BluetoothDeviceInstanceId, ImplementedAs=id] readonly attribute DOMString instanceID; readonly attribute DOMString id; readonly attribute DOMString? name; -// readonly attribute BluetoothAdvertisingData adData; + readonly attribute BluetoothAdvertisingData adData; readonly attribute unsigned long? deviceClass; readonly attribute VendorIDSource? vendorIDSource; readonly attribute unsigned long? vendorID; diff --git a/third_party/WebKit/Source/modules/modules.gypi b/third_party/WebKit/Source/modules/modules.gypi index 0c4d52c..09e47ff 100644 --- a/third_party/WebKit/Source/modules/modules.gypi +++ b/third_party/WebKit/Source/modules/modules.gypi @@ -24,6 +24,7 @@ 'background_sync/SyncRegistration.idl', 'battery/BatteryManager.idl', 'bluetooth/Bluetooth.idl', + 'bluetooth/BluetoothAdvertisingData.idl', 'bluetooth/BluetoothDevice.idl', 'bluetooth/BluetoothCharacteristicProperties.idl', 'bluetooth/BluetoothGATTCharacteristic.idl', @@ -792,6 +793,8 @@ 'bluetooth/ConvertWebVectorToArrayBuffer.cpp', 'bluetooth/ConvertWebVectorToArrayBuffer.h', 'bluetooth/Bluetooth.cpp', + 'bluetooth/BluetoothAdvertisingData.cpp', + 'bluetooth/BluetoothAdvertisingData.h', 'bluetooth/BluetoothCharacteristicProperties.cpp', 'bluetooth/BluetoothCharacteristicProperties.h', 'bluetooth/BluetoothDevice.cpp', diff --git a/third_party/WebKit/public/platform/modules/bluetooth/WebBluetoothDevice.h b/third_party/WebKit/public/platform/modules/bluetooth/WebBluetoothDevice.h index 76534e5..e2d97b5 100644 --- a/third_party/WebKit/public/platform/modules/bluetooth/WebBluetoothDevice.h +++ b/third_party/WebKit/public/platform/modules/bluetooth/WebBluetoothDevice.h @@ -20,6 +20,8 @@ struct WebBluetoothDevice { WebBluetoothDevice(const WebString& id, const WebString& name, + int8_t txPower, + int8_t rssi, int32_t deviceClass, VendorIDSource vendorIDSource, uint16_t vendorID, @@ -29,6 +31,8 @@ struct WebBluetoothDevice { const WebVector<WebString>& uuids) : id(id) , name(name) + , txPower(txPower) + , rssi(rssi) , deviceClass(deviceClass) , vendorIDSource(vendorIDSource) , vendorID(vendorID) @@ -42,6 +46,10 @@ struct WebBluetoothDevice { // Members corresponding to BluetoothDevice attributes as specified in IDL. const WebString id; const WebString name; + // Powers: + // A value of 127 denotes an invalid power. + const int8_t txPower; + const int8_t rssi; const int32_t deviceClass; const VendorIDSource vendorIDSource; const uint16_t vendorID; |