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

Side by Side Diff: content/browser/gamepad/platform_data_fetcher_linux.h

Issue 10824036: Linux: Refactor udev device monitoring code into its own class so it can be reused more easily. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix typo Created 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | content/browser/gamepad/platform_data_fetcher_linux.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_BROWSER_GAMEPAD_PLATFORM_DATA_FETCHER_LINUX_H_ 5 #ifndef CONTENT_BROWSER_GAMEPAD_PLATFORM_DATA_FETCHER_LINUX_H_
6 #define CONTENT_BROWSER_GAMEPAD_PLATFORM_DATA_FETCHER_LINUX_H_ 6 #define CONTENT_BROWSER_GAMEPAD_PLATFORM_DATA_FETCHER_LINUX_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/message_pump_libevent.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "build/build_config.h"
14 #include "content/browser/gamepad/data_fetcher.h" 13 #include "content/browser/gamepad/data_fetcher.h"
15 #include "content/browser/gamepad/gamepad_standard_mappings.h" 14 #include "content/browser/gamepad/gamepad_standard_mappings.h"
16 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebGamepads. h" 15 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebGamepads. h"
17 16
18 extern "C" { 17 extern "C" {
19 struct udev;
20 struct udev_device; 18 struct udev_device;
21 struct udev_monitor;
22 } 19 }
23 20
24 namespace content { 21 namespace content {
25 22
26 class GamepadPlatformDataFetcherLinux : 23 class UdevLinux;
27 public GamepadDataFetcher, 24
28 public base::MessagePumpLibevent::Watcher { 25 class GamepadPlatformDataFetcherLinux : public GamepadDataFetcher {
29 public: 26 public:
30 GamepadPlatformDataFetcherLinux(); 27 GamepadPlatformDataFetcherLinux();
31 virtual ~GamepadPlatformDataFetcherLinux(); 28 virtual ~GamepadPlatformDataFetcherLinux();
32 29
33 // GamepadDataFetcher: 30 // GamepadDataFetcher implementation.
34 virtual void GetGamepadData(WebKit::WebGamepads* pads, 31 virtual void GetGamepadData(WebKit::WebGamepads* pads,
35 bool devices_changed_hint) OVERRIDE; 32 bool devices_changed_hint) OVERRIDE;
36 33
37 // base::MessagePump:Libevent::Watcher:
38 virtual void OnFileCanReadWithoutBlocking(int fd) OVERRIDE;
39 virtual void OnFileCanWriteWithoutBlocking(int fd) OVERRIDE;
40
41 private: 34 private:
42 void RefreshDevice(udev_device* dev); 35 void RefreshDevice(udev_device* dev);
43 void EnumerateDevices(); 36 void EnumerateDevices();
44 void ReadDeviceData(size_t index); 37 void ReadDeviceData(size_t index);
45 38
46 // libudev-related items, the main context, and the monitoring context to be
47 // notified about changes to device states.
48 udev* udev_;
49 udev_monitor* monitor_;
50 int monitor_fd_;
51 base::MessagePumpLibevent::FileDescriptorWatcher monitor_watcher_;
52
53 // File descriptors for the /dev/input/js* devices. -1 if not in use. 39 // File descriptors for the /dev/input/js* devices. -1 if not in use.
54 int device_fds_[WebKit::WebGamepads::itemsLengthCap]; 40 int device_fds_[WebKit::WebGamepads::itemsLengthCap];
55 41
56 // Functions to map from device data to standard layout, if available. May 42 // Functions to map from device data to standard layout, if available. May
57 // be null if no mapping is available. 43 // be null if no mapping is available.
58 GamepadStandardMappingFunction mappers_[WebKit::WebGamepads::itemsLengthCap]; 44 GamepadStandardMappingFunction mappers_[WebKit::WebGamepads::itemsLengthCap];
59 45
60 // Data that's returned to the consumer. 46 // Data that's returned to the consumer.
61 WebKit::WebGamepads data_; 47 WebKit::WebGamepads data_;
62 48
49 scoped_ptr<UdevLinux> udev_;
50
63 DISALLOW_COPY_AND_ASSIGN(GamepadPlatformDataFetcherLinux); 51 DISALLOW_COPY_AND_ASSIGN(GamepadPlatformDataFetcherLinux);
64 }; 52 };
65 53
66 } // namespace content 54 } // namespace content
67 55
68 #endif // CONTENT_BROWSER_GAMEPAD_PLATFORM_DATA_FETCHER_LINUX_H_ 56 #endif // CONTENT_BROWSER_GAMEPAD_PLATFORM_DATA_FETCHER_LINUX_H_
OLDNEW
« no previous file with comments | « no previous file | content/browser/gamepad/platform_data_fetcher_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698