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

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

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: with backward compatibility 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 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 Gamepad* gamepad = m_pendingEvents.takeFirst(); 165 Gamepad* gamepad = m_pendingEvents.takeFirst();
166 const AtomicString& eventName = gamepad->connected() ? EventTypeNames::gamep adconnected : EventTypeNames::gamepaddisconnected; 166 const AtomicString& eventName = gamepad->connected() ? EventTypeNames::gamep adconnected : EventTypeNames::gamepaddisconnected;
167 window()->dispatchEvent(GamepadEvent::create(eventName, false, true, gamepad )); 167 window()->dispatchEvent(GamepadEvent::create(eventName, false, true, gamepad ));
168 168
169 if (!m_pendingEvents.isEmpty()) 169 if (!m_pendingEvents.isEmpty())
170 m_dispatchOneEventRunner.runAsync(); 170 m_dispatchOneEventRunner.runAsync();
171 } 171 }
172 172
173 NavigatorGamepad::NavigatorGamepad(LocalFrame* frame) 173 NavigatorGamepad::NavigatorGamepad(LocalFrame* frame)
174 : DOMWindowProperty(frame) 174 : DOMWindowProperty(frame)
175 , DeviceEventControllerBase(frame ? frame->page() : 0) 175 , PlatformEventController(frame ? frame->page() : 0)
176 , DOMWindowLifecycleObserver(frame ? frame->domWindow() : 0) 176 , DOMWindowLifecycleObserver(frame ? frame->domWindow() : 0)
177 , m_dispatchOneEventRunner(this, &NavigatorGamepad::dispatchOneEvent) 177 , m_dispatchOneEventRunner(this, &NavigatorGamepad::dispatchOneEvent)
178 { 178 {
179 } 179 }
180 180
181 NavigatorGamepad::~NavigatorGamepad() 181 NavigatorGamepad::~NavigatorGamepad()
182 { 182 {
183 } 183 }
184 184
185 const char* NavigatorGamepad::supplementName() 185 const char* NavigatorGamepad::supplementName()
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 if (connectedGamepadChanged || (!oldWasConnected && newIsConnected)) { 284 if (connectedGamepadChanged || (!oldWasConnected && newIsConnected)) {
285 m_pendingEvents.append(newGamepad); 285 m_pendingEvents.append(newGamepad);
286 } 286 }
287 } 287 }
288 288
289 if (!m_pendingEvents.isEmpty()) 289 if (!m_pendingEvents.isEmpty())
290 m_dispatchOneEventRunner.runAsync(); 290 m_dispatchOneEventRunner.runAsync();
291 } 291 }
292 292
293 } // namespace blink 293 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698