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

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

Issue 417213002: Introduce PlatformEvent to handle Device events, Battery events and Gamepad events. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebase Created 6 years, 4 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 10 matching lines...) Expand all
21 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 21 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
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/PlatformEventController.h"
32 #include "platform/AsyncMethodRunner.h" 32 #include "platform/AsyncMethodRunner.h"
33 #include "platform/Supplementable.h" 33 #include "platform/Supplementable.h"
34 #include "platform/heap/Handle.h" 34 #include "platform/heap/Handle.h"
35 #include "public/platform/WebGamepads.h" 35 #include "public/platform/WebGamepads.h"
36 36
37 namespace blink { 37 namespace blink {
38 class WebGamepad; 38 class WebGamepad;
39 class WebGamepads; 39 class WebGamepads;
40 } 40 }
41 41
42 namespace blink { 42 namespace blink {
43 43
44 class Document; 44 class Document;
45 class Gamepad; 45 class Gamepad;
46 class GamepadList; 46 class GamepadList;
47 class Navigator; 47 class Navigator;
48 class WebKitGamepadList; 48 class WebKitGamepadList;
49 49
50 class NavigatorGamepad FINAL : public NoBaseWillBeGarbageCollectedFinalized<Navi gatorGamepad>, public WillBeHeapSupplement<Navigator>, public DOMWindowProperty, public DeviceEventControllerBase, public DOMWindowLifecycleObserver { 50 class NavigatorGamepad FINAL : public NoBaseWillBeGarbageCollectedFinalized<Navi gatorGamepad>, public WillBeHeapSupplement<Navigator>, public DOMWindowProperty, public PlatformEventController, public DOMWindowLifecycleObserver {
51 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(NavigatorGamepad); 51 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(NavigatorGamepad);
52 public: 52 public:
53 static NavigatorGamepad* from(Document&); 53 static NavigatorGamepad* from(Document&);
54 static NavigatorGamepad& from(Navigator&); 54 static NavigatorGamepad& from(Navigator&);
55 virtual ~NavigatorGamepad(); 55 virtual ~NavigatorGamepad();
56 56
57 static WebKitGamepadList* webkitGetGamepads(Navigator&); 57 static WebKitGamepadList* webkitGetGamepads(Navigator&);
58 static GamepadList* getGamepads(Navigator&); 58 static GamepadList* getGamepads(Navigator&);
59 59
60 WebKitGamepadList* webkitGamepads(); 60 WebKitGamepadList* webkitGamepads();
61 GamepadList* gamepads(); 61 GamepadList* gamepads();
62 62
63 virtual void trace(Visitor*); 63 virtual void trace(Visitor*);
64 64
65 void didConnectOrDisconnectGamepad(unsigned index, const blink::WebGamepad&, bool connected); 65 void didConnectOrDisconnectGamepad(unsigned index, const blink::WebGamepad&, bool connected);
66 66
67 private: 67 private:
68 explicit NavigatorGamepad(LocalFrame*); 68 explicit NavigatorGamepad(LocalFrame*);
69 69
70 static const char* supplementName(); 70 static const char* supplementName();
71 71
72 void dispatchOneEvent(); 72 void dispatchOneEvent();
73 void didRemoveGamepadEventListeners(); 73 void didRemoveGamepadEventListeners();
74 74
75 // DOMWindowProperty 75 // DOMWindowProperty
76 virtual void willDestroyGlobalObjectInFrame() OVERRIDE; 76 virtual void willDestroyGlobalObjectInFrame() OVERRIDE;
77 virtual void willDetachGlobalObjectFromFrame() OVERRIDE; 77 virtual void willDetachGlobalObjectFromFrame() OVERRIDE;
78 78
79 // DeviceEventControllerBase 79 // PlatformEventController
80 virtual void registerWithDispatcher() OVERRIDE; 80 virtual void registerWithDispatcher() OVERRIDE;
81 virtual void unregisterWithDispatcher() OVERRIDE; 81 virtual void unregisterWithDispatcher() OVERRIDE;
82 virtual bool hasLastData() OVERRIDE; 82 virtual bool hasLastData() OVERRIDE;
83 virtual void didUpdateData() OVERRIDE; 83 virtual void didUpdateData() OVERRIDE;
84 virtual void pageVisibilityChanged() OVERRIDE; 84 virtual void pageVisibilityChanged() OVERRIDE;
85 85
86 // DOMWindowLifecycleObserver 86 // DOMWindowLifecycleObserver
87 virtual void didAddEventListener(LocalDOMWindow*, const AtomicString&) OVERR IDE; 87 virtual void didAddEventListener(LocalDOMWindow*, const AtomicString&) OVERR IDE;
88 virtual void didRemoveEventListener(LocalDOMWindow*, const AtomicString&) OV ERRIDE; 88 virtual void didRemoveEventListener(LocalDOMWindow*, const AtomicString&) OV ERRIDE;
89 virtual void didRemoveAllEventListeners(LocalDOMWindow*) OVERRIDE; 89 virtual void didRemoveAllEventListeners(LocalDOMWindow*) OVERRIDE;
90 90
91 PersistentWillBeMember<GamepadList> m_gamepads; 91 PersistentWillBeMember<GamepadList> m_gamepads;
92 PersistentWillBeMember<WebKitGamepadList> m_webkitGamepads; 92 PersistentWillBeMember<WebKitGamepadList> m_webkitGamepads;
93 PersistentHeapDequeWillBeHeapDeque<Member<Gamepad> > m_pendingEvents; 93 PersistentHeapDequeWillBeHeapDeque<Member<Gamepad> > m_pendingEvents;
94 AsyncMethodRunner<NavigatorGamepad> m_dispatchOneEventRunner; 94 AsyncMethodRunner<NavigatorGamepad> m_dispatchOneEventRunner;
95 }; 95 };
96 96
97 } // namespace blink 97 } // namespace blink
98 98
99 #endif // NavigatorGamepad_h 99 #endif // NavigatorGamepad_h
OLDNEW
« no previous file with comments | « Source/modules/gamepad/GamepadDispatcher.cpp ('k') | Source/modules/gamepad/NavigatorGamepad.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698