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

Unified Diff: public/platform/Platform.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: with backward compatibility 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/modules/gamepad/NavigatorGamepad.cpp ('k') | public/platform/WebBatteryStatusListener.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: public/platform/Platform.h
diff --git a/public/platform/Platform.h b/public/platform/Platform.h
index 259143d042d95541d8b18bded3782dbfab592196..2afbe73cf1a0d0c6711881e66704a2543d21b4df 100644
--- a/public/platform/Platform.h
+++ b/public/platform/Platform.h
@@ -36,14 +36,18 @@
#endif
#include "WebAudioDevice.h"
+#include "WebBatteryStatusListener.h"
#include "WebCommon.h"
#include "WebData.h"
+#include "WebDeviceLightListener.h"
+#include "WebDeviceMotionListener.h"
+#include "WebDeviceOrientationListener.h"
#include "WebGamepadListener.h"
#include "WebGamepads.h"
#include "WebGestureDevice.h"
#include "WebGraphicsContext3D.h"
#include "WebLocalizedString.h"
-#include "WebLockOrientationCallback.h"
+#include "WebPlatformEventType.h"
#include "WebSpeechSynthesizer.h"
#include "WebStorageQuotaCallbacks.h"
#include "WebStorageQuotaType.h"
@@ -56,7 +60,6 @@ class GrContext;
namespace blink {
class WebAudioBus;
-class WebBatteryStatusListener;
class WebBlobRegistry;
class WebContentDecryptionModule;
class WebClipboard;
@@ -65,10 +68,8 @@ class WebConvertableToTraceFormat;
class WebCookieJar;
class WebCrypto;
class WebDatabaseObserver;
-class WebDeviceLightListener;
-class WebDeviceMotionListener;
-class WebDeviceOrientationListener;
class WebDiscardableMemory;
+class WebPlatformEventListener;
class WebFallbackThemeEngine;
class WebFileSystem;
class WebFileUtilities;
@@ -163,12 +164,6 @@ public:
virtual WebMIDIAccessor* createMIDIAccessor(WebMIDIAccessorClient*) { return 0; }
- // Battery -------------------------------------------------------------
-
- // Sets the listener for watching battery status updates.
- virtual void setBatteryStatusListener(blink::WebBatteryStatusListener*) { }
-
-
// Blob ----------------------------------------------------------------
// Must return non-null.
@@ -221,8 +216,6 @@ public:
virtual void sampleGamepads(WebGamepads& into) { into.length = 0; }
- virtual void setGamepadListener(WebGamepadListener*) { }
-
// History -------------------------------------------------------------
@@ -603,19 +596,61 @@ public:
virtual WebCrypto* crypto() { return 0; }
- // Device Motion / Orientation / Light ----------------------------------------
+ // Platform events -----------------------------------------------------
+ // Device Orientation, Device Motion, Device Light, Battery, Gamepad.
- // Sets a Listener to listen for device motion data updates.
- // If null, the platform stops providing device motion data to the current listener.
- virtual void setDeviceMotionListener(blink::WebDeviceMotionListener*) { }
+ // Request the platform to start listening to the specified event and
timvolodine 2014/07/30 12:56:41 nit: "to the specified event" -> "to events of spe
mlamouri (slow - plz ping) 2014/08/01 10:21:05 Done.
+ // notify the given listener (if not null) when there is an update.
+ virtual void startListening(blink::WebPlatformEventType type, blink::WebPlatformEventListener* listener)
abarth-chromium 2014/07/29 22:24:38 Why virtual? It seems like we should implement th
mlamouri (slow - plz ping) 2014/07/29 22:27:54 The only intent is to not break Chromium when this
+ {
+ switch (type) {
+ case blink::WebPlatformEventDeviceMotion:
+ setDeviceMotionListener(static_cast<blink::WebDeviceMotionListener*>(listener));
+ break;
+ case blink::WebPlatformEventDeviceOrientation:
+ setDeviceOrientationListener(static_cast<blink::WebDeviceOrientationListener*>(listener));
+ break;
+ case blink::WebPlatformEventDeviceLight:
+ setDeviceLightListener(static_cast<blink::WebDeviceLightListener*>(listener));
+ break;
+ case blink::WebPlatformEventBattery:
+ setBatteryStatusListener(static_cast<blink::WebBatteryStatusListener*>(listener));
+ break;
+ case blink::WebPlatformEventGamepad:
+ setGamepadListener(static_cast<blink::WebGamepadListener*>(listener));
+ break;
+ }
+ }
- // Sets a Listener to listen for device orientation data updates.
- // If null, the platform stops providing device orientation data to the current listener.
- virtual void setDeviceOrientationListener(blink::WebDeviceOrientationListener*) { }
+ // Request the platform to stop listening to the specified event and no
+ // longer notify the listener, if any.
+ virtual void stopListening(blink::WebPlatformEventType type)
+ {
+ switch (type) {
+ case blink::WebPlatformEventDeviceMotion:
+ setDeviceMotionListener(0);
+ break;
+ case blink::WebPlatformEventDeviceOrientation:
+ setDeviceOrientationListener(0);
+ break;
+ case blink::WebPlatformEventDeviceLight:
+ setDeviceLightListener(0);
+ break;
+ case blink::WebPlatformEventBattery:
+ setBatteryStatusListener(0);
+ break;
+ case blink::WebPlatformEventGamepad:
+ setGamepadListener(0);
+ break;
+ }
+ }
- // Sets a Listener to listen for device light data updates.
- // If null, the platform stops providing device light data to the current listener.
+ // Deprecated: remove when content/ is updated.
abarth-chromium 2014/07/30 05:56:23 I see, this comment was intended to communicate th
mlamouri (slow - plz ping) 2014/08/01 10:21:05 Yes. I've added a FIXME to make it clearer.
+ virtual void setDeviceMotionListener(blink::WebDeviceMotionListener*) { }
+ virtual void setDeviceOrientationListener(blink::WebDeviceOrientationListener*) { }
virtual void setDeviceLightListener(blink::WebDeviceLightListener*) { }
+ virtual void setBatteryStatusListener(blink::WebBatteryStatusListener*) { }
+ virtual void setGamepadListener(blink::WebGamepadListener*) { }
// Quota -----------------------------------------------------------
« no previous file with comments | « Source/modules/gamepad/NavigatorGamepad.cpp ('k') | public/platform/WebBatteryStatusListener.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698