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

Side by Side Diff: Source/modules/gamepad/NavigatorGamepad.h

Issue 346273008: Gamepad: make gamepad events play well with page visibility (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@gamepad-vis
Patch Set: queueing Created 6 years, 5 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 /* 1 /*
2 * Copyright (C) 2011, Google Inc. All rights reserved. 2 * Copyright (C) 2011, Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met: 5 * modification, are permitted provided that the following conditions are met:
6 * 6 *
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 11 matching lines...) Expand all
22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
23 * DAMAGE. 23 * DAMAGE.
24 */ 24 */
25 25
26 #ifndef NavigatorGamepad_h 26 #ifndef NavigatorGamepad_h
27 #define NavigatorGamepad_h 27 #define NavigatorGamepad_h
28 28
29 #include "core/frame/DOMWindowLifecycleObserver.h" 29 #include "core/frame/DOMWindowLifecycleObserver.h"
30 #include "core/frame/DOMWindowProperty.h" 30 #include "core/frame/DOMWindowProperty.h"
31 #include "core/frame/DeviceEventControllerBase.h" 31 #include "core/frame/DeviceEventControllerBase.h"
32 #include "platform/AsyncMethodRunner.h"
32 #include "platform/Supplementable.h" 33 #include "platform/Supplementable.h"
33 #include "platform/heap/Handle.h" 34 #include "platform/heap/Handle.h"
34 #include "public/platform/WebGamepads.h" 35 #include "public/platform/WebGamepads.h"
36 #include "wtf/Deque.h"
35 37
36 namespace blink { 38 namespace blink {
37 class WebGamepad; 39 class WebGamepad;
38 class WebGamepads; 40 class WebGamepads;
39 } 41 }
40 42
41 namespace WebCore { 43 namespace WebCore {
42 44
43 class Document; 45 class Document;
46 class Gamepad;
44 class GamepadList; 47 class GamepadList;
45 class Navigator; 48 class Navigator;
46 class WebKitGamepadList; 49 class WebKitGamepadList;
47 50
48 class NavigatorGamepad FINAL : public NoBaseWillBeGarbageCollectedFinalized<Navi gatorGamepad>, public WillBeHeapSupplement<Navigator>, public DOMWindowProperty, public DeviceEventControllerBase, public DOMWindowLifecycleObserver { 51 class NavigatorGamepad FINAL : public NoBaseWillBeGarbageCollectedFinalized<Navi gatorGamepad>, public WillBeHeapSupplement<Navigator>, public DOMWindowProperty, public DeviceEventControllerBase, public DOMWindowLifecycleObserver {
49 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(NavigatorGamepad); 52 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(NavigatorGamepad);
50 public: 53 public:
51 static NavigatorGamepad* from(Document&); 54 static NavigatorGamepad* from(Document&);
52 static NavigatorGamepad& from(Navigator&); 55 static NavigatorGamepad& from(Navigator&);
53 virtual ~NavigatorGamepad(); 56 virtual ~NavigatorGamepad();
54 57
55 static WebKitGamepadList* webkitGetGamepads(Navigator&); 58 static WebKitGamepadList* webkitGetGamepads(Navigator&);
56 static GamepadList* getGamepads(Navigator&); 59 static GamepadList* getGamepads(Navigator&);
57 60
58 WebKitGamepadList* webkitGamepads(); 61 WebKitGamepadList* webkitGamepads();
59 GamepadList* gamepads(); 62 GamepadList* gamepads();
60 63
61 virtual void trace(Visitor*); 64 virtual void trace(Visitor*);
62 65
63 void didConnectOrDisconnectGamepad(unsigned index, const blink::WebGamepad&, bool connected); 66 void didConnectOrDisconnectGamepad(unsigned index, const blink::WebGamepad&, bool connected);
64 67
65 private: 68 private:
66 explicit NavigatorGamepad(LocalFrame*); 69 explicit NavigatorGamepad(LocalFrame*);
67 70
68 static const char* supplementName(); 71 static const char* supplementName();
69 72
73 void dispatchOneEvent();
74 void didRemoveGamepadEventListeners();
75
70 // DOMWindowProperty 76 // DOMWindowProperty
71 virtual void willDestroyGlobalObjectInFrame() OVERRIDE; 77 virtual void willDestroyGlobalObjectInFrame() OVERRIDE;
72 virtual void willDetachGlobalObjectFromFrame() OVERRIDE; 78 virtual void willDetachGlobalObjectFromFrame() OVERRIDE;
73 79
74 // DeviceEventControllerBase 80 // DeviceEventControllerBase
75 virtual void registerWithDispatcher() OVERRIDE; 81 virtual void registerWithDispatcher() OVERRIDE;
76 virtual void unregisterWithDispatcher() OVERRIDE; 82 virtual void unregisterWithDispatcher() OVERRIDE;
77 virtual bool hasLastData() OVERRIDE; 83 virtual bool hasLastData() OVERRIDE;
78 virtual void didUpdateData() OVERRIDE; 84 virtual void didUpdateData() OVERRIDE;
79 virtual void pageVisibilityChanged() OVERRIDE; 85 virtual void pageVisibilityChanged() OVERRIDE;
80 86
81 // DOMWindowLifecycleObserver 87 // DOMWindowLifecycleObserver
82 virtual void didAddEventListener(LocalDOMWindow*, const AtomicString&) OVERR IDE; 88 virtual void didAddEventListener(LocalDOMWindow*, const AtomicString&) OVERR IDE;
83 virtual void didRemoveEventListener(LocalDOMWindow*, const AtomicString&) OV ERRIDE; 89 virtual void didRemoveEventListener(LocalDOMWindow*, const AtomicString&) OV ERRIDE;
84 virtual void didRemoveAllEventListeners(LocalDOMWindow*) OVERRIDE; 90 virtual void didRemoveAllEventListeners(LocalDOMWindow*) OVERRIDE;
85 91
86 PersistentWillBeMember<GamepadList> m_gamepads; 92 PersistentWillBeMember<GamepadList> m_gamepads;
87 PersistentWillBeMember<WebKitGamepadList> m_webkitGamepads; 93 PersistentWillBeMember<WebKitGamepadList> m_webkitGamepads;
94 AsyncMethodRunner<NavigatorGamepad> m_dispatchOneEventRunner;
95 Deque<Gamepad*> m_pendingEvents;
abarth-chromium 2014/07/07 22:11:04 Don't we need to trace these Gamepad* so that they
88 }; 96 };
89 97
90 } // namespace WebCore 98 } // namespace WebCore
91 99
92 #endif // NavigatorGamepad_h 100 #endif // NavigatorGamepad_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698