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

Side by Side 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, 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "config.h"
6 #include "modules/bluetooth/BluetoothAdvertisingData.h"
7
8 namespace blink {
9
10 namespace {
11 const int kUnknownPower = INT8_MAX;
12 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.
13 } // namespace
14
15 BluetoothAdvertisingData* BluetoothAdvertisingData::create(int txPower, int rssi )
16 {
17 return new BluetoothAdvertisingData(txPower, rssi);
18 }
19
20 int8_t BluetoothAdvertisingData::txPower(bool& isNull)
21 {
22 if (m_txPower == kUnknownPower) {
23 isNull = true;
24 }
25 return m_txPower;
26 }
27
28 int8_t BluetoothAdvertisingData::rssi(bool& isNull)
29 {
30 if (m_rssi == kUnknownPower) {
31 isNull = true;
32 }
33 return m_rssi;
34 }
35
36 static int8_t GetValidatedPower(int power)
37 {
38 return (power > kUnknownPower || power < kNegativeUnknownPower) ? kUnknownPo wer : power;
39 }
40
41 BluetoothAdvertisingData::BluetoothAdvertisingData(int txPower, int rssi)
42 : m_txPower(GetValidatedPower(txPower))
43 , m_rssi(GetValidatedPower(rssi))
44 {
45 }
46
47 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698