| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "device_motion_event_pump.h" | 5 #include "device_motion_event_pump.h" |
| 6 | 6 |
| 7 #include "content/public/renderer/render_thread.h" | 7 #include "content/public/renderer/render_thread.h" |
| 8 #include "third_party/WebKit/public/platform/modules/device_orientation/WebDevic
eMotionListener.h" | 8 #include "third_party/WebKit/public/platform/modules/device_orientation/WebDevic
eMotionListener.h" |
| 9 | 9 |
| 10 namespace content { | 10 namespace content { |
| 11 | 11 |
| 12 DeviceMotionEventPump::DeviceMotionEventPump(RenderThread* thread) | 12 DeviceMotionEventPump::DeviceMotionEventPump(RenderThread* thread) |
| 13 : DeviceSensorMojoClientMixin< | 13 : DeviceSensorMojoClientMixin< |
| 14 DeviceSensorEventPump<blink::WebDeviceMotionListener>, | 14 DeviceSensorEventPump<blink::WebDeviceMotionListener>, |
| 15 device::mojom::MotionSensor>(thread) {} | 15 device::mojom::MotionSensor>(thread) {} |
| 16 | 16 |
| 17 DeviceMotionEventPump::~DeviceMotionEventPump() { | 17 DeviceMotionEventPump::~DeviceMotionEventPump() { |
| 18 } | 18 } |
| 19 | 19 |
| 20 void DeviceMotionEventPump::FireEvent() { | 20 void DeviceMotionEventPump::FireEvent() { |
| 21 DCHECK(listener()); | 21 DCHECK(listener()); |
| 22 blink::WebDeviceMotionData data; | 22 device::MotionData data; |
| 23 if (reader_->GetLatestData(&data) && data.allAvailableSensorsAreActive) | 23 if (reader_->GetLatestData(&data) && data.allAvailableSensorsAreActive) |
| 24 listener()->didChangeDeviceMotion(data); | 24 listener()->didChangeDeviceMotion(data); |
| 25 } | 25 } |
| 26 | 26 |
| 27 bool DeviceMotionEventPump::InitializeReader(base::SharedMemoryHandle handle) { | 27 bool DeviceMotionEventPump::InitializeReader(base::SharedMemoryHandle handle) { |
| 28 if (!reader_) | 28 if (!reader_) |
| 29 reader_.reset(new DeviceMotionSharedMemoryReader()); | 29 reader_.reset(new DeviceMotionSharedMemoryReader()); |
| 30 return reader_->Initialize(handle); | 30 return reader_->Initialize(handle); |
| 31 } | 31 } |
| 32 | 32 |
| 33 void DeviceMotionEventPump::SendFakeDataForTesting(void* fake_data) { | 33 void DeviceMotionEventPump::SendFakeDataForTesting(void* fake_data) { |
| 34 blink::WebDeviceMotionData data = | 34 device::MotionData data = *static_cast<device::MotionData*>(fake_data); |
| 35 *static_cast<blink::WebDeviceMotionData*>(fake_data); | |
| 36 | 35 |
| 37 listener()->didChangeDeviceMotion(data); | 36 listener()->didChangeDeviceMotion(data); |
| 38 } | 37 } |
| 39 | 38 |
| 40 } // namespace content | 39 } // namespace content |
| OLD | NEW |