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

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, 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 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 // Copyright (c) 2014, NVIDIA CORPORATION. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 3 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 4 // found in the LICENSE file.
4 5
5 #ifndef CONTENT_BROWSER_GAMEPAD_GAMEPAD_PROVIDER_H_ 6 #ifndef CONTENT_BROWSER_GAMEPAD_GAMEPAD_PROVIDER_H_
6 #define CONTENT_BROWSER_GAMEPAD_GAMEPAD_PROVIDER_H_ 7 #define CONTENT_BROWSER_GAMEPAD_GAMEPAD_PROVIDER_H_
7 8
8 #include <utility> 9 #include <utility>
9 #include <vector> 10 #include <vector>
10 11
11 #include "base/callback_forward.h" 12 #include "base/callback_forward.h"
(...skipping 24 matching lines...) Expand all
36 // Manually specifies the data fetcher. Used for testing. 37 // Manually specifies the data fetcher. Used for testing.
37 explicit GamepadProvider(scoped_ptr<GamepadDataFetcher> fetcher); 38 explicit GamepadProvider(scoped_ptr<GamepadDataFetcher> fetcher);
38 39
39 virtual ~GamepadProvider(); 40 virtual ~GamepadProvider();
40 41
41 // Returns the shared memory handle of the gamepad data duplicated into the 42 // Returns the shared memory handle of the gamepad data duplicated into the
42 // given process. 43 // given process.
43 base::SharedMemoryHandle GetSharedMemoryHandleForProcess( 44 base::SharedMemoryHandle GetSharedMemoryHandleForProcess(
44 base::ProcessHandle renderer_process); 45 base::ProcessHandle renderer_process);
45 46
47 #if defined(OS_ANDROID)
48 // Returns the state of polling thread regarding Gamepad Data reads via
49 // low-level data fetcher i.e. Paused or Resuming
50 bool GetPollState();
51 #endif
52
46 // Pause and resume the background polling thread. Can be called from any 53 // Pause and resume the background polling thread. Can be called from any
47 // thread. 54 // thread.
48 void Pause(); 55 void Pause();
49 void Resume(); 56 void Resume();
50 57
51 // Registers the given closure for calling when the user has interacted with 58 // Registers the given closure for calling when the user has interacted with
52 // the device. This callback will only be issued once. 59 // the device. This callback will only be issued once.
53 void RegisterForUserGesture(const base::Closure& closure); 60 void RegisterForUserGesture(const base::Closure& closure);
54 61
55 // base::SystemMonitor::DevicesChangedObserver implementation. 62 // base::SystemMonitor::DevicesChangedObserver implementation.
(...skipping 30 matching lines...) Expand all
86 // accidentally scheduling more than one at any time, when rapidly toggling 93 // accidentally scheduling more than one at any time, when rapidly toggling
87 // |is_paused_|. 94 // |is_paused_|.
88 bool have_scheduled_do_poll_; 95 bool have_scheduled_do_poll_;
89 96
90 // Lists all observers registered for user gestures, and the thread which 97 // 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 98 // 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 99 // 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. 100 // thread, the message loop proxies will normally just be the I/O thread.
94 // However, this will be the main thread for unit testing. 101 // However, this will be the main thread for unit testing.
95 base::Lock user_gesture_lock_; 102 base::Lock user_gesture_lock_;
103
104 #if defined(OS_ANDROID)
105 // Maximum time allowed for the thread before polling gets paused in
106 // milliseconds after last gamepad data access from consumer
107 static const int64 max_timestamp_before_pause_;
108 #endif
96 struct ClosureAndThread { 109 struct ClosureAndThread {
97 ClosureAndThread(const base::Closure& c, 110 ClosureAndThread(const base::Closure& c,
98 const scoped_refptr<base::MessageLoopProxy>& m); 111 const scoped_refptr<base::MessageLoopProxy>& m);
99 ~ClosureAndThread(); 112 ~ClosureAndThread();
100 113
101 base::Closure closure; 114 base::Closure closure;
102 scoped_refptr<base::MessageLoopProxy> message_loop; 115 scoped_refptr<base::MessageLoopProxy> message_loop;
103 }; 116 };
104 typedef std::vector<ClosureAndThread> UserGestureObserverVector; 117 typedef std::vector<ClosureAndThread> UserGestureObserverVector;
105 UserGestureObserverVector user_gesture_observers_; 118 UserGestureObserverVector user_gesture_observers_;
(...skipping 15 matching lines...) Expand all
121 scoped_ptr<base::Thread> polling_thread_; 134 scoped_ptr<base::Thread> polling_thread_;
122 135
123 static GamepadProvider* instance_; 136 static GamepadProvider* instance_;
124 137
125 DISALLOW_COPY_AND_ASSIGN(GamepadProvider); 138 DISALLOW_COPY_AND_ASSIGN(GamepadProvider);
126 }; 139 };
127 140
128 } // namespace content 141 } // namespace content
129 142
130 #endif // CONTENT_BROWSER_GAMEPAD_GAMEPAD_PROVIDER_H_ 143 #endif // CONTENT_BROWSER_GAMEPAD_GAMEPAD_PROVIDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698