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

Side by Side Diff: content/renderer/device_sensors/device_light_event_pump.cc

Issue 2332903002: [sensors] [mac] Implement ambient light sensor for macOS (Closed)
Patch Set: Update commit message Created 4 years, 2 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 unified diff | Download patch
« no previous file with comments | « content/renderer/DEPS ('k') | device/generic_sensor/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
OLDNEW
« no previous file with comments | « content/renderer/DEPS ('k') | device/generic_sensor/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698