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

Unified Diff: device/hid/hid_service.h

Issue 143883005: HID backend (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@hid-impl-base
Patch Set: Created 6 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
Index: device/hid/hid_service.h
diff --git a/device/hid/hid_service.h b/device/hid/hid_service.h
new file mode 100644
index 0000000000000000000000000000000000000000..2b06de9fa185b74ba4b38703d29e75c79e244238
--- /dev/null
+++ b/device/hid/hid_service.h
@@ -0,0 +1,72 @@
+// Copyright (c) 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 DEVICE_HID_HID_SERVICE_H_
+#define DEVICE_HID_HID_SERVICE_H_
+
+#include <map>
+#include <string>
+#include <vector>
+
+#include "base/basictypes.h"
+#include "base/memory/ref_counted.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/message_loop/message_loop.h"
+#include "base/strings/string16.h"
+#include "base/threading/thread_checker.h"
+#include "build/build_config.h"
+#include "device/hid/hid_device_info.h"
+
+namespace device {
+
+namespace {
+
+class HidServiceContainer;
+
+} // namespace
+
+class HidConnection;
+class HidService;
+
+class HidService : public base::MessageLoop::DestructionObserver {
+ public:
+ // Must be called on FILE thread.
+ static HidService* GetInstance();
+
+ // Enumerates and returns a list of device identifiers.
+ virtual void GetDevices(std::vector<HidDeviceInfo>* devices);
+
+ virtual scoped_refptr<HidConnection> Connect(std::string device_id) = 0;
+
+ // Implements base::MessageLoop::DestructionObserver
+ virtual void WillDestroyCurrentMessageLoop() OVERRIDE;
+
+ // Gets whether the HidService have been successfully initialized.
+ bool initialized() const { return initialized_; }
+
+ protected:
+ friend class HidServiceContainer;
+ friend struct base::DefaultDeleter<HidService>;
+
+ HidService();
+ virtual ~HidService();
+
+ static HidService* CreateInstance();
+
+ virtual void DeviceAdd(HidDeviceInfo info);
Ken Rockot(use gerrit already) 2014/01/21 23:03:39 nit: I think verb-noun naming would be preferable:
Bei Zhang 2014/01/24 12:48:47 Right... This name was inherited from the good ol
+ virtual void DeviceRemove(std::string device_id);
+
+ typedef std::map<std::string, HidDeviceInfo> DeviceMap;
+ DeviceMap devices_;
+
+ bool initialized_;
+
+ base::ThreadChecker thread_checker_;
+
+ DISALLOW_COPY_AND_ASSIGN(HidService);
+};
+
+} // namespace device
+
+#endif // DEVICE_HID_HID_SERVICE_H_

Powered by Google App Engine
This is Rietveld 408576698