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

Unified Diff: content/renderer/device_orientation/device_orientation_event_pump.h

Issue 20707002: Implement Device Orientation using shared memory in content/renderer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: excluded orientation pump tests on win bots Created 7 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_orientation/device_orientation_event_pump.h
diff --git a/content/renderer/device_orientation/device_orientation_event_pump.h b/content/renderer/device_orientation/device_orientation_event_pump.h
new file mode 100644
index 0000000000000000000000000000000000000000..26658ff5d4d6aab35f721d067535be7ba358f289
--- /dev/null
+++ b/content/renderer/device_orientation/device_orientation_event_pump.h
@@ -0,0 +1,54 @@
+// Copyright 2013 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.
+
+#ifndef CONTENT_RENDERER_DEVICE_ORIENTATION_EVENT_PUMP_H_
+#define CONTENT_RENDERER_DEVICE_ORIENTATION_EVENT_PUMP_H_
+
+#include "base/memory/scoped_ptr.h"
+#include "content/renderer/device_orientation/device_sensor_event_pump.h"
+#include "content/renderer/shared_memory_seqlock_reader.h"
+#include "third_party/WebKit/public/platform/WebDeviceOrientationData.h"
+
+namespace WebKit {
+class WebDeviceOrientationListener;
+}
+
+namespace content {
+
+typedef SharedMemorySeqLockReader<WebKit::WebDeviceOrientationData>
+ DeviceOrientationSharedMemoryReader;
+
+class CONTENT_EXPORT DeviceOrientationEventPump : public DeviceSensorEventPump {
+ public:
+ // Angle threshold beyond which two orientation events are considered
+ // sufficiently different.
+ static const double kOrientationThreshold;
+
+ DeviceOrientationEventPump();
+ explicit DeviceOrientationEventPump(int pump_delay_millis);
+ virtual ~DeviceOrientationEventPump();
+
+ // Sets the listener to receive updates for device orientation data at
+ // regular intervals. Returns true if the registration was successful.
+ bool SetListener(WebKit::WebDeviceOrientationListener* listener);
+
+ // RenderProcessObserver implementation.
+ virtual bool OnControlMessageReceived(const IPC::Message& message) OVERRIDE;
+
+ protected:
+ virtual void FireEvent() OVERRIDE;
+ virtual bool InitializeReader(base::SharedMemoryHandle handle) OVERRIDE;
+ virtual bool SendStartMessage() OVERRIDE;
+ virtual bool SendStopMessage() OVERRIDE;
+
+ bool ShouldFireEvent(const WebKit::WebDeviceOrientationData& data) const;
+
+ WebKit::WebDeviceOrientationListener* listener_;
+ WebKit::WebDeviceOrientationData data_;
+ scoped_ptr<DeviceOrientationSharedMemoryReader> reader_;
+};
+
+} // namespace content
+
+#endif // CONTENT_RENDERER_DEVICE_ORIENTATION_EVENT_PUMP_H_

Powered by Google App Engine
This is Rietveld 408576698