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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_RENDERER_RENDERER_WEBKITPLATFORMSUPPORT_IMPL_H_ 5 #ifndef CONTENT_RENDERER_RENDERER_WEBKITPLATFORMSUPPORT_IMPL_H_
6 #define CONTENT_RENDERER_RENDERER_WEBKITPLATFORMSUPPORT_IMPL_H_ 6 #define CONTENT_RENDERER_RENDERER_WEBKITPLATFORMSUPPORT_IMPL_H_
7 7
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/id_map.h"
9 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
10 #include "content/child/blink_platform_impl.h" 11 #include "content/child/blink_platform_impl.h"
11 #include "content/common/content_export.h" 12 #include "content/common/content_export.h"
12 #include "content/renderer/compositor_bindings/web_compositor_support_impl.h" 13 #include "content/renderer/compositor_bindings/web_compositor_support_impl.h"
13 #include "content/renderer/webpublicsuffixlist_impl.h" 14 #include "content/renderer/webpublicsuffixlist_impl.h"
14 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h" 15 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h"
15 #include "third_party/WebKit/public/platform/WebIDBFactory.h" 16 #include "third_party/WebKit/public/platform/WebIDBFactory.h"
16 #include "third_party/WebKit/public/platform/WebScreenOrientationType.h" 17 #include "third_party/WebKit/public/platform/WebScreenOrientationType.h"
17 18
18 namespace base { 19 namespace base {
(...skipping 13 matching lines...) Expand all
32 class WebDeviceMotionData; 33 class WebDeviceMotionData;
33 class WebDeviceOrientationData; 34 class WebDeviceOrientationData;
34 class WebGraphicsContext3DProvider; 35 class WebGraphicsContext3DProvider;
35 } 36 }
36 37
37 namespace content { 38 namespace content {
38 class BatteryStatusDispatcher; 39 class BatteryStatusDispatcher;
39 class DeviceLightEventPump; 40 class DeviceLightEventPump;
40 class DeviceMotionEventPump; 41 class DeviceMotionEventPump;
41 class DeviceOrientationEventPump; 42 class DeviceOrientationEventPump;
43 class PlatformEventObserverBase;
42 class QuotaMessageFilter; 44 class QuotaMessageFilter;
43 class RendererClipboardClient; 45 class RendererClipboardClient;
44 class RenderView; 46 class RenderView;
45 class RendererGamepadProvider;
46 class ThreadSafeSender; 47 class ThreadSafeSender;
47 class WebClipboardImpl; 48 class WebClipboardImpl;
48 class WebDatabaseObserverImpl; 49 class WebDatabaseObserverImpl;
49 class WebFileSystemImpl; 50 class WebFileSystemImpl;
50 51
51 class CONTENT_EXPORT RendererWebKitPlatformSupportImpl 52 class CONTENT_EXPORT RendererWebKitPlatformSupportImpl
52 : public BlinkPlatformImpl { 53 : public BlinkPlatformImpl {
53 public: 54 public:
54 RendererWebKitPlatformSupportImpl(); 55 RendererWebKitPlatformSupportImpl();
55 virtual ~RendererWebKitPlatformSupportImpl(); 56 virtual ~RendererWebKitPlatformSupportImpl();
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 virtual void startListening(blink::WebPlatformEventType, 140 virtual void startListening(blink::WebPlatformEventType,
140 blink::WebPlatformEventListener*); 141 blink::WebPlatformEventListener*);
141 virtual void stopListening(blink::WebPlatformEventType); 142 virtual void stopListening(blink::WebPlatformEventType);
142 virtual void queryStorageUsageAndQuota( 143 virtual void queryStorageUsageAndQuota(
143 const blink::WebURL& storage_partition, 144 const blink::WebURL& storage_partition,
144 blink::WebStorageQuotaType, 145 blink::WebStorageQuotaType,
145 blink::WebStorageQuotaCallbacks); 146 blink::WebStorageQuotaCallbacks);
146 virtual void vibrate(unsigned int milliseconds); 147 virtual void vibrate(unsigned int milliseconds);
147 virtual void cancelVibration(); 148 virtual void cancelVibration();
148 149
149 void set_gamepad_provider(RendererGamepadProvider* provider) { 150 // Set the PlatformEventObserverBase in |platform_event_observers_| associated
150 gamepad_provider_ = provider; 151 // with |type| to |observer|. If there was already an observer associated to
151 } 152 // 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.
153 // 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.
154 void SetPlatformEventObserverForTesting(blink::WebPlatformEventType type,
155 PlatformEventObserverBase* observer);
152 156
153 // Disables the WebSandboxSupport implementation for testing. 157 // Disables the WebSandboxSupport implementation for testing.
154 // Tests that do not set up a full sandbox environment should call 158 // Tests that do not set up a full sandbox environment should call
155 // SetSandboxEnabledForTesting(false) _before_ creating any instances 159 // SetSandboxEnabledForTesting(false) _before_ creating any instances
156 // of this class, to ensure that we don't attempt to use sandbox-related 160 // of this class, to ensure that we don't attempt to use sandbox-related
157 // file descriptors or other resources. 161 // file descriptors or other resources.
158 // 162 //
159 // Returns the previous |enable| value. 163 // Returns the previous |enable| value.
160 static bool SetSandboxEnabledForTesting(bool enable); 164 static bool SetSandboxEnabledForTesting(bool enable);
161 165
162 // Set a double to return when setDeviceLightListener is invoked. 166 // Set a double to return when setDeviceLightListener is invoked.
163 static void SetMockDeviceLightDataForTesting(double data); 167 static void SetMockDeviceLightDataForTesting(double data);
164 // Set WebDeviceMotionData to return when setDeviceMotionListener is invoked. 168 // Set WebDeviceMotionData to return when setDeviceMotionListener is invoked.
165 static void SetMockDeviceMotionDataForTesting( 169 static void SetMockDeviceMotionDataForTesting(
166 const blink::WebDeviceMotionData& data); 170 const blink::WebDeviceMotionData& data);
167 // Set WebDeviceOrientationData to return when setDeviceOrientationListener 171 // Set WebDeviceOrientationData to return when setDeviceOrientationListener
168 // is invoked. 172 // is invoked.
169 static void SetMockDeviceOrientationDataForTesting( 173 static void SetMockDeviceOrientationDataForTesting(
170 const blink::WebDeviceOrientationData& data); 174 const blink::WebDeviceOrientationData& data);
171 175
172 // Notifies blink::WebBatteryStatusListener that battery status has changed. 176 // Notifies blink::WebBatteryStatusListener that battery status has changed.
173 static void MockBatteryStatusChangedForTesting( 177 void MockBatteryStatusChangedForTesting(
174 const blink::WebBatteryStatus& status); 178 const blink::WebBatteryStatus& status);
175 179
176 WebDatabaseObserverImpl* web_database_observer_impl() { 180 WebDatabaseObserverImpl* web_database_observer_impl() {
177 return web_database_observer_impl_.get(); 181 return web_database_observer_impl_.get();
178 } 182 }
179 183
180 private: 184 private:
181 bool CheckPreparsedJsCachingEnabled() const; 185 bool CheckPreparsedJsCachingEnabled() const;
182 186
183 // Implement those methods internally so startListening() and stopListening() 187 // Factory that takes a type and return PlatformEventObserverBase that matches
184 // are being used and Blink can change its interface. 188 // it.
185 void SetDeviceMotionListener(blink::WebDeviceMotionListener*); 189 static PlatformEventObserverBase* CreatePlatformEventObserverFromType(
186 void SetDeviceOrientationListener(blink::WebDeviceOrientationListener*); 190 blink::WebPlatformEventType type);
187 void SetDeviceLightListener(blink::WebDeviceLightListener*);
188 void SetBatteryStatusListener(blink::WebBatteryStatusListener*);
189 void SetGamepadListener(blink::WebGamepadListener*);
190 191
192 // Use the data previously set via SetMockDevice...DataForTesting() and send
193 // them to the registered listener.
194 void SendFakeDeviceEventDataForTesting(blink::WebPlatformEventType type);
191 195
192 scoped_ptr<RendererClipboardClient> clipboard_client_; 196 scoped_ptr<RendererClipboardClient> clipboard_client_;
193 scoped_ptr<WebClipboardImpl> clipboard_; 197 scoped_ptr<WebClipboardImpl> clipboard_;
194 198
195 class FileUtilities; 199 class FileUtilities;
196 scoped_ptr<FileUtilities> file_utilities_; 200 scoped_ptr<FileUtilities> file_utilities_;
197 201
198 class MimeRegistry; 202 class MimeRegistry;
199 scoped_ptr<MimeRegistry> mime_registry_; 203 scoped_ptr<MimeRegistry> mime_registry_;
200 204
(...skipping 25 matching lines...) Expand all
226 scoped_refptr<QuotaMessageFilter> quota_message_filter_; 230 scoped_refptr<QuotaMessageFilter> quota_message_filter_;
227 231
228 scoped_ptr<WebDatabaseObserverImpl> web_database_observer_impl_; 232 scoped_ptr<WebDatabaseObserverImpl> web_database_observer_impl_;
229 233
230 WebCompositorSupportImpl compositor_support_; 234 WebCompositorSupportImpl compositor_support_;
231 235
232 scoped_ptr<blink::WebScrollbarBehavior> web_scrollbar_behavior_; 236 scoped_ptr<blink::WebScrollbarBehavior> web_scrollbar_behavior_;
233 237
234 scoped_ptr<BatteryStatusDispatcher> battery_status_dispatcher_; 238 scoped_ptr<BatteryStatusDispatcher> battery_status_dispatcher_;
235 239
236 RendererGamepadProvider* gamepad_provider_; 240 IDMap<PlatformEventObserverBase, IDMapOwnPointer> platform_event_observers_;
237 241
238 DISALLOW_COPY_AND_ASSIGN(RendererWebKitPlatformSupportImpl); 242 DISALLOW_COPY_AND_ASSIGN(RendererWebKitPlatformSupportImpl);
239 }; 243 };
240 244
241 } // namespace content 245 } // namespace content
242 246
243 #endif // CONTENT_RENDERER_RENDERER_WEBKITPLATFORMSUPPORT_IMPL_H_ 247 #endif // CONTENT_RENDERER_RENDERER_WEBKITPLATFORMSUPPORT_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698