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

Unified Diff: content/renderer/device_light/device_light_event_pump.cc

Issue 152893002: [DeviceLight API] Content Side Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix in Java file, stop() Created 6 years, 9 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_light/device_light_event_pump.cc
diff --git a/content/renderer/device_light/device_light_event_pump.cc b/content/renderer/device_light/device_light_event_pump.cc
new file mode 100644
index 0000000000000000000000000000000000000000..610c3010d30424e73d192ca755557e1d444351dd
--- /dev/null
+++ b/content/renderer/device_light/device_light_event_pump.cc
@@ -0,0 +1,62 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/renderer/device_light/device_light_event_pump.h"
+
+#include "content/common/device_light/device_light_messages.h"
+#include "content/public/renderer/render_thread.h"
+#include "third_party/WebKit/public/platform/WebDeviceLightListener.h"
+
+namespace content {
+
+DeviceLightEventPump::DeviceLightEventPump()
+ : DeviceSensorEventPump(), listener_(0) {
+}
+
+DeviceLightEventPump::DeviceLightEventPump(int pump_delay_millis)
+ : DeviceSensorEventPump(pump_delay_millis), listener_(0) {
+}
+
+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_END_MESSAGE_MAP()
+ return handled;
+}
+
+void DeviceLightEventPump::FireEvent() {
+ DCHECK(listener_);
+ double data;
+ if (reader_->GetLatestData(&data))
+ listener_->didChangeDeviceLight(data);
+}
+
+bool DeviceLightEventPump::InitializeReader(base::SharedMemoryHandle handle) {
+ if (!reader_)
+ reader_.reset(new DeviceLightSharedMemoryReader());
+ return reader_->Initialize(handle);
+}
+
+bool DeviceLightEventPump::SendStartMessage() {
+ return RenderThread::Get()->Send(new DeviceLightHostMsg_StartPolling());
+}
+
+
+bool DeviceLightEventPump::SendStopMessage() {
+ return RenderThread::Get()->Send(new DeviceLightHostMsg_StopPolling());
+}
+
+} // namespace content
« no previous file with comments | « content/renderer/device_light/device_light_event_pump.h ('k') | content/renderer/renderer_webkitplatformsupport_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698