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 "content/renderer/device_sensors/device_light_event_pump.h" | 5 #include "content/renderer/device_sensors/device_light_event_pump.h" |
6 | 6 |
7 #include "base/time/time.h" | 7 #include "base/time/time.h" |
8 #include "content/public/renderer/render_thread.h" | 8 #include "content/public/renderer/render_thread.h" |
| 9 #include "device/sensors/public/cpp/device_sensors_consts.h" |
9 #include "third_party/WebKit/public/platform/WebDeviceLightListener.h" | 10 #include "third_party/WebKit/public/platform/WebDeviceLightListener.h" |
10 | 11 |
11 namespace { | 12 namespace { |
12 // Default rate for firing of DeviceLight events. | 13 // Default rate for firing of DeviceLight events. |
13 const int kDefaultLightPumpFrequencyHz = 5; | |
14 const int kDefaultLightPumpDelayMicroseconds = | 14 const int kDefaultLightPumpDelayMicroseconds = |
15 base::Time::kMicrosecondsPerSecond / kDefaultLightPumpFrequencyHz; | 15 base::Time::kMicrosecondsPerSecond / |
| 16 device::kDefaultAmbientLightFrequencyHz; |
16 } // namespace | 17 } // namespace |
17 | 18 |
18 namespace content { | 19 namespace content { |
19 | 20 |
20 DeviceLightEventPump::DeviceLightEventPump(RenderThread* thread) | 21 DeviceLightEventPump::DeviceLightEventPump(RenderThread* thread) |
21 : DeviceSensorMojoClientMixin< | 22 : DeviceSensorMojoClientMixin< |
22 DeviceSensorEventPump<blink::WebDeviceLightListener>, | 23 DeviceSensorEventPump<blink::WebDeviceLightListener>, |
23 device::mojom::LightSensor>(thread), | 24 device::mojom::LightSensor>(thread), |
24 last_seen_data_(-1) { | 25 last_seen_data_(-1) { |
25 pump_delay_microseconds_ = kDefaultLightPumpDelayMicroseconds; | 26 pump_delay_microseconds_ = kDefaultLightPumpDelayMicroseconds; |
(...skipping 29 matching lines...) Expand all Loading... |
55 return reader_->Initialize(handle); | 56 return reader_->Initialize(handle); |
56 } | 57 } |
57 | 58 |
58 void DeviceLightEventPump::SendFakeDataForTesting(void* fake_data) { | 59 void DeviceLightEventPump::SendFakeDataForTesting(void* fake_data) { |
59 double data = *static_cast<double*>(fake_data); | 60 double data = *static_cast<double*>(fake_data); |
60 | 61 |
61 listener()->didChangeDeviceLight(data); | 62 listener()->didChangeDeviceLight(data); |
62 } | 63 } |
63 | 64 |
64 } // namespace content | 65 } // namespace content |
OLD | NEW |