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

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

Issue 8568029: Add gamepad hardware data fetcher, and higher level thread container (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: delayload xinput for XP Created 9 years 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
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CONTENT_BROWSER_GAMEPAD_PROVIDER_H_
6 #define CONTENT_BROWSER_GAMEPAD_PROVIDER_H_
7
8 #include "base/memory/scoped_ptr.h"
9 #include "base/memory/weak_ptr.h"
10 #include "base/message_loop_proxy.h"
11 #include "base/shared_memory.h"
12 #include "base/system_monitor/system_monitor.h"
13 #include "base/task.h"
14 #include "content/browser/gamepad/data_fetcher.h"
15 #include "content/common/gamepad_hardware_buffer.h"
16
17 namespace base {
18 class Thread;
19 }
20
21 struct GamepadMsg_Updated_Params;
22
23 namespace gamepad {
24
25 class Provider : public base::RefCountedThreadSafe<Provider>,
26 public base::SystemMonitor::DevicesChangedObserver {
27 public:
28 explicit Provider(DataFetcher* fetcher);
29
30 // Starts or Stops the provider. Called from creator_loop_.
31 void Start();
32 void Stop();
33 base::SharedMemoryHandle GetRendererSharedMemoryHandle(
34 base::ProcessHandle renderer_process);
35
36 private:
37 friend class base::RefCountedThreadSafe<Provider>;
38
39 virtual ~Provider();
40
41 // Method for starting the polling, runs on polling_thread_.
42 void DoInitializePollingThread();
43
44 // Method for polling a DataFetcher. Runs on the polling_thread_.
45 void DoPoll();
46 void ScheduleDoPoll();
47
48 virtual void OnDevicesChanged() OVERRIDE;
49
50 GamepadHardwareBuffer* SharedMemoryAsHardwareBuffer();
51
52 enum { kDesiredSamplingIntervalMs = 16 };
53
54 // The Message Loop on which this object was created.
55 // Typically the I/O loop, but may be something else during testing.
56 scoped_refptr<base::MessageLoopProxy> creator_loop_;
57 scoped_ptr<DataFetcher> provided_fetcher_;
58
59 // When polling_thread_ is running, members below are only to be used
60 // from that thread.
61 scoped_ptr<DataFetcher> data_fetcher_;
62 base::SharedMemory gamepad_shared_memory_;
63 bool devices_changed_;
64
65 // Polling is done on this background thread.
66 scoped_ptr<base::Thread> polling_thread_;
67
68 static Provider* instance_;
69 base::WeakPtrFactory<Provider> weak_factory_;
70
71 DISALLOW_COPY_AND_ASSIGN(Provider);
72 };
73
74 } // namespace gamepad
75
76 #endif // CONTENT_BROWSER_GAMEPAD_PROVIDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698