Vectorize website settings icons in omnibox
[chromium-blink-merge.git] / device / usb / mock_usb_service.cc
blobf9bf9d917de1d0244a42dcb528747a5f79df49de
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"
9 namespace device {
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())
30 return it->second;
31 return nullptr;
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);
42 } // namespace device