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

Unified Diff: content/renderer/device_sensors/device_light_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_light_event_pump.cc
diff --git a/content/renderer/device_sensors/device_light_event_pump.cc b/content/renderer/device_sensors/device_light_event_pump.cc
index a20919d968d9f3637afe8fb3e1435255d98890ce..31b0970d60bfbfe410f41e4df4cd2c9a6d89382c 100644
--- a/content/renderer/device_sensors/device_light_event_pump.cc
+++ b/content/renderer/device_sensors/device_light_event_pump.cc
@@ -15,32 +15,44 @@ const int kDefaultLightPumpDelayMillis = 200;
namespace content {
-DeviceLightEventPump::DeviceLightEventPump(RenderThread* thread)
- : DeviceSensorEventPump<blink::WebDeviceLightListener>(thread),
+DeviceLightEventPump::DeviceLightEventPump()
+ : DeviceSensorEventPump(kDefaultLightPumpDelayMillis),
+ listener_(NULL),
+ last_seen_data_(-1) {
+}
+
+DeviceLightEventPump::DeviceLightEventPump(int pump_delay_millis)
+ : DeviceSensorEventPump(pump_delay_millis),
+ listener_(NULL),
last_seen_data_(-1) {
- pump_delay_millis_ = kDefaultLightPumpDelayMillis;
}
DeviceLightEventPump::~DeviceLightEventPump() {
}
+bool DeviceLightEventPump::SetListener(
+ blink::WebDeviceLightListener* listener) {
+ listener_ = listener;
+ return listener_ ? RequestStart() : Stop();
+}
+
bool DeviceLightEventPump::OnControlMessageReceived(
const IPC::Message& message) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(DeviceLightEventPump, message)
- IPC_MESSAGE_HANDLER(DeviceLightMsg_DidStartPolling, OnDidStart)
- IPC_MESSAGE_UNHANDLED(handled = false)
+ IPC_MESSAGE_HANDLER(DeviceLightMsg_DidStartPolling, OnDidStart)
+ IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
return handled;
}
void DeviceLightEventPump::FireEvent() {
- DCHECK(listener());
+ DCHECK(listener_);
DeviceLightData data;
bool did_return_light_data = reader_->GetLatestData(&data);
if (did_return_light_data && data.value != last_seen_data_) {
last_seen_data_ = data.value;
- listener()->didChangeDeviceLight(data.value);
+ listener_->didChangeDeviceLight(data.value);
}
}
@@ -50,19 +62,13 @@ bool DeviceLightEventPump::InitializeReader(base::SharedMemoryHandle handle) {
return reader_->Initialize(handle);
}
-void DeviceLightEventPump::SendStartMessage() {
- RenderThread::Get()->Send(new DeviceLightHostMsg_StartPolling());
+bool DeviceLightEventPump::SendStartMessage() {
+ return RenderThread::Get()->Send(new DeviceLightHostMsg_StartPolling());
}
-void DeviceLightEventPump::SendStopMessage() {
+bool DeviceLightEventPump::SendStopMessage() {
last_seen_data_ = -1;
- RenderThread::Get()->Send(new DeviceLightHostMsg_StopPolling());
-}
-
-void DeviceLightEventPump::SendFakeDataForTesting(void* fake_data) {
- double data = *static_cast<double*>(fake_data);
-
- listener()->didChangeDeviceLight(data);
+ return RenderThread::Get()->Send(new DeviceLightHostMsg_StopPolling());
}
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698