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

Unified Diff: device/hid/hid_service.h

Issue 825523003: Convert HidDeviceInfo from a struct to a refcounted class. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added TODO to remove friend class definitions. Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « device/hid/hid_device_info.cc ('k') | device/hid/hid_service.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/hid/hid_service.h
diff --git a/device/hid/hid_service.h b/device/hid/hid_service.h
index 8d296c0986797f737bb31da02e9c59ca8b3a44a5..6d6ef2bd2860fc18313652ae8d2c16c2296c9e50 100644
--- a/device/hid/hid_service.h
+++ b/device/hid/hid_service.h
@@ -26,11 +26,11 @@ class HidService {
public:
class Observer {
public:
- virtual void OnDeviceAdded(const HidDeviceInfo& info) {}
- virtual void OnDeviceRemoved(const HidDeviceInfo& info) {}
+ virtual void OnDeviceAdded(scoped_refptr<HidDeviceInfo> info);
+ virtual void OnDeviceRemoved(scoped_refptr<HidDeviceInfo> info);
};
- typedef base::Callback<void(const std::vector<HidDeviceInfo>&)>
+ typedef base::Callback<void(const std::vector<scoped_refptr<HidDeviceInfo>>&)>
GetDevicesCallback;
typedef base::Callback<void(scoped_refptr<HidConnection> connection)>
ConnectCallback;
@@ -51,8 +51,9 @@ class HidService {
void RemoveObserver(Observer* observer);
// Fills in a DeviceInfo struct with info for the given device_id.
- // Returns |true| if successful or |false| if |device_id| is invalid.
- bool GetDeviceInfo(const HidDeviceId& device_id, HidDeviceInfo* info) const;
+ // Returns |nullptr| if |device_id| is invalid.
+ scoped_refptr<HidDeviceInfo> GetDeviceInfo(
+ const HidDeviceId& device_id) const;
// Opens a connection to a device. The callback will be run with null on
// failure.
@@ -63,12 +64,12 @@ class HidService {
friend void base::DeletePointer<HidService>(HidService* service);
friend class HidConnectionTest;
- typedef std::map<HidDeviceId, HidDeviceInfo> DeviceMap;
+ typedef std::map<HidDeviceId, scoped_refptr<HidDeviceInfo>> DeviceMap;
HidService();
virtual ~HidService();
- void AddDevice(const HidDeviceInfo& info);
+ void AddDevice(scoped_refptr<HidDeviceInfo> info);
void RemoveDevice(const HidDeviceId& device_id);
void FirstEnumerationComplete();
« no previous file with comments | « device/hid/hid_device_info.cc ('k') | device/hid/hid_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698