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

Unified Diff: content/renderer/renderer_webkitplatformsupport_impl.cc

Issue 457933002: Replace Chrome IPC with Mojo IPC for querying BatteryStatus service Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 3 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.cc
diff --git a/content/renderer/renderer_webkitplatformsupport_impl.cc b/content/renderer/renderer_webkitplatformsupport_impl.cc
index 850166d7663cb5613989f4815c289979a8a2334f..c0c929d400eab3680d04b62113e1954c3e842b57 100644
--- a/content/renderer/renderer_webkitplatformsupport_impl.cc
+++ b/content/renderer/renderer_webkitplatformsupport_impl.cc
@@ -1056,39 +1056,34 @@ RendererWebKitPlatformSupportImpl::CreatePlatformEventObserverFromType(
// hardware changes. In order to make that happen, they will receive a null
// thread.
if (thread && RenderThreadImpl::current()->layout_test_mode())
- thread = 0;
+ thread = NULL;
switch (type) {
- case blink::WebPlatformEventDeviceMotion: {
- return new DeviceMotionEventPump(thread);
- }
- case blink::WebPlatformEventDeviceOrientation: {
- return new DeviceOrientationEventPump(thread);
- }
- case blink::WebPlatformEventDeviceLight: {
- return new DeviceLightEventPump(thread);
- }
- case blink::WebPlatformEventBattery: {
- return new BatteryStatusDispatcher(thread);
- }
- case blink::WebPlatformEventGamepad:
- return new GamepadSharedMemoryReader(thread);
- break;
- case blink::WebPlatformEventScreenOrientation:
- return new ScreenOrientationObserver();
- default:
- // A default statement is required to prevent compilation errors when Blink
- // adds a new type.
- VLOG(1) << "RendererWebKitPlatformSupportImpl::startListening() with "
- "unknown type.";
+ case blink::WebPlatformEventDeviceMotion:
+ return new DeviceMotionEventPump(thread);
+ case blink::WebPlatformEventDeviceOrientation:
+ return new DeviceOrientationEventPump(thread);
+ case blink::WebPlatformEventDeviceLight:
+ return new DeviceLightEventPump(thread);
+ case blink::WebPlatformEventGamepad:
+ return new GamepadSharedMemoryReader(thread);
+ case blink::WebPlatformEventScreenOrientation:
+ return new ScreenOrientationObserver();
+ default:
+ // A default statement is required to prevent compilation errors when
+ // Blink adds a new type.
+ VLOG(1) << "RendererWebKitPlatformSupportImpl::startListening() with "
+ "unknown type.";
}
- return 0;
+ return NULL;
}
void RendererWebKitPlatformSupportImpl::SetPlatformEventObserverForTesting(
blink::WebPlatformEventType type,
scoped_ptr<PlatformEventObserverBase> observer) {
+ DCHECK(type != blink::WebPlatformEventBattery);
+
if (platform_event_observers_.Lookup(type))
platform_event_observers_.Remove(type);
platform_event_observers_.AddWithID(observer.release(), type);
@@ -1097,6 +1092,12 @@ void RendererWebKitPlatformSupportImpl::SetPlatformEventObserverForTesting(
void RendererWebKitPlatformSupportImpl::startListening(
blink::WebPlatformEventType type,
blink::WebPlatformEventListener* listener) {
+ if (type == blink::WebPlatformEventBattery) {
+ battery_status_dispatcher_.reset(new BatteryStatusDispatcher(
+ static_cast<blink::WebBatteryStatusListener*>(listener)));
+ return;
+ }
+
PlatformEventObserverBase* observer = platform_event_observers_.Lookup(type);
if (!observer) {
observer = CreatePlatformEventObserverFromType(type);
@@ -1155,6 +1156,11 @@ void RendererWebKitPlatformSupportImpl::SendFakeDeviceEventDataForTesting(
void RendererWebKitPlatformSupportImpl::stopListening(
blink::WebPlatformEventType type) {
+ if (type == blink::WebPlatformEventBattery) {
+ battery_status_dispatcher_.reset();
+ return;
+ }
+
PlatformEventObserverBase* observer = platform_event_observers_.Lookup(type);
if (!observer)
return;
« no previous file with comments | « content/renderer/battery_status/battery_status_dispatcher.cc ('k') | content/renderer/shared_memory_seqlock_reader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698