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

Unified Diff: chrome/browser/extensions/api/hid/hid_device_manager.h

Issue 161823002: Clean up HID backend and API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: cleanup Created 6 years, 10 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
Index: chrome/browser/extensions/api/hid/hid_device_manager.h
diff --git a/chrome/browser/extensions/api/hid/hid_device_manager.h b/chrome/browser/extensions/api/hid/hid_device_manager.h
new file mode 100644
index 0000000000000000000000000000000000000000..815f1384af2c1f20e606b807c71eac8aa8928b71
--- /dev/null
+++ b/chrome/browser/extensions/api/hid/hid_device_manager.h
@@ -0,0 +1,63 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_EXTENSIONS_API_HID_HID_DEVICE_MANAGER_H_
+#define CHROME_BROWSER_EXTENSIONS_API_HID_HID_DEVICE_MANAGER_H_
+
+#include <stdint.h>
+
+#include <map>
+#include <vector>
Mark Mentovai 2014/02/24 20:23:36 Unused in the .h. Move to the .cc.
Ken Rockot(use gerrit already) 2014/02/25 21:30:01 Done.
+
+#include "base/basictypes.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/threading/thread_checker.h"
+#include "chrome/browser/extensions/api/profile_keyed_api_factory.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/common/extensions/api/hid.h"
+#include "device/hid/hid_device_info.h"
+
+namespace extensions {
+
+class HidDeviceManager : public ProfileKeyedAPI {
+ public:
+ explicit HidDeviceManager(Profile* profile);
+ virtual ~HidDeviceManager();
+
+ // ProfileKeyedAPI implementation.
+ static ProfileKeyedAPIFactory<HidDeviceManager>* GetFactoryInstance();
+
+ // Convenience method to get the HidDeviceManager for a profile.
+ static HidDeviceManager* Get(Profile* profile) {
+ return ProfileKeyedAPIFactory<HidDeviceManager>::GetForProfile(profile);
+ }
+
+ scoped_ptr<base::ListValue> GetApiDevices(uint16_t vendor_id,
+ uint16_t product_id);
+
+ bool GetDeviceInfo(int resource_id, device::HidDeviceInfo* device_info);
+
+ private:
+ friend class ProfileKeyedAPIFactory<HidDeviceManager>;
+
+ static const char* service_name() { return "HidDeviceManager"; }
+
+ void UpdateDevices();
+
+ base::ThreadChecker thread_checker_;
+
+ int next_resource_id_;
+
+ typedef std::map<int, device::HidDeviceId> ResourceIdToDeviceIdMap;
+ typedef std::map<device::HidDeviceId, int> DeviceIdToResourceIdMap;
+
+ ResourceIdToDeviceIdMap device_ids_;
+ DeviceIdToResourceIdMap resource_ids_;
+
+ DISALLOW_COPY_AND_ASSIGN(HidDeviceManager);
+};
+
+} // namespace extensions
+
+#endif // CHROME_BROWSER_EXTENSIONS_API_HID_HID_DEVICE_MANAGER_H_

Powered by Google App Engine
This is Rietveld 408576698