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

Side by Side Diff: content/browser/gamepad/gamepad_service.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_SERVICE_H 6 #ifndef CONTENT_BROWSER_GAMEPAD_GAMEPAD_SERVICE_H
6 #define CONTENT_BROWSER_GAMEPAD_GAMEPAD_SERVICE_H 7 #define CONTENT_BROWSER_GAMEPAD_GAMEPAD_SERVICE_H
7 8
8 #include "base/basictypes.h" 9 #include "base/basictypes.h"
9 #include "base/callback_forward.h" 10 #include "base/callback_forward.h"
10 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
11 #include "base/memory/shared_memory.h" 12 #include "base/memory/shared_memory.h"
12 #include "base/memory/singleton.h" 13 #include "base/memory/singleton.h"
13 #include "base/threading/thread_checker.h" 14 #include "base/threading/thread_checker.h"
15 #include "base/time/time.h"
14 #include "content/common/content_export.h" 16 #include "content/common/content_export.h"
15 17
16 namespace content { 18 namespace content {
17 19
18 class GamepadDataFetcher; 20 class GamepadDataFetcher;
19 class GamepadProvider; 21 class GamepadProvider;
20 class GamepadServiceTestConstructor; 22 class GamepadServiceTestConstructor;
21 class RenderProcessHost; 23 class RenderProcessHost;
22 24
23 // Owns the GamepadProvider (the background polling thread) and keeps track of 25 // Owns the GamepadProvider (the background polling thread) and keeps track of
(...skipping 13 matching lines...) Expand all
37 // Removes a consumer. Should be matched with an AddConsumer call. 39 // Removes a consumer. Should be matched with an AddConsumer call.
38 // 40 //
39 // Must be called on the I/O thread. 41 // Must be called on the I/O thread.
40 void RemoveConsumer(); 42 void RemoveConsumer();
41 43
42 // Registers the given closure for calling when the user has interacted with 44 // Registers the given closure for calling when the user has interacted with
43 // the device. This callback will only be issued once. Should only be called 45 // the device. This callback will only be issued once. Should only be called
44 // while a consumer is active. 46 // while a consumer is active.
45 void RegisterForUserGesture(const base::Closure& closure); 47 void RegisterForUserGesture(const base::Closure& closure);
46 48
49 #if defined(OS_ANDROID)
50 // Setter amd getter for the last Gamepad Data access timestamp accessed by
51 // the consumer
52 void SetGamepadAccessTimestamp(base::Time);
53 base::Time GetGamepadAccessTimestamp();
54
55 // Returns the state of polling thread regarding Gamepad Data reads via
56 // low-level data fetcher i.e. Paused or Resuming
57 bool GetPollState();
58
59 // Manages pause and resume state of polling thread in GamepadProvider
60 // |provider_|.
61 void Pause();
62 void Resume();
63 #endif
64
47 // Returns the shared memory handle of the gamepad data duplicated into the 65 // Returns the shared memory handle of the gamepad data duplicated into the
48 // given process. 66 // given process.
49 base::SharedMemoryHandle GetSharedMemoryHandleForProcess( 67 base::SharedMemoryHandle GetSharedMemoryHandleForProcess(
50 base::ProcessHandle handle); 68 base::ProcessHandle handle);
51 69
52 // Stop/join with the background thread in GamepadProvider |provider_|. 70 // Stop/join with the background thread in GamepadProvider |provider_|.
53 void Terminate(); 71 void Terminate();
54 72
55 private: 73 private:
56 friend struct DefaultSingletonTraits<GamepadService>; 74 friend struct DefaultSingletonTraits<GamepadService>;
57 friend class GamepadServiceTestConstructor; 75 friend class GamepadServiceTestConstructor;
58 76
59 GamepadService(); 77 GamepadService();
60 78
61 // Constructor for testing. This specifies the data fetcher to use for a 79 // Constructor for testing. This specifies the data fetcher to use for a
62 // provider, bypassing the default platform one. 80 // provider, bypassing the default platform one.
63 GamepadService(scoped_ptr<GamepadDataFetcher> fetcher); 81 GamepadService(scoped_ptr<GamepadDataFetcher> fetcher);
64 82
65 virtual ~GamepadService(); 83 virtual ~GamepadService();
66 84
67 int num_readers_; 85 int num_readers_;
86
87 #if defined(OS_ANDROID)
88 // Maintans the timestamp for last Gamepad Data access
89 base::Time gamepad_access_timestamp_;
90 #endif
68 scoped_ptr<GamepadProvider> provider_; 91 scoped_ptr<GamepadProvider> provider_;
69 92
70 base::ThreadChecker thread_checker_; 93 base::ThreadChecker thread_checker_;
71 94
72 DISALLOW_COPY_AND_ASSIGN(GamepadService); 95 DISALLOW_COPY_AND_ASSIGN(GamepadService);
73 }; 96 };
74 97
75 } // namespace content 98 } // namespace content
76 99
77 #endif // CONTENT_BROWSER_GAMEPAD_GAMEPAD_SERVICE_H_ 100 #endif // CONTENT_BROWSER_GAMEPAD_GAMEPAD_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698