Chromium Code Reviews| Index: third_party/WebKit/Source/modules/sensor/GyroscopeReading.cpp |
| diff --git a/third_party/WebKit/Source/modules/sensor/GyroscopeReading.cpp b/third_party/WebKit/Source/modules/sensor/GyroscopeReading.cpp |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..b43eee6d4a0711a1b6fbe5c6a3c00aa43b7c44d3 |
| --- /dev/null |
| +++ b/third_party/WebKit/Source/modules/sensor/GyroscopeReading.cpp |
| @@ -0,0 +1,56 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "modules/sensor/GyroscopeReading.h" |
| + |
| +#include "modules/sensor/SensorProxy.h" |
|
shalamov
2016/11/16 14:38:20
nit: not used
Mikhail
2016/11/17 13:47:46
Done.
|
| +#include "wtf/CurrentTime.h" |
| + |
| +namespace blink { |
| + |
| +namespace { |
| +device::SensorReading ToReadingData(const GyroscopeReadingInit& init) { |
| + device::SensorReading result; |
| + result.timestamp = WTF::monotonicallyIncreasingTime(); |
| + if (init.hasX()) |
| + result.values[0] = init.x(); |
| + if (init.hasY()) |
| + result.values[1] = init.y(); |
| + if (init.hasZ()) |
| + result.values[2] = init.z(); |
| + return result; |
| +} |
| +} // namespace |
| + |
| +GyroscopeReading::GyroscopeReading(const GyroscopeReadingInit& init) |
| + : SensorReading(ToReadingData(init)) {} |
| + |
| +GyroscopeReading::GyroscopeReading(const device::SensorReading& data) |
| + : SensorReading(data) {} |
| + |
| +GyroscopeReading::~GyroscopeReading() = default; |
| + |
| +double GyroscopeReading::x() const { |
| + return data().values[0]; |
| +} |
| + |
| +double GyroscopeReading::y() const { |
| + return data().values[1]; |
| +} |
| + |
| +double GyroscopeReading::z() const { |
| + return data().values[2]; |
| +} |
| + |
| +bool GyroscopeReading::isReadingUpdated( |
| + const device::SensorReading& previous) const { |
| + return (previous.values[0] != x() || previous.values[1] != y() || |
| + previous.values[2] != z()); |
|
Reilly Grant (use Gerrit)
2016/11/16 18:50:51
nit: parenthesis unnecessary
Mikhail
2016/11/17 13:47:46
Done.
|
| +} |
| + |
| +DEFINE_TRACE(GyroscopeReading) { |
| + SensorReading::trace(visitor); |
| +} |
| + |
| +} // namespace blink |