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

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

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: rebase 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 0143d1942cca38f2033a20b46d40d5d2d9696b5b..aca6df5c005b0965c1e60aa7cd026c59bfa3b2aa 100644
--- a/content/renderer/device_sensors/device_motion_event_pump.cc
+++ b/content/renderer/device_sensors/device_motion_event_pump.cc
@@ -10,23 +10,13 @@
namespace content {
-DeviceMotionEventPump::DeviceMotionEventPump()
- : DeviceSensorEventPump(), listener_(0) {
-}
-
-DeviceMotionEventPump::DeviceMotionEventPump(int pump_delay_millis)
- : DeviceSensorEventPump(pump_delay_millis), listener_(0) {
+DeviceMotionEventPump::DeviceMotionEventPump(RenderThread* thread)
+ : DeviceSensorEventPump<blink::WebDeviceMotionListener>(thread) {
}
DeviceMotionEventPump::~DeviceMotionEventPump() {
}
-bool DeviceMotionEventPump::SetListener(
- blink::WebDeviceMotionListener* listener) {
- listener_ = listener;
- return listener_ ? RequestStart() : Stop();
-}
-
bool DeviceMotionEventPump::OnControlMessageReceived(
const IPC::Message& message) {
bool handled = true;
@@ -38,10 +28,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) {
@@ -50,13 +40,19 @@ bool DeviceMotionEventPump::InitializeReader(base::SharedMemoryHandle handle) {
return reader_->Initialize(handle);
}
-bool DeviceMotionEventPump::SendStartMessage() {
- return RenderThread::Get()->Send(new DeviceMotionHostMsg_StartPolling());
+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);
-bool DeviceMotionEventPump::SendStopMessage() {
- return RenderThread::Get()->Send(new DeviceMotionHostMsg_StopPolling());
+ listener()->didChangeDeviceMotion(data);
}
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698