Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "modules/bluetooth/Bluetooth.h" | 5 #include "modules/bluetooth/Bluetooth.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/CallbackPromiseAdapter.h" | 7 #include "bindings/core/v8/CallbackPromiseAdapter.h" |
| 8 #include "bindings/core/v8/ScriptPromise.h" | 8 #include "bindings/core/v8/ScriptPromise.h" |
| 9 #include "bindings/core/v8/ScriptPromiseResolver.h" | 9 #include "bindings/core/v8/ScriptPromiseResolver.h" |
| 10 #include "core/dom/DOMException.h" | 10 #include "core/dom/DOMException.h" |
| 11 #include "core/dom/Document.h" | 11 #include "core/dom/Document.h" |
| 12 #include "core/dom/ExceptionCode.h" | 12 #include "core/dom/ExceptionCode.h" |
| 13 #include "core/dom/ExecutionContext.h" | 13 #include "core/dom/ExecutionContext.h" |
| 14 #include "core/frame/LocalFrame.h" | 14 #include "core/frame/LocalFrame.h" |
| 15 #include "modules/bluetooth/BluetoothDevice.h" | 15 #include "modules/bluetooth/BluetoothDevice.h" |
| 16 #include "modules/bluetooth/BluetoothError.h" | 16 #include "modules/bluetooth/BluetoothError.h" |
| 17 #include "modules/bluetooth/BluetoothRemoteGATTCharacteristic.h" | 17 #include "modules/bluetooth/BluetoothRemoteGATTCharacteristic.h" |
| 18 #include "modules/bluetooth/BluetoothUUID.h" | 18 #include "modules/bluetooth/BluetoothUUID.h" |
| 19 #include "modules/bluetooth/RequestDeviceOptions.h" | 19 #include "modules/bluetooth/RequestDeviceOptions.h" |
| 20 #include "platform/UserGestureIndicator.h" | 20 #include "platform/UserGestureIndicator.h" |
| 21 #include "public/platform/InterfaceProvider.h" | 21 #include "public/platform/InterfaceProvider.h" |
| 22 #include <memory> | 22 #include <memory> |
| 23 #include <utility> | 23 #include <utility> |
| 24 | 24 |
| 25 namespace blink { | 25 namespace blink { |
| 26 | 26 |
| 27 namespace { | 27 namespace { |
| 28 // A device name can never be longer than 29 bytes. A adv packet is at most | 28 // A name coming from an adv packet is max 29 bytes (adv packet max size |
| 29 // 31 bytes long. The length and identifier of the length field take 2 bytes. | 29 // 31 bytes - 2 byte length field), but the name can also be acquired via |
| 30 // That least 29 bytes for the name. | 30 // gap.device_name, so it is limited to the max EIR packet size of 240 bytes. |
| 31 const size_t kMaxFilterNameLength = 29; | 31 const size_t kMaxFilterNameLength = 240; |
|
scheib
2017/01/09 19:26:49
Description here is good, please add spec sections
| |
| 32 const char kFilterNameTooLong[] = | 32 const char kFilterNameTooLong[] = |
| 33 "A 'name' or 'namePrefix' longer than 29 bytes results in no devices being " | 33 "A 'name' or 'namePrefix' longer than 240 bytes results in no devices being " |
| 34 "found, because a device can't advertise a name longer than 29 bytes."; | 34 "found, because a device can't acquire a name longer than 240 bytes."; |
| 35 // Per the Bluetooth Spec: The name is a user-friendly name associated with the | 35 // Per the Bluetooth Spec: The name is a user-friendly name associated with the |
| 36 // device and consists of a maximum of 248 bytes coded according to the UTF-8 | 36 // device and consists of a maximum of 248 bytes coded according to the UTF-8 |
| 37 // standard. | 37 // standard. |
| 38 const size_t kMaxDeviceNameLength = 248; | 38 const size_t kMaxDeviceNameLength = 248; |
| 39 const char kDeviceNameTooLong[] = | 39 const char kDeviceNameTooLong[] = |
| 40 "A device name can't be longer than 248 bytes."; | 40 "A device name can't be longer than 248 bytes."; |
| 41 } // namespace | 41 } // namespace |
| 42 | 42 |
| 43 static void canonicalizeFilter( | 43 static void canonicalizeFilter( |
| 44 const BluetoothScanFilterInit& filter, | 44 const BluetoothScanFilterInit& filter, |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 294 BluetoothDevice* device = m_deviceInstanceMap.get(id); | 294 BluetoothDevice* device = m_deviceInstanceMap.get(id); |
| 295 if (!device) { | 295 if (!device) { |
| 296 device = BluetoothDevice::take(resolver, id, name, this); | 296 device = BluetoothDevice::take(resolver, id, name, this); |
| 297 auto result = m_deviceInstanceMap.add(id, device); | 297 auto result = m_deviceInstanceMap.add(id, device); |
| 298 DCHECK(result.isNewEntry); | 298 DCHECK(result.isNewEntry); |
| 299 } | 299 } |
| 300 return device; | 300 return device; |
| 301 } | 301 } |
| 302 | 302 |
| 303 } // namespace blink | 303 } // namespace blink |
| OLD | NEW |