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

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

Issue 2611773004: Allow top-level frames to request any USB device. (Closed)
Patch Set: Add comments explaining how the mock devices are being used. Created 3 years, 11 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 | « chrome/test/BUILD.gn ('k') | no next file » | 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/mock_usb_service.h" 5 #include "device/usb/mock_usb_service.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/threading/thread_task_runner_handle.h"
10 #include "device/usb/usb_device.h" 11 #include "device/usb/usb_device.h"
11 12
12 namespace device { 13 namespace device {
13 14
14 MockUsbService::MockUsbService() : UsbService(nullptr, nullptr) {} 15 MockUsbService::MockUsbService()
16 : UsbService(base::ThreadTaskRunnerHandle::IsSet()
17 ? base::ThreadTaskRunnerHandle::Get()
18 : nullptr,
19 nullptr) {}
15 20
16 MockUsbService::~MockUsbService() { 21 MockUsbService::~MockUsbService() {
17 // Shutdown() must be called before the base class destructor. 22 // Shutdown() must be called before the base class destructor.
18 Shutdown(); 23 Shutdown();
19 } 24 }
20 25
21 void MockUsbService::AddDevice(scoped_refptr<UsbDevice> device) { 26 void MockUsbService::AddDevice(scoped_refptr<UsbDevice> device) {
22 devices()[device->guid()] = device; 27 devices()[device->guid()] = device;
23 NotifyDeviceAdded(device); 28 NotifyDeviceAdded(device);
24 } 29 }
25 30
26 void MockUsbService::RemoveDevice(scoped_refptr<UsbDevice> device) { 31 void MockUsbService::RemoveDevice(scoped_refptr<UsbDevice> device) {
27 devices().erase(device->guid()); 32 devices().erase(device->guid());
28 UsbService::NotifyDeviceRemoved(device); 33 UsbService::NotifyDeviceRemoved(device);
29 } 34 }
30 35
31 } // namespace device 36 } // namespace device
OLDNEW
« no previous file with comments | « chrome/test/BUILD.gn ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698