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

Unified Diff: content/renderer/device_orientation/device_sensor_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_sensor_event_pump.h
diff --git a/content/renderer/device_orientation/device_sensor_event_pump.h b/content/renderer/device_orientation/device_sensor_event_pump.h
new file mode 100644
index 0000000000000000000000000000000000000000..8f0e37e80c3f45429bb62e39fb9be6c65fed7a37
--- /dev/null
+++ b/content/renderer/device_orientation/device_sensor_event_pump.h
@@ -0,0 +1,60 @@
+// 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_SENSOR_EVENT_PUMP_H_
+#define CONTENT_RENDERER_DEVICE_SENSOR_EVENT_PUMP_H_
+
+#include "base/memory/shared_memory.h"
+#include "base/timer/timer.h"
+#include "content/public/renderer/render_process_observer.h"
+
+namespace content {
+class RenderThread;
+
+class CONTENT_EXPORT DeviceSensorEventPump : public RenderProcessObserver {
+ public:
+ // Default delay between subsequent firing of events.
+ static const int kDefaultPumpDelayMillis;
+
+ int GetDelayMillis() const;
+
+ void Attach(RenderThread* thread);
+ virtual bool OnControlMessageReceived(const IPC::Message& message) = 0;
+
+ protected:
+ // Constructor for a pump with default delay.
+ DeviceSensorEventPump();
+
+ // Constructor for a pump with a given delay.
+ explicit DeviceSensorEventPump(int pump_delay_millis);
+ virtual ~DeviceSensorEventPump();
+
+ // The pump is a tri-state automaton with allowed transitions as follows:
+ // STOPPED -> PENDING_START
+ // PENDING_START -> RUNNING
+ // PENDING_START -> STOPPED
+ // RUNNING -> STOPPED
+ enum PumpState {
+ STOPPED,
+ RUNNING,
+ PENDING_START
+ };
+
+ bool RequestStart();
+ void OnDidStart(base::SharedMemoryHandle handle);
+ bool Stop();
+
+ virtual void FireEvent() = 0;
+ virtual bool InitializeReader(base::SharedMemoryHandle handle) = 0;
+ virtual bool SendStartMessage() = 0;
+ virtual bool SendStopMessage() = 0;
+
+ int pump_delay_millis_;
+ PumpState state_;
+ base::RepeatingTimer<DeviceSensorEventPump> timer_;
+};
+
+} // namespace content
+
+#endif // CONTENT_RENDERER_DEVICE_SENSOR_EVENT_PUMP_H_

Powered by Google App Engine
This is Rietveld 408576698