Index: content/renderer/device_sensors/device_motion_event_pump.cc |
diff --git a/content/renderer/device_sensors/device_motion_event_pump.cc b/content/renderer/device_sensors/device_motion_event_pump.cc |
index 860cf68e2f16fb18b13f6d794e047f229991d468..543a72548d5c4506440cced78dd600a1c2b65e57 100644 |
--- a/content/renderer/device_sensors/device_motion_event_pump.cc |
+++ b/content/renderer/device_sensors/device_motion_event_pump.cc |
@@ -4,34 +4,41 @@ |
#include "device_motion_event_pump.h" |
-#include "content/common/device_sensors/device_motion_messages.h" |
+#include "base/process/process_handle.h" |
+#include "content/public/common/service_registry.h" |
#include "content/public/renderer/render_thread.h" |
#include "third_party/WebKit/public/platform/modules/device_orientation/WebDeviceMotionListener.h" |
namespace content { |
-DeviceMotionEventPump::DeviceMotionEventPump(RenderThread* thread) |
- : DeviceSensorEventPump<blink::WebDeviceMotionListener>(thread) { |
-} |
+DeviceMotionEventPump::DeviceMotionEventPump( |
+ blink::WebDeviceMotionListener* listener) |
+ : listener_(listener) { |
+ DCHECK(listener_); |
-DeviceMotionEventPump::~DeviceMotionEventPump() { |
+ if (ServiceRegistry* registry = RenderThread::Get()->GetServiceRegistry()) { |
+ // registry can be null during testing. |
+ registry->ConnectToRemoteService(&service_); |
+ service_->StartPolling( |
+ static_cast<int32>(base::GetCurrentProcId()), |
+ base::Bind(&DeviceMotionEventPump::OnDidStart, base::Unretained(this))); |
+ } |
} |
-bool DeviceMotionEventPump::OnControlMessageReceived( |
- const IPC::Message& message) { |
- bool handled = true; |
- IPC_BEGIN_MESSAGE_MAP(DeviceMotionEventPump, message) |
- IPC_MESSAGE_HANDLER(DeviceMotionMsg_DidStartPolling, OnDidStart) |
- IPC_MESSAGE_UNHANDLED(handled = false) |
- IPC_END_MESSAGE_MAP() |
- return handled; |
+DeviceMotionEventPump::~DeviceMotionEventPump() { |
} |
void DeviceMotionEventPump::FireEvent() { |
- DCHECK(listener()); |
+ LOG(WARNING) << "DeviceMotionEventPump::FireEvent"; |
+ DCHECK(listener_); |
blink::WebDeviceMotionData data; |
- if (reader_->GetLatestData(&data) && data.allAvailableSensorsAreActive) |
- listener()->didChangeDeviceMotion(data); |
+ if (reader_->GetLatestData(&data)) { |
+ LOG(WARNING) << "DeviceMotionEventPump::FireEvent, " |
+ "data.allAvailableSensorsAreActive: " |
+ << data.allAvailableSensorsAreActive; |
+ if (data.allAvailableSensorsAreActive) |
+ listener_->didChangeDeviceMotion(data); |
+ } |
} |
bool DeviceMotionEventPump::InitializeReader(base::SharedMemoryHandle handle) { |
@@ -40,19 +47,11 @@ bool DeviceMotionEventPump::InitializeReader(base::SharedMemoryHandle handle) { |
return reader_->Initialize(handle); |
} |
-void DeviceMotionEventPump::SendStartMessage() { |
- RenderThread::Get()->Send(new DeviceMotionHostMsg_StartPolling()); |
-} |
- |
-void DeviceMotionEventPump::SendStopMessage() { |
- RenderThread::Get()->Send(new DeviceMotionHostMsg_StopPolling()); |
-} |
- |
void DeviceMotionEventPump::SendFakeDataForTesting(void* fake_data) { |
blink::WebDeviceMotionData data = |
*static_cast<blink::WebDeviceMotionData*>(fake_data); |
- listener()->didChangeDeviceMotion(data); |
+ listener_->didChangeDeviceMotion(data); |
} |
} // namespace content |