summaryrefslogtreecommitdiffstats
path: root/device/hid/hid_service_mac.h
diff options
context:
space:
mode:
authorrockot@chromium.org <rockot@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-02-27 17:29:10 +0000
committerrockot@chromium.org <rockot@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-02-27 17:29:10 +0000
commit26958d1d63547e6ff5f9f254e718905709fb6daf (patch)
tree2cc5f9553d8bd8d56f8d438fec805e11c2e2e01c /device/hid/hid_service_mac.h
parent76d03f895522ae0ea5106c31618115b1a1d2c575 (diff)
downloadchromium_src-26958d1d63547e6ff5f9f254e718905709fb6daf.zip
chromium_src-26958d1d63547e6ff5f9f254e718905709fb6daf.tar.gz
chromium_src-26958d1d63547e6ff5f9f254e718905709fb6daf.tar.bz2
Clean up HID backend and API.
The Mac backend no longer creates its own thread and instead simply enforces single-threaded usage on any thread which supports I/O. Ref management has also been sanitized. The Linux backend now implements feature report support. The backend interface no longer expects implicit report IDs in buffers passed to Write or SetFeatureReport. Instead these interfaces (as well as GetFeatureReport) take explicit report ID arguments. The API interface has been updated to reflect the improved report ID treatment. Finally, the API also now exposes opaque device identifiers on enumeration, rather than exposing raw system paths or other information that could be potentially sensitive. BUG=347294 Review URL: https://codereview.chromium.org/161823002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@253853 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'device/hid/hid_service_mac.h')
-rw-r--r--device/hid/hid_service_mac.h53
1 files changed, 18 insertions, 35 deletions
diff --git a/device/hid/hid_service_mac.h b/device/hid/hid_service_mac.h
index 9351d1e..7c43234 100644
--- a/device/hid/hid_service_mac.h
+++ b/device/hid/hid_service_mac.h
@@ -1,77 +1,60 @@
-// Copyright (c) 2014 The Chromium Authors. All rights reserved.
+// 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 DEVICE_HID_HID_SERVICE_MAC_H_
#define DEVICE_HID_HID_SERVICE_MAC_H_
-#include <map>
+#include <CoreFoundation/CoreFoundation.h>
+#include <IOKit/hid/IOHIDManager.h>
+
#include <string>
-#include <vector>
-#include "base/basictypes.h"
#include "base/mac/foundation_util.h"
#include "base/memory/ref_counted.h"
-#include "base/memory/singleton.h"
-#include "base/message_loop/message_loop.h"
-#include "base/strings/string16.h"
-#include "base/synchronization/waitable_event.h"
-#include "base/threading/thread.h"
-#include "base/threading/thread_checker.h"
-#include "build/build_config.h"
-#include "device/hid/hid_device_info.h"
#include "device/hid/hid_service.h"
-#include <CoreFoundation/CoreFoundation.h>
-#include <IOKit/hid/IOHIDManager.h>
+namespace base {
+class MessageLoopProxy;
+}
namespace device {
class HidConnection;
-class HidService;
class HidServiceMac : public HidService {
public:
HidServiceMac();
- virtual scoped_refptr<HidConnection> Connect(std::string device_id) OVERRIDE;
+ virtual scoped_refptr<HidConnection> Connect(const HidDeviceId& device_id)
+ OVERRIDE;
private:
virtual ~HidServiceMac();
- void ScheduleRunLoop();
- void UnscheduleRunLoop();
+ void StartWatchingDevices();
+ void StopWatchingDevices();
// Device changing callbacks.
static void AddDeviceCallback(void* context,
IOReturn result,
void* sender,
- IOHIDDeviceRef ref);
+ IOHIDDeviceRef hid_device);
static void RemoveDeviceCallback(void* context,
IOReturn result,
void* sender,
- IOHIDDeviceRef ref);
- static HidServiceMac* InstanceFromContext(void* context);
-
- IOHIDDeviceRef FindDevice(std::string id);
+ IOHIDDeviceRef hid_device);
void Enumerate();
- void PlatformAddDevice(IOHIDDeviceRef ref);
- void PlatformRemoveDevice(IOHIDDeviceRef ref);
-
- // The message loop this object belongs to.
- scoped_refptr<base::MessageLoopProxy> message_loop_;
+ void PlatformAddDevice(IOHIDDeviceRef hid_device);
+ void PlatformRemoveDevice(IOHIDDeviceRef hid_device);
// Platform HID Manager
- base::ScopedCFTypeRef<IOHIDManagerRef> hid_manager_ref_;
+ base::ScopedCFTypeRef<IOHIDManagerRef> hid_manager_;
- // Enumeration thread.
- scoped_ptr<base::Thread> enumeration_runloop_thread_;
- CFRunLoopRef enumeration_runloop_;
- base::WaitableEvent enumeration_runloop_init_;
-
- bool available_;
+ // The message loop for the thread on which this service was created.
+ scoped_refptr<base::MessageLoopProxy> message_loop_;
DISALLOW_COPY_AND_ASSIGN(HidServiceMac);
};