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

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

Powered by Google App Engine
This is Rietveld 408576698