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

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

Issue 2614663008: Migrate WTF::Vector::append() to ::push_back() [part 13 of N] (Closed)
Patch Set: Created 3 years, 11 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 exceptionState.throwTypeError( 55 exceptionState.throwTypeError(
56 "'services', if present, must contain at least one service."); 56 "'services', if present, must contain at least one service.");
57 return; 57 return;
58 } 58 }
59 canonicalizedFilter->services.emplace(); 59 canonicalizedFilter->services.emplace();
60 for (const StringOrUnsignedLong& service : filter.services()) { 60 for (const StringOrUnsignedLong& service : filter.services()) {
61 const String& validatedService = 61 const String& validatedService =
62 BluetoothUUID::getService(service, exceptionState); 62 BluetoothUUID::getService(service, exceptionState);
63 if (exceptionState.hadException()) 63 if (exceptionState.hadException())
64 return; 64 return;
65 canonicalizedFilter->services->append(validatedService); 65 canonicalizedFilter->services->push_back(validatedService);
66 } 66 }
67 } 67 }
68 68
69 if (filter.hasName()) { 69 if (filter.hasName()) {
70 size_t nameLength = filter.name().utf8().length(); 70 size_t nameLength = filter.name().utf8().length();
71 if (nameLength > kMaxDeviceNameLength) { 71 if (nameLength > kMaxDeviceNameLength) {
72 exceptionState.throwTypeError(kDeviceNameTooLong); 72 exceptionState.throwTypeError(kDeviceNameTooLong);
73 return; 73 return;
74 } 74 }
75 if (nameLength > kMaxFilterNameLength) { 75 if (nameLength > kMaxFilterNameLength) {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 result->filters.emplace(); 121 result->filters.emplace();
122 122
123 for (const BluetoothScanFilterInit& filter : options.filters()) { 123 for (const BluetoothScanFilterInit& filter : options.filters()) {
124 auto canonicalizedFilter = mojom::blink::WebBluetoothScanFilter::New(); 124 auto canonicalizedFilter = mojom::blink::WebBluetoothScanFilter::New();
125 125
126 canonicalizeFilter(filter, canonicalizedFilter, exceptionState); 126 canonicalizeFilter(filter, canonicalizedFilter, exceptionState);
127 127
128 if (exceptionState.hadException()) 128 if (exceptionState.hadException())
129 return; 129 return;
130 130
131 result->filters.value().append(std::move(canonicalizedFilter)); 131 result->filters.value().push_back(std::move(canonicalizedFilter));
132 } 132 }
133 } 133 }
134 134
135 if (options.hasOptionalServices()) { 135 if (options.hasOptionalServices()) {
136 for (const StringOrUnsignedLong& optionalService : 136 for (const StringOrUnsignedLong& optionalService :
137 options.optionalServices()) { 137 options.optionalServices()) {
138 const String& validatedOptionalService = 138 const String& validatedOptionalService =
139 BluetoothUUID::getService(optionalService, exceptionState); 139 BluetoothUUID::getService(optionalService, exceptionState);
140 if (exceptionState.hadException()) 140 if (exceptionState.hadException())
141 return; 141 return;
142 result->optional_services.append(validatedOptionalService); 142 result->optional_services.push_back(validatedOptionalService);
143 } 143 }
144 } 144 }
145 } 145 }
146 146
147 void Bluetooth::dispose() { 147 void Bluetooth::dispose() {
148 // The pipe to this object must be closed when is marked unreachable to 148 // The pipe to this object must be closed when is marked unreachable to
149 // prevent messages from being dispatched before lazy sweeping. 149 // prevent messages from being dispatched before lazy sweeping.
150 if (m_clientBinding.is_bound()) 150 if (m_clientBinding.is_bound())
151 m_clientBinding.Close(); 151 m_clientBinding.Close();
152 } 152 }
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698