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

Side by Side Diff: third_party/WebKit/Source/modules/sensor/AmbientLightSensorReading.cpp

Issue 2668173003: [Sensors] Remove SensorReading interfaces (Closed)
Patch Set: updated global-interface-listing.html Created 3 years, 10 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
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "modules/sensor/AmbientLightSensorReading.h"
6
7 #include "modules/sensor/SensorProxy.h"
8 #include "wtf/CurrentTime.h"
9
10 namespace blink {
11
12 namespace {
13
14 device::SensorReading ToReadingData(const AmbientLightSensorReadingInit& init) {
15 device::SensorReading result;
16 result.timestamp = WTF::monotonicallyIncreasingTime();
17 if (init.hasIlluminance())
18 result.values[0] = init.illuminance();
19
20 return result;
21 }
22
23 } // namespace
24
25 AmbientLightSensorReading::AmbientLightSensorReading(
26 const AmbientLightSensorReadingInit& init)
27 : SensorReading(ToReadingData(init)) {}
28
29 AmbientLightSensorReading::AmbientLightSensorReading(
30 const device::SensorReading& data)
31 : SensorReading(data) {}
32
33 AmbientLightSensorReading::~AmbientLightSensorReading() = default;
34
35 double AmbientLightSensorReading::illuminance() const {
36 return data().values[0];
37 }
38
39 bool AmbientLightSensorReading::isReadingUpdated(
40 const device::SensorReading& previous) const {
41 return previous.values[0] != illuminance();
42 }
43
44 DEFINE_TRACE(AmbientLightSensorReading) {
45 SensorReading::trace(visitor);
46 }
47
48 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698