Chromium Code Reviews| 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..5c5fafa3adffbfc38717c6019218d6770f54f0b0 |
| --- /dev/null |
| +++ b/third_party/WebKit/Source/modules/sensor/Magnetometer.cpp |
| @@ -0,0 +1,45 @@ |
| +// 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 std::unique_ptr<SensorReadingFactory>( |
| + new SensorReadingFactoryImpl<MagnetometerReading>()); |
|
haraken
2016/11/16 17:33:02
Use makeUnique.
|
| +} |
| + |
| +DEFINE_TRACE(Magnetometer) { |
| + Sensor::trace(visitor); |
| +} |
| + |
| +} // namespace blink |