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

Side by Side Diff: device/usb/mock_usb_service.cc

Issue 1144493003: Extract //device/usb mocks so that they can be shared. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix Android and GN builds for real. Created 5 years, 7 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/mock_usb_service.h ('k') | device/usb/usb.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "device/usb/mock_usb_service.h"
6
7 #include "device/usb/usb_device.h"
8
9 namespace device {
10
11 MockUsbService::MockUsbService() {
12 }
13
14 MockUsbService::~MockUsbService() {
15 }
16
17 void MockUsbService::AddDevice(scoped_refptr<UsbDevice> device) {
18 devices_[device->unique_id()] = device;
19 NotifyDeviceAdded(device);
20 }
21
22 void MockUsbService::RemoveDevice(scoped_refptr<UsbDevice> device) {
23 devices_.erase(device->unique_id());
24 UsbService::NotifyDeviceRemoved(device);
25 }
26
27 scoped_refptr<UsbDevice> MockUsbService::GetDeviceById(uint32 unique_id) {
28 auto it = devices_.find(unique_id);
29 EXPECT_TRUE(it != devices_.end());
30 return it->second;
31 }
32
33 void MockUsbService::GetDevices(const GetDevicesCallback& callback) {
34 std::vector<scoped_refptr<UsbDevice>> devices;
35 for (const auto& map_entry : devices_) {
36 devices.push_back(map_entry.second);
37 }
38 callback.Run(devices);
39 }
40
41 } // namespace device
OLDNEW
« no previous file with comments | « device/usb/mock_usb_service.h ('k') | device/usb/usb.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698