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

Unified Diff: content/renderer/device_sensors/device_orientation_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_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 ec159b08ead138bdeb33d646ebd28b5e85eb2d1a..deea13632f83dd1f3a447c79d0bb58e1fe18f5a1 100644
--- a/content/renderer/device_sensors/device_orientation_event_pump.cc
+++ b/content/renderer/device_sensors/device_orientation_event_pump.cc
@@ -14,23 +14,13 @@ namespace content {
const double DeviceOrientationEventPump::kOrientationThreshold = 0.1;
-DeviceOrientationEventPump::DeviceOrientationEventPump()
- : DeviceSensorEventPump(), listener_(0) {
-}
-
-DeviceOrientationEventPump::DeviceOrientationEventPump(int pump_delay_millis)
- : DeviceSensorEventPump(pump_delay_millis), listener_(0) {
+DeviceOrientationEventPump::DeviceOrientationEventPump(RenderThread* thread)
+ : DeviceSensorEventPump<blink::WebDeviceOrientationListener>(thread) {
}
DeviceOrientationEventPump::~DeviceOrientationEventPump() {
}
-bool DeviceOrientationEventPump::SetListener(
- blink::WebDeviceOrientationListener* listener) {
- listener_ = listener;
- return listener_ ? RequestStart() : Stop();
-}
-
bool DeviceOrientationEventPump::OnControlMessageReceived(
const IPC::Message& message) {
bool handled = true;
@@ -42,11 +32,11 @@ bool DeviceOrientationEventPump::OnControlMessageReceived(
}
void DeviceOrientationEventPump::FireEvent() {
- DCHECK(listener_);
+ DCHECK(listener());
blink::WebDeviceOrientationData data;
if (reader_->GetLatestData(&data) && ShouldFireEvent(data)) {
memcpy(&data_, &data, sizeof(data));
- listener_->didChangeDeviceOrientation(data);
+ listener()->didChangeDeviceOrientation(data);
}
}
@@ -84,12 +74,19 @@ bool DeviceOrientationEventPump::InitializeReader(
return reader_->Initialize(handle);
}
-bool DeviceOrientationEventPump::SendStartMessage() {
- return RenderThread::Get()->Send(new DeviceOrientationHostMsg_StartPolling());
+void DeviceOrientationEventPump::SendStartMessage() {
+ RenderThread::Get()->Send(new DeviceOrientationHostMsg_StartPolling());
}
-bool DeviceOrientationEventPump::SendStopMessage() {
- return RenderThread::Get()->Send(new DeviceOrientationHostMsg_StopPolling());
+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);
}
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698