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

Unified Diff: device/usb/usb_service.h

Issue 2204713006: Add chrome://usb-internals page for adding and removing test devices. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use typemaped types in the TestDeviceInfo struct. Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/common/url_constants.cc ('k') | device/usb/usb_service.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/usb/usb_service.h
diff --git a/device/usb/usb_service.h b/device/usb/usb_service.h
index a78fa83eb6dba3e9a012040bf97ceb2a4688af02..b3949a77aaaac838c8e64fb1ce54377f341b04ec 100644
--- a/device/usb/usb_service.h
+++ b/device/usb/usb_service.h
@@ -8,6 +8,7 @@
#include <memory>
#include <string>
#include <unordered_map>
+#include <unordered_set>
#include <vector>
#include "base/bind_helpers.h"
@@ -64,6 +65,12 @@ class UsbService : public base::NonThreadSafe {
void AddObserver(Observer* observer);
void RemoveObserver(Observer* observer);
+ // Methods to add and remove devices for testing purposes. Only a device added
+ // by this method can be removed by RemoveDeviceForTesting().
+ void AddDeviceForTesting(scoped_refptr<UsbDevice> device);
+ void RemoveDeviceForTesting(const std::string& device_guid);
+ void GetTestDevices(std::vector<scoped_refptr<UsbDevice>>* devices);
+
protected:
UsbService(scoped_refptr<base::SingleThreadTaskRunner> task_runner,
scoped_refptr<base::SequencedTaskRunner> blocking_task_runner);
@@ -89,6 +96,7 @@ class UsbService : public base::NonThreadSafe {
scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_;
std::unordered_map<std::string, scoped_refptr<UsbDevice>> devices_;
+ std::unordered_set<std::string> testing_devices_;
base::ObserverList<Observer, true> observer_list_;
DISALLOW_COPY_AND_ASSIGN(UsbService);
« no previous file with comments | « chrome/common/url_constants.cc ('k') | device/usb/usb_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698