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

Unified Diff: content/renderer/renderer_webkitplatformsupport_impl.h

Issue 446603002: Refactor code listening to platform events in content/renderer/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@webkitplatform_impl_start_stop
Patch Set: apply review comments 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 side-by-side diff with in-line comments
Download patch
Index: content/renderer/renderer_webkitplatformsupport_impl.h
diff --git a/content/renderer/renderer_webkitplatformsupport_impl.h b/content/renderer/renderer_webkitplatformsupport_impl.h
index 209da825f3357dd5a7321d1b97d83eb230b7e0e9..86734d733544e7e1c882fc5543dd34b85c203ce7 100644
--- a/content/renderer/renderer_webkitplatformsupport_impl.h
+++ b/content/renderer/renderer_webkitplatformsupport_impl.h
@@ -6,6 +6,7 @@
#define CONTENT_RENDERER_RENDERER_WEBKITPLATFORMSUPPORT_IMPL_H_
#include "base/compiler_specific.h"
+#include "base/id_map.h"
#include "base/memory/scoped_ptr.h"
#include "content/child/blink_platform_impl.h"
#include "content/common/content_export.h"
@@ -39,10 +40,10 @@ class BatteryStatusDispatcher;
class DeviceLightEventPump;
class DeviceMotionEventPump;
class DeviceOrientationEventPump;
+class PlatformEventObserverBase;
class QuotaMessageFilter;
class RendererClipboardClient;
class RenderView;
-class RendererGamepadProvider;
class ThreadSafeSender;
class WebClipboardImpl;
class WebDatabaseObserverImpl;
@@ -146,9 +147,12 @@ class CONTENT_EXPORT RendererWebKitPlatformSupportImpl
virtual void vibrate(unsigned int milliseconds);
virtual void cancelVibration();
- void set_gamepad_provider(RendererGamepadProvider* provider) {
- gamepad_provider_ = provider;
- }
+ // Set the PlatformEventObserverBase in |platform_event_observers_| associated
+ // with |type| to |observer|. If there was already an observer associated to
+ // the given |type|, it will be overridden.
Avi (use Gerrit) 2014/08/07 19:56:11 What does "overridden" mean here? Use "replaced" i
mlamouri (slow - plz ping) 2014/08/08 18:08:36 Done.
+ // Note that |observer| will be owned by this object after the call.
Avi (use Gerrit) 2014/08/07 19:56:11 If you are taking ownership, indicate that in the
mlamouri (slow - plz ping) 2014/08/08 18:08:36 Done.
+ void SetPlatformEventObserverForTesting(blink::WebPlatformEventType type,
+ PlatformEventObserverBase* observer);
// Disables the WebSandboxSupport implementation for testing.
// Tests that do not set up a full sandbox environment should call
@@ -170,7 +174,7 @@ class CONTENT_EXPORT RendererWebKitPlatformSupportImpl
const blink::WebDeviceOrientationData& data);
// Notifies blink::WebBatteryStatusListener that battery status has changed.
- static void MockBatteryStatusChangedForTesting(
+ void MockBatteryStatusChangedForTesting(
const blink::WebBatteryStatus& status);
WebDatabaseObserverImpl* web_database_observer_impl() {
@@ -180,14 +184,14 @@ class CONTENT_EXPORT RendererWebKitPlatformSupportImpl
private:
bool CheckPreparsedJsCachingEnabled() const;
- // Implement those methods internally so startListening() and stopListening()
- // are being used and Blink can change its interface.
- void SetDeviceMotionListener(blink::WebDeviceMotionListener*);
- void SetDeviceOrientationListener(blink::WebDeviceOrientationListener*);
- void SetDeviceLightListener(blink::WebDeviceLightListener*);
- void SetBatteryStatusListener(blink::WebBatteryStatusListener*);
- void SetGamepadListener(blink::WebGamepadListener*);
+ // Factory that takes a type and return PlatformEventObserverBase that matches
+ // it.
+ static PlatformEventObserverBase* CreatePlatformEventObserverFromType(
+ blink::WebPlatformEventType type);
+ // Use the data previously set via SetMockDevice...DataForTesting() and send
+ // them to the registered listener.
+ void SendFakeDeviceEventDataForTesting(blink::WebPlatformEventType type);
scoped_ptr<RendererClipboardClient> clipboard_client_;
scoped_ptr<WebClipboardImpl> clipboard_;
@@ -233,7 +237,7 @@ class CONTENT_EXPORT RendererWebKitPlatformSupportImpl
scoped_ptr<BatteryStatusDispatcher> battery_status_dispatcher_;
- RendererGamepadProvider* gamepad_provider_;
+ IDMap<PlatformEventObserverBase, IDMapOwnPointer> platform_event_observers_;
DISALLOW_COPY_AND_ASSIGN(RendererWebKitPlatformSupportImpl);
};

Powered by Google App Engine
This is Rietveld 408576698