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

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

Issue 8760023: Add GamepadService, owns 1 gamepad bg thread (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: merge HEAD 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 // Owns the GamepadProvider (the background polling thread) and keeps track of
6 // the number of renderers currently using the data (and pausing the provider
7 // when not in use).
8
9 #ifndef CONTENT_BROWSER_GAMEPAD_GAMEPAD_SERVICE_H
10 #define CONTENT_BROWSER_GAMEPAD_GAMEPAD_SERVICE_H
11
12 #include "base/basictypes.h"
13 #include "base/memory/singleton.h"
14 #include "base/shared_memory.h"
15 #include "content/public/browser/notification_observer.h"
16 #include "content/public/browser/notification_registrar.h"
17
18 namespace content {
19
20 class GamepadDataFetcher;
21 class GamepadProvider;
22 class RenderProcessHost;
23
24 class GamepadService : public NotificationObserver {
25 public:
26 // Returns the GamepadService singleton.
27 static GamepadService* GetInstance();
28
29 // Called on IO thread from a renderer host. Increments the number of users
30 // of the provider. The Provider is running when there's > 0 users, and is
31 // paused when the count drops to 0. There is no stop, the gamepad service
32 // registers with the RPH to be notified when the associated renderer closes
33 // (or crashes).
34 void Start(GamepadDataFetcher* fetcher,
35 RenderProcessHost* associated_rph);
36
37 base::SharedMemoryHandle GetSharedMemoryHandle(base::ProcessHandle handle);
38
39 private:
40 friend struct DefaultSingletonTraits<GamepadService>;
41 friend class base::RefCountedThreadSafe<GamepadService>;
42 GamepadService();
43 virtual ~GamepadService();
44
45 // Called when a renderer that Start'd us is closed/crashes.
46 void Stop();
47
48 // Run on UI thread to receive notifications of renderer closes.
49 void RegisterForCloseNotification(RenderProcessHost* rph);
50
51 // NotificationObserver overrides:
52 virtual void Observe(int type,
53 const NotificationSource& source,
54 const NotificationDetails& details) OVERRIDE;
55
56 // A registrar for listening notifications. Used to listen for when an
57 // associated renderer has gone away (possibly crashed). We don't trust
58 // the renderers to send a stop message because of the possibility of
59 // crashing.
60 NotificationRegistrar registrar_;
61
62 int num_readers_;
63 scoped_refptr<GamepadProvider> provider_;
64
65 DISALLOW_COPY_AND_ASSIGN(GamepadService);
66 };
67
68 } // namespace content
69
70 #endif // CONTENT_BROWSER_GAMEPAD_GAMEPAD_SERVICE_H
OLDNEW
« no previous file with comments | « content/browser/gamepad/gamepad_provider_unittest.cc ('k') | content/browser/gamepad/gamepad_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698