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

Side by Side Diff: third_party/WebKit/Source/modules/sensor/GyroscopeReading.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/GyroscopeReading.h"
6
7 #include "modules/sensor/GyroscopeReadingInit.h"
8 #include "wtf/CurrentTime.h"
9
10 namespace blink {
11
12 namespace {
13 device::SensorReading ToReadingData(const GyroscopeReadingInit& init) {
14 device::SensorReading result;
15 result.timestamp = WTF::monotonicallyIncreasingTime();
16 if (init.hasX())
17 result.values[0] = init.x();
18 if (init.hasY())
19 result.values[1] = init.y();
20 if (init.hasZ())
21 result.values[2] = init.z();
22 return result;
23 }
24 } // namespace
25
26 GyroscopeReading::GyroscopeReading(const GyroscopeReadingInit& init)
27 : SensorReading(ToReadingData(init)) {}
28
29 GyroscopeReading::GyroscopeReading(const device::SensorReading& data)
30 : SensorReading(data) {}
31
32 GyroscopeReading::~GyroscopeReading() = default;
33
34 double GyroscopeReading::x() const {
35 return data().values[0];
36 }
37
38 double GyroscopeReading::y() const {
39 return data().values[1];
40 }
41
42 double GyroscopeReading::z() const {
43 return data().values[2];
44 }
45
46 bool GyroscopeReading::isReadingUpdated(
47 const device::SensorReading& previous) const {
48 return previous.values[0] != x() || previous.values[1] != y() ||
49 previous.values[2] != z();
50 }
51
52 DEFINE_TRACE(GyroscopeReading) {
53 SensorReading::trace(visitor);
54 }
55
56 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698