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

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

Issue 2789243002: Rename BluetoothScanFilterInit to BluetoothLEScanFilterInit (Closed)
Patch Set: Codereview: nit Created 3 years, 8 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 unified diff | Download patch
OLDNEW
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"
(...skipping 17 matching lines...) Expand all
28 namespace { 28 namespace {
29 // Per the Bluetooth Spec: The name is a user-friendly name associated with the 29 // Per the Bluetooth Spec: The name is a user-friendly name associated with the
30 // device and consists of a maximum of 248 bytes coded according to the UTF-8 30 // device and consists of a maximum of 248 bytes coded according to the UTF-8
31 // standard. 31 // standard.
32 const size_t kMaxDeviceNameLength = 248; 32 const size_t kMaxDeviceNameLength = 248;
33 const char kDeviceNameTooLong[] = 33 const char kDeviceNameTooLong[] =
34 "A device name can't be longer than 248 bytes."; 34 "A device name can't be longer than 248 bytes.";
35 } // namespace 35 } // namespace
36 36
37 static void CanonicalizeFilter( 37 static void CanonicalizeFilter(
38 const BluetoothScanFilterInit& filter, 38 const BluetoothLEScanFilterInit& filter,
39 mojom::blink::WebBluetoothScanFilterPtr& canonicalizedFilter, 39 mojom::blink::WebBluetoothLeScanFilterPtr& canonicalizedFilter,
40 ExceptionState& exceptionState) { 40 ExceptionState& exceptionState) {
41 if (!(filter.hasServices() || filter.hasName() || filter.hasNamePrefix())) { 41 if (!(filter.hasServices() || filter.hasName() || filter.hasNamePrefix())) {
42 exceptionState.throwTypeError( 42 exceptionState.throwTypeError(
43 "A filter must restrict the devices in some way."); 43 "A filter must restrict the devices in some way.");
44 return; 44 return;
45 } 45 }
46 46
47 if (filter.hasServices()) { 47 if (filter.hasServices()) {
48 if (filter.services().size() == 0) { 48 if (filter.services().size() == 0) {
49 exceptionState.throwTypeError( 49 exceptionState.throwTypeError(
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 99
100 if (options.hasFilters()) { 100 if (options.hasFilters()) {
101 if (options.filters().isEmpty()) { 101 if (options.filters().isEmpty()) {
102 exceptionState.throwTypeError( 102 exceptionState.throwTypeError(
103 "'filters' member must be non-empty to find any devices."); 103 "'filters' member must be non-empty to find any devices.");
104 return; 104 return;
105 } 105 }
106 106
107 result->filters.emplace(); 107 result->filters.emplace();
108 108
109 for (const BluetoothScanFilterInit& filter : options.filters()) { 109 for (const BluetoothLEScanFilterInit& filter : options.filters()) {
110 auto canonicalizedFilter = mojom::blink::WebBluetoothScanFilter::New(); 110 auto canonicalizedFilter = mojom::blink::WebBluetoothLeScanFilter::New();
111 111
112 CanonicalizeFilter(filter, canonicalizedFilter, exceptionState); 112 CanonicalizeFilter(filter, canonicalizedFilter, exceptionState);
113 113
114 if (exceptionState.hadException()) 114 if (exceptionState.hadException())
115 return; 115 return;
116 116
117 result->filters.value().push_back(std::move(canonicalizedFilter)); 117 result->filters.value().push_back(std::move(canonicalizedFilter));
118 } 118 }
119 } 119 }
120 120
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 BluetoothDevice* device = m_deviceInstanceMap.at(id); 226 BluetoothDevice* device = m_deviceInstanceMap.at(id);
227 if (!device) { 227 if (!device) {
228 device = BluetoothDevice::take(resolver, std::move(devicePtr), this); 228 device = BluetoothDevice::take(resolver, std::move(devicePtr), this);
229 auto result = m_deviceInstanceMap.insert(id, device); 229 auto result = m_deviceInstanceMap.insert(id, device);
230 DCHECK(result.isNewEntry); 230 DCHECK(result.isNewEntry);
231 } 231 }
232 return device; 232 return device;
233 } 233 }
234 234
235 } // namespace blink 235 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698