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

Unified Diff: third_party/WebKit/Source/modules/bluetooth/BluetoothAdvertisingData.cpp

Issue 1427653003: bluetooth: Implement TxPower and RSSI of BluetoothAdvertisementData (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@my-origin
Patch Set: Fix webexposed test Created 5 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/modules/bluetooth/BluetoothAdvertisingData.cpp
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 0000000000000000000000000000000000000000..f28736be8d8a3fc72dd96a653d850b1719be4732
--- /dev/null
+++ b/third_party/WebKit/Source/modules/bluetooth/BluetoothAdvertisingData.cpp
@@ -0,0 +1,47 @@
+// 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 {
+const int kUnknownPower = INT8_MAX;
+const int kNegativeUnknownPower = INT8_MIN;
scheib 2015/10/29 17:37:26 kNegativeUnknownPower seems to be a valid minimum
ortuno 2015/10/29 20:21:42 Done.
+} // namespace
+
+BluetoothAdvertisingData* BluetoothAdvertisingData::create(int txPower, int 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;
+}
+
+static int8_t GetValidatedPower(int power)
+{
+ return (power > kUnknownPower || power < kNegativeUnknownPower) ? kUnknownPower : power;
+}
+
+BluetoothAdvertisingData::BluetoothAdvertisingData(int txPower, int rssi)
+ : m_txPower(GetValidatedPower(txPower))
+ , m_rssi(GetValidatedPower(rssi))
+{
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698