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

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

Issue 133943002: Gamepad API support for chrome on android (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: 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 unified diff | Download patch
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_GAMEPAD_PROVIDER_H_ 5 #ifndef CONTENT_BROWSER_GAMEPAD_GAMEPAD_PROVIDER_H_
6 #define CONTENT_BROWSER_GAMEPAD_GAMEPAD_PROVIDER_H_ 6 #define CONTENT_BROWSER_GAMEPAD_GAMEPAD_PROVIDER_H_
7 7
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 25 matching lines...) Expand all
36 // Manually specifies the data fetcher. Used for testing. 36 // Manually specifies the data fetcher. Used for testing.
37 explicit GamepadProvider(scoped_ptr<GamepadDataFetcher> fetcher); 37 explicit GamepadProvider(scoped_ptr<GamepadDataFetcher> fetcher);
38 38
39 virtual ~GamepadProvider(); 39 virtual ~GamepadProvider();
40 40
41 // Returns the shared memory handle of the gamepad data duplicated into the 41 // Returns the shared memory handle of the gamepad data duplicated into the
42 // given process. 42 // given process.
43 base::SharedMemoryHandle GetSharedMemoryHandleForProcess( 43 base::SharedMemoryHandle GetSharedMemoryHandleForProcess(
44 base::ProcessHandle renderer_process); 44 base::ProcessHandle renderer_process);
45 45
46 // Returns the state of polling thread regarding Gamepad Data reads via
47 // low-level data fetcher i.e. Paused or Resuming
48 bool GetPollState();
49
46 // Pause and resume the background polling thread. Can be called from any 50 // Pause and resume the background polling thread. Can be called from any
47 // thread. 51 // thread.
48 void Pause(); 52 void Pause();
49 void Resume(); 53 void Resume();
50 54
51 // Registers the given closure for calling when the user has interacted with 55 // Registers the given closure for calling when the user has interacted with
52 // the device. This callback will only be issued once. 56 // the device. This callback will only be issued once.
53 void RegisterForUserGesture(const base::Closure& closure); 57 void RegisterForUserGesture(const base::Closure& closure);
54 58
55 // base::SystemMonitor::DevicesChangedObserver implementation. 59 // base::SystemMonitor::DevicesChangedObserver implementation.
(...skipping 30 matching lines...) Expand all
86 // accidentally scheduling more than one at any time, when rapidly toggling 90 // accidentally scheduling more than one at any time, when rapidly toggling
87 // |is_paused_|. 91 // |is_paused_|.
88 bool have_scheduled_do_poll_; 92 bool have_scheduled_do_poll_;
89 93
90 // Lists all observers registered for user gestures, and the thread which 94 // Lists all observers registered for user gestures, and the thread which
91 // to issue the callbacks on. Since we always issue the callback on the 95 // to issue the callbacks on. Since we always issue the callback on the
92 // thread which the registration happened, and this class lives on the I/O 96 // thread which the registration happened, and this class lives on the I/O
93 // thread, the message loop proxies will normally just be the I/O thread. 97 // thread, the message loop proxies will normally just be the I/O thread.
94 // However, this will be the main thread for unit testing. 98 // However, this will be the main thread for unit testing.
95 base::Lock user_gesture_lock_; 99 base::Lock user_gesture_lock_;
100
101 // Maximum time allowed for the thread before polling gets paused in
102 // milliseconds after last gamepad data access from consumer
103 static const int64 max_timestamp_before_pause_;
104
96 struct ClosureAndThread { 105 struct ClosureAndThread {
97 ClosureAndThread(const base::Closure& c, 106 ClosureAndThread(const base::Closure& c,
98 const scoped_refptr<base::MessageLoopProxy>& m); 107 const scoped_refptr<base::MessageLoopProxy>& m);
99 ~ClosureAndThread(); 108 ~ClosureAndThread();
100 109
101 base::Closure closure; 110 base::Closure closure;
102 scoped_refptr<base::MessageLoopProxy> message_loop; 111 scoped_refptr<base::MessageLoopProxy> message_loop;
103 }; 112 };
104 typedef std::vector<ClosureAndThread> UserGestureObserverVector; 113 typedef std::vector<ClosureAndThread> UserGestureObserverVector;
105 UserGestureObserverVector user_gesture_observers_; 114 UserGestureObserverVector user_gesture_observers_;
(...skipping 15 matching lines...) Expand all
121 scoped_ptr<base::Thread> polling_thread_; 130 scoped_ptr<base::Thread> polling_thread_;
122 131
123 static GamepadProvider* instance_; 132 static GamepadProvider* instance_;
124 133
125 DISALLOW_COPY_AND_ASSIGN(GamepadProvider); 134 DISALLOW_COPY_AND_ASSIGN(GamepadProvider);
126 }; 135 };
127 136
128 } // namespace content 137 } // namespace content
129 138
130 #endif // CONTENT_BROWSER_GAMEPAD_GAMEPAD_PROVIDER_H_ 139 #endif // CONTENT_BROWSER_GAMEPAD_GAMEPAD_PROVIDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698