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

Unified Diff: content/renderer/device_sensors/device_motion_event_pump.h

Issue 2953263002: Revert of Reland: Refactor DeviceMotionEventPump to use //device/generic_sensor instead of //device/sensors (Closed)
Patch Set: Created 3 years, 6 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
« no previous file with comments | « content/renderer/DEPS ('k') | content/renderer/device_sensors/device_motion_event_pump.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/device_sensors/device_motion_event_pump.h
diff --git a/content/renderer/device_sensors/device_motion_event_pump.h b/content/renderer/device_sensors/device_motion_event_pump.h
index 5089aff19a6fe1d4a5d2ef9dd2b4ea72c9ceb0e3..5846db199bb8a2e123874350752b4ee685c91cbc 100644
--- a/content/renderer/device_sensors/device_motion_event_pump.h
+++ b/content/renderer/device_sensors/device_motion_event_pump.h
@@ -6,105 +6,38 @@
#define CONTENT_RENDERER_DEVICE_SENSORS_DEVICE_MOTION_EVENT_PUMP_H_
#include <memory>
-#include <utility>
-#include <vector>
-#include "base/bind.h"
-#include "base/bind_helpers.h"
#include "base/macros.h"
-#include "base/time/time.h"
-#include "base/timer/timer.h"
-#include "content/public/renderer/platform_event_observer.h"
-#include "content/renderer/render_thread_impl.h"
-#include "device/generic_sensor/public/cpp/sensor_reading.h"
-#include "device/generic_sensor/public/interfaces/sensor.mojom.h"
-#include "device/generic_sensor/public/interfaces/sensor_provider.mojom.h"
+#include "content/renderer/device_sensors/device_sensor_event_pump.h"
+#include "content/renderer/shared_memory_seqlock_reader.h"
#include "device/sensors/public/cpp/motion_data.h"
-#include "mojo/public/cpp/bindings/binding.h"
-#include "third_party/WebKit/public/platform/modules/device_orientation/WebDeviceMotionListener.h"
+#include "device/sensors/public/interfaces/motion.mojom.h"
+
+namespace blink {
+class WebDeviceMotionListener;
+}
namespace content {
+typedef SharedMemorySeqLockReader<device::MotionData>
+ DeviceMotionSharedMemoryReader;
+
class CONTENT_EXPORT DeviceMotionEventPump
- : NON_EXPORTED_BASE(
- public PlatformEventObserver<blink::WebDeviceMotionListener>) {
+ : public DeviceSensorMojoClientMixin<
+ DeviceSensorEventPump<blink::WebDeviceMotionListener>,
+ device::mojom::MotionSensor> {
public:
explicit DeviceMotionEventPump(RenderThread* thread);
~DeviceMotionEventPump() override;
- // PlatformEventObserver:
- void Start(blink::WebPlatformEventListener* listener) override;
- void Stop() override;
- void SendStartMessage() override;
- void SendStopMessage() override;
+ // PlatformEventObserver.
void SendFakeDataForTesting(void* fake_data) override;
protected:
- // Default rate for firing events.
- static constexpr int kDefaultPumpFrequencyHz = 60;
- static constexpr int kDefaultPumpDelayMicroseconds =
- base::Time::kMicrosecondsPerSecond / kDefaultPumpFrequencyHz;
+ void FireEvent() override;
+ bool InitializeReader(base::SharedMemoryHandle handle) override;
- struct CONTENT_EXPORT SensorEntry : public device::mojom::SensorClient {
- SensorEntry(DeviceMotionEventPump* pump,
- device::mojom::SensorType sensor_type);
- ~SensorEntry() override;
-
- // device::mojom::SensorClient:
- void RaiseError() override;
- void SensorReadingChanged() override;
-
- // Mojo callback for SensorProvider::GetSensor().
- void OnSensorCreated(device::mojom::SensorInitParamsPtr params,
- device::mojom::SensorClientRequest client_request);
-
- // Mojo callback for Sensor::AddConfiguration().
- void OnSensorAddConfiguration(bool success);
-
- void HandleSensorError();
-
- bool SensorReadingCouldBeRead();
-
- DeviceMotionEventPump* event_pump;
- device::mojom::SensorPtr sensor;
- device::mojom::SensorType type;
- device::mojom::ReportingMode mode;
- device::PlatformSensorConfiguration default_config;
- mojo::ScopedSharedBufferHandle shared_buffer_handle;
- mojo::ScopedSharedBufferMapping shared_buffer;
- device::SensorReading reading;
- mojo::Binding<device::mojom::SensorClient> client_binding;
- };
-
- friend struct SensorEntry;
-
- virtual void FireEvent();
-
- void DidStart();
-
- SensorEntry accelerometer_;
- SensorEntry linear_acceleration_sensor_;
- SensorEntry gyroscope_;
-
- private:
- // TODO(juncai): refactor DeviceMotionEventPump to use DeviceSensorEventPump
- // when refactoring DeviceOrientation.
- //
- // The pump is a tri-state automaton with allowed transitions as follows:
- // STOPPED -> PENDING_START
- // PENDING_START -> RUNNING
- // PENDING_START -> STOPPED
- // RUNNING -> STOPPED
- enum class PumpState { STOPPED, RUNNING, PENDING_START };
-
- bool CanStart() const;
- void GetDataFromSharedMemory(device::MotionData* data);
- void GetSensor(SensorEntry* sensor_entry);
- void HandleSensorProviderError();
-
- mojo::InterfacePtr<device::mojom::SensorProvider> sensor_provider_;
- PumpState state_;
- base::RepeatingTimer timer_;
+ std::unique_ptr<DeviceMotionSharedMemoryReader> reader_;
DISALLOW_COPY_AND_ASSIGN(DeviceMotionEventPump);
};
« no previous file with comments | « content/renderer/DEPS ('k') | content/renderer/device_sensors/device_motion_event_pump.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698