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

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

Powered by Google App Engine
This is Rietveld 408576698