Index: content/renderer/device_sensors/device_orientation_event_pump.cc |
diff --git a/content/renderer/device_sensors/device_orientation_event_pump.cc b/content/renderer/device_sensors/device_orientation_event_pump.cc |
index 093841b069f92e1d3529899200f333e4e00aad7d..186adc14af5c06efdbbae461edc189adb2020a02 100644 |
--- a/content/renderer/device_sensors/device_orientation_event_pump.cc |
+++ b/content/renderer/device_sensors/device_orientation_event_pump.cc |
@@ -6,7 +6,9 @@ |
#include <cmath> |
-#include "content/common/device_sensors/device_orientation_messages.h" |
+#include "base/logging.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/WebDeviceOrientationListener.h" |
@@ -14,29 +16,31 @@ namespace content { |
const double DeviceOrientationEventPump::kOrientationThreshold = 0.1; |
-DeviceOrientationEventPump::DeviceOrientationEventPump(RenderThread* thread) |
- : DeviceSensorEventPump<blink::WebDeviceOrientationListener>(thread) { |
+DeviceOrientationEventPump::DeviceOrientationEventPump( |
+ blink::WebDeviceOrientationListener* listener) |
+ : listener_(listener) { |
+ DCHECK(listener_); |
+ LOG(WARNING) << "DeviceOrientationEventPump::DeviceOrientationEventPump"; |
+ |
+ if (ServiceRegistry* registry = RenderThread::Get()->GetServiceRegistry()) { |
+ // registry can be null during testing. |
+ registry->ConnectToRemoteService(&service_); |
+ service_->StartPolling(static_cast<int32>(base::GetCurrentProcId()), |
+ base::Bind(&DeviceOrientationEventPump::OnDidStart, |
+ base::Unretained(this))); |
+ } |
} |
DeviceOrientationEventPump::~DeviceOrientationEventPump() { |
} |
-bool DeviceOrientationEventPump::OnControlMessageReceived( |
- const IPC::Message& message) { |
- bool handled = true; |
- IPC_BEGIN_MESSAGE_MAP(DeviceOrientationEventPump, message) |
- IPC_MESSAGE_HANDLER(DeviceOrientationMsg_DidStartPolling, OnDidStart) |
- IPC_MESSAGE_UNHANDLED(handled = false) |
- IPC_END_MESSAGE_MAP() |
- return handled; |
-} |
- |
void DeviceOrientationEventPump::FireEvent() { |
- DCHECK(listener()); |
+ DCHECK(listener_); |
+ LOG(WARNING) << "DeviceOrientationEventPump::FireEvent"; |
blink::WebDeviceOrientationData data; |
if (reader_->GetLatestData(&data) && ShouldFireEvent(data)) { |
memcpy(&data_, &data, sizeof(data)); |
- listener()->didChangeDeviceOrientation(data); |
+ listener_->didChangeDeviceOrientation(data); |
} |
} |
@@ -74,19 +78,11 @@ bool DeviceOrientationEventPump::InitializeReader( |
return reader_->Initialize(handle); |
} |
-void DeviceOrientationEventPump::SendStartMessage() { |
- RenderThread::Get()->Send(new DeviceOrientationHostMsg_StartPolling()); |
-} |
- |
-void DeviceOrientationEventPump::SendStopMessage() { |
- RenderThread::Get()->Send(new DeviceOrientationHostMsg_StopPolling()); |
-} |
- |
void DeviceOrientationEventPump::SendFakeDataForTesting(void* fake_data) { |
blink::WebDeviceOrientationData data = |
*static_cast<blink::WebDeviceOrientationData*>(fake_data); |
- listener()->didChangeDeviceOrientation(data); |
+ listener_->didChangeDeviceOrientation(data); |
} |
} // namespace content |