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

Side by Side Diff: device/usb/mojo/device_impl.cc

Issue 1784733002: Track USB device configuration state in Blink. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@blink_open_state
Patch Set: Rebased. Created 4 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
« no previous file with comments | « device/usb/mojo/device_impl.h ('k') | device/usb/mojo/type_converters.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "device/usb/mojo/device_impl.h" 5 #include "device/usb/mojo/device_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <numeric> 10 #include <numeric>
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 } 183 }
184 } 184 }
185 185
186 void DeviceImpl::OnOpen(const OpenCallback& callback, 186 void DeviceImpl::OnOpen(const OpenCallback& callback,
187 scoped_refptr<UsbDeviceHandle> handle) { 187 scoped_refptr<UsbDeviceHandle> handle) {
188 device_handle_ = handle; 188 device_handle_ = handle;
189 callback.Run(handle ? OpenDeviceError::OK : OpenDeviceError::ACCESS_DENIED); 189 callback.Run(handle ? OpenDeviceError::OK : OpenDeviceError::ACCESS_DENIED);
190 } 190 }
191 191
192 void DeviceImpl::GetDeviceInfo(const GetDeviceInfoCallback& callback) { 192 void DeviceImpl::GetDeviceInfo(const GetDeviceInfoCallback& callback) {
193 const UsbConfigDescriptor* config = device_->GetActiveConfiguration();
194 device_info_->active_configuration = config ? config->configuration_value : 0;
193 callback.Run(device_info_->Clone()); 195 callback.Run(device_info_->Clone());
194 } 196 }
195 197
196 void DeviceImpl::GetConfiguration(const GetConfigurationCallback& callback) {
197 const UsbConfigDescriptor* config = device_->GetActiveConfiguration();
198 callback.Run(config ? config->configuration_value : 0);
199 }
200
201 void DeviceImpl::Open(const OpenCallback& callback) { 198 void DeviceImpl::Open(const OpenCallback& callback) {
202 if (device_handle_) 199 if (device_handle_)
203 callback.Run(OpenDeviceError::ALREADY_OPEN); 200 callback.Run(OpenDeviceError::ALREADY_OPEN);
204 else 201 else
205 device_->Open( 202 device_->Open(
206 base::Bind(&DeviceImpl::OnOpen, weak_factory_.GetWeakPtr(), callback)); 203 base::Bind(&DeviceImpl::OnOpen, weak_factory_.GetWeakPtr(), callback));
207 } 204 }
208 205
209 void DeviceImpl::Close(const CloseCallback& callback) { 206 void DeviceImpl::Close(const CloseCallback& callback) {
210 CloseHandle(); 207 CloseHandle();
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 base::Bind(&OnIsochronousTransferOut, base::Passed(&callback_ptr))); 423 base::Bind(&OnIsochronousTransferOut, base::Passed(&callback_ptr)));
427 } 424 }
428 425
429 void DeviceImpl::OnDeviceRemoved(scoped_refptr<UsbDevice> device) { 426 void DeviceImpl::OnDeviceRemoved(scoped_refptr<UsbDevice> device) {
430 DCHECK_EQ(device_, device); 427 DCHECK_EQ(device_, device);
431 delete this; 428 delete this;
432 } 429 }
433 430
434 } // namespace usb 431 } // namespace usb
435 } // namespace device 432 } // namespace device
OLDNEW
« no previous file with comments | « device/usb/mojo/device_impl.h ('k') | device/usb/mojo/type_converters.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698