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

Side by Side Diff: third_party/WebKit/Source/modules/webusb/USB.cpp

Issue 2709033003: Migrate WTF::HashMap::get() to ::at() (Closed)
Patch Set: rebase Created 3 years, 9 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/webusb/USB.h" 5 #include "modules/webusb/USB.h"
6 6
7 #include "bindings/core/v8/ScriptPromise.h" 7 #include "bindings/core/v8/ScriptPromise.h"
8 #include "bindings/core/v8/ScriptPromiseResolver.h" 8 #include "bindings/core/v8/ScriptPromiseResolver.h"
9 #include "core/dom/DOMException.h" 9 #include "core/dom/DOMException.h"
10 #include "core/dom/Document.h" 10 #include "core/dom/Document.h"
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 } 140 }
141 141
142 void USB::contextDestroyed(ExecutionContext*) { 142 void USB::contextDestroyed(ExecutionContext*) {
143 m_deviceManager.reset(); 143 m_deviceManager.reset();
144 m_deviceManagerRequests.clear(); 144 m_deviceManagerRequests.clear();
145 m_chooserService.reset(); 145 m_chooserService.reset();
146 m_chooserServiceRequests.clear(); 146 m_chooserServiceRequests.clear();
147 } 147 }
148 148
149 USBDevice* USB::getOrCreateDevice(usb::DeviceInfoPtr deviceInfo) { 149 USBDevice* USB::getOrCreateDevice(usb::DeviceInfoPtr deviceInfo) {
150 USBDevice* device = m_deviceCache.get(deviceInfo->guid); 150 USBDevice* device = m_deviceCache.at(deviceInfo->guid);
151 if (!device) { 151 if (!device) {
152 String guid = deviceInfo->guid; 152 String guid = deviceInfo->guid;
153 usb::DevicePtr pipe; 153 usb::DevicePtr pipe;
154 m_deviceManager->GetDevice(guid, mojo::MakeRequest(&pipe)); 154 m_deviceManager->GetDevice(guid, mojo::MakeRequest(&pipe));
155 device = USBDevice::create(std::move(deviceInfo), std::move(pipe), 155 device = USBDevice::create(std::move(deviceInfo), std::move(pipe),
156 getExecutionContext()); 156 getExecutionContext());
157 m_deviceCache.insert(guid, device); 157 m_deviceCache.insert(guid, device);
158 } 158 }
159 return device; 159 return device;
160 } 160 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 void USB::OnDeviceAdded(usb::DeviceInfoPtr deviceInfo) { 195 void USB::OnDeviceAdded(usb::DeviceInfoPtr deviceInfo) {
196 if (!m_deviceManager) 196 if (!m_deviceManager)
197 return; 197 return;
198 198
199 dispatchEvent(USBConnectionEvent::create( 199 dispatchEvent(USBConnectionEvent::create(
200 EventTypeNames::connect, getOrCreateDevice(std::move(deviceInfo)))); 200 EventTypeNames::connect, getOrCreateDevice(std::move(deviceInfo))));
201 } 201 }
202 202
203 void USB::OnDeviceRemoved(usb::DeviceInfoPtr deviceInfo) { 203 void USB::OnDeviceRemoved(usb::DeviceInfoPtr deviceInfo) {
204 String guid = deviceInfo->guid; 204 String guid = deviceInfo->guid;
205 USBDevice* device = m_deviceCache.get(guid); 205 USBDevice* device = m_deviceCache.at(guid);
206 if (!device) 206 if (!device)
207 device = USBDevice::create(std::move(deviceInfo), nullptr, 207 device = USBDevice::create(std::move(deviceInfo), nullptr,
208 getExecutionContext()); 208 getExecutionContext());
209 dispatchEvent(USBConnectionEvent::create(EventTypeNames::disconnect, device)); 209 dispatchEvent(USBConnectionEvent::create(EventTypeNames::disconnect, device));
210 m_deviceCache.erase(guid); 210 m_deviceCache.erase(guid);
211 } 211 }
212 212
213 void USB::onDeviceManagerConnectionError() { 213 void USB::onDeviceManagerConnectionError() {
214 m_deviceManager.reset(); 214 m_deviceManager.reset();
215 for (ScriptPromiseResolver* resolver : m_deviceManagerRequests) 215 for (ScriptPromiseResolver* resolver : m_deviceManagerRequests)
(...skipping 10 matching lines...) Expand all
226 226
227 DEFINE_TRACE(USB) { 227 DEFINE_TRACE(USB) {
228 visitor->trace(m_deviceManagerRequests); 228 visitor->trace(m_deviceManagerRequests);
229 visitor->trace(m_chooserServiceRequests); 229 visitor->trace(m_chooserServiceRequests);
230 visitor->trace(m_deviceCache); 230 visitor->trace(m_deviceCache);
231 EventTargetWithInlineData::trace(visitor); 231 EventTargetWithInlineData::trace(visitor);
232 ContextLifecycleObserver::trace(visitor); 232 ContextLifecycleObserver::trace(visitor);
233 } 233 }
234 234
235 } // namespace blink 235 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp ('k') | third_party/WebKit/Source/platform/Length.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698