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

Unified Diff: third_party/WebKit/Source/modules/sensor/Magnetometer.cpp

Issue 2507453002: [sensors] Magnetometer sensor bindings implementation (Closed)
Patch Set: Rebased to master Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/modules/sensor/Magnetometer.cpp
diff --git a/third_party/WebKit/Source/modules/sensor/Magnetometer.cpp b/third_party/WebKit/Source/modules/sensor/Magnetometer.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..56fbe6798dfef25fd40c1de6094204ea99a83c7e
--- /dev/null
+++ b/third_party/WebKit/Source/modules/sensor/Magnetometer.cpp
@@ -0,0 +1,44 @@
+// 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/Magnetometer.h"
+
+#include "modules/sensor/MagnetometerReading.h"
+
+using device::mojom::blink::SensorType;
+
+namespace blink {
+
+// static
+Magnetometer* Magnetometer::create(ScriptState* scriptState,
+ const SensorOptions& options,
+ ExceptionState& exceptionState) {
+ return new Magnetometer(scriptState, options, exceptionState);
+}
+
+// static
+Magnetometer* Magnetometer::create(ScriptState* scriptState,
+ ExceptionState& exceptionState) {
+ return create(scriptState, SensorOptions(), exceptionState);
+}
+
+Magnetometer::Magnetometer(ScriptState* scriptState,
+ const SensorOptions& options,
+ ExceptionState& exceptionState)
+ : Sensor(scriptState, options, exceptionState, SensorType::MAGNETOMETER) {}
+
+MagnetometerReading* Magnetometer::reading() const {
+ return static_cast<MagnetometerReading*>(Sensor::reading());
+}
+
+std::unique_ptr<SensorReadingFactory>
+Magnetometer::createSensorReadingFactory() {
+ return makeUnique<SensorReadingFactoryImpl<MagnetometerReading>>();
+}
+
+DEFINE_TRACE(Magnetometer) {
+ Sensor::trace(visitor);
+}
+
+} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/modules/sensor/Magnetometer.h ('k') | third_party/WebKit/Source/modules/sensor/Magnetometer.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698