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

Unified Diff: content/renderer/device_sensors/device_motion_event_pump.cc

Issue 470683002: Revert "Refactor code listening to platform events in content/renderer/." (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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/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 aca6df5c005b0965c1e60aa7cd026c59bfa3b2aa..0143d1942cca38f2033a20b46d40d5d2d9696b5b 100644
--- a/content/renderer/device_sensors/device_motion_event_pump.cc
+++ b/content/renderer/device_sensors/device_motion_event_pump.cc
@@ -10,13 +10,23 @@
namespace content {
-DeviceMotionEventPump::DeviceMotionEventPump(RenderThread* thread)
- : DeviceSensorEventPump<blink::WebDeviceMotionListener>(thread) {
+DeviceMotionEventPump::DeviceMotionEventPump()
+ : DeviceSensorEventPump(), listener_(0) {
+}
+
+DeviceMotionEventPump::DeviceMotionEventPump(int pump_delay_millis)
+ : DeviceSensorEventPump(pump_delay_millis), listener_(0) {
}
DeviceMotionEventPump::~DeviceMotionEventPump() {
}
+bool DeviceMotionEventPump::SetListener(
+ blink::WebDeviceMotionListener* listener) {
+ listener_ = listener;
+ return listener_ ? RequestStart() : Stop();
+}
+
bool DeviceMotionEventPump::OnControlMessageReceived(
const IPC::Message& message) {
bool handled = true;
@@ -28,10 +38,10 @@ bool DeviceMotionEventPump::OnControlMessageReceived(
}
void DeviceMotionEventPump::FireEvent() {
- DCHECK(listener());
+ DCHECK(listener_);
blink::WebDeviceMotionData data;
if (reader_->GetLatestData(&data) && data.allAvailableSensorsAreActive)
- listener()->didChangeDeviceMotion(data);
+ listener_->didChangeDeviceMotion(data);
}
bool DeviceMotionEventPump::InitializeReader(base::SharedMemoryHandle handle) {
@@ -40,19 +50,13 @@ 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());
+bool DeviceMotionEventPump::SendStartMessage() {
+ return RenderThread::Get()->Send(new DeviceMotionHostMsg_StartPolling());
}
-void DeviceMotionEventPump::SendFakeDataForTesting(void* fake_data) {
- blink::WebDeviceMotionData data =
- *static_cast<blink::WebDeviceMotionData*>(fake_data);
- listener()->didChangeDeviceMotion(data);
+bool DeviceMotionEventPump::SendStopMessage() {
+ return RenderThread::Get()->Send(new DeviceMotionHostMsg_StopPolling());
}
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698