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.
5 #include "device/usb/mock_usb_service.h"
7 #include "device/usb/usb_device.h"
11 MockUsbService::MockUsbService() {
14 MockUsbService::~MockUsbService() {
17 void MockUsbService::AddDevice(scoped_refptr
<UsbDevice
> device
) {
18 devices_
[device
->guid()] = device
;
19 NotifyDeviceAdded(device
);
22 void MockUsbService::RemoveDevice(scoped_refptr
<UsbDevice
> device
) {
23 devices_
.erase(device
->guid());
24 UsbService::NotifyDeviceRemoved(device
);
27 scoped_refptr
<UsbDevice
> MockUsbService::GetDevice(const std::string
& guid
) {
28 auto it
= devices_
.find(guid
);
29 if (it
!= devices_
.end())
34 void MockUsbService::GetDevices(const GetDevicesCallback
& callback
) {
35 std::vector
<scoped_refptr
<UsbDevice
>> devices
;
36 for (const auto& map_entry
: devices_
) {
37 devices
.push_back(map_entry
.second
);
39 callback
.Run(devices
);