Index: third_party/WebKit/Source/modules/sensor/Sensor.cpp |
diff --git a/third_party/WebKit/Source/modules/sensor/Sensor.cpp b/third_party/WebKit/Source/modules/sensor/Sensor.cpp |
new file mode 100644 |
index 0000000000000000000000000000000000000000..d3519a48565a830b32de10ee48bd8022fe7b2ca4 |
--- /dev/null |
+++ b/third_party/WebKit/Source/modules/sensor/Sensor.cpp |
@@ -0,0 +1,70 @@ |
+// 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/Sensor.h" |
+ |
+#include "bindings/core/v8/ScriptPromise.h" |
+#include "bindings/core/v8/ScriptPromiseResolver.h" |
+#include "modules/sensor/SensorReading.h" |
+ |
+namespace blink { |
+ |
+Sensor::~Sensor() |
+{ |
+} |
+ |
+Sensor::Sensor(ExecutionContext* executionContext, const SensorOptions& sensorOptions) |
+ : ActiveScriptWrappable(this) |
+ , ActiveDOMObject(executionContext) |
+ , m_sensorState(SensorState::Idle) |
+ , m_sensorOptions(sensorOptions) |
+{ |
+} |
+ |
+// Getters |
+String Sensor::state() const |
+{ |
+ switch (m_sensorState) { |
+ case SensorState::Idle: |
timvolodine
2016/05/17 17:44:39
indentation
riju_
2016/05/20 11:20:11
check-webkit-style does not complain
https://www.c
timvolodine
2016/05/24 15:30:35
yes sorry you are correct, this should follow the
|
+ return "idle"; |
+ case SensorState::Activating: |
+ return "activating"; |
+ case SensorState::Active: |
+ return "active"; |
+ case SensorState::Errored: |
+ return "errored"; |
+ } |
+ ASSERT_NOT_REACHED(); |
+ return "idle"; |
+} |
+ |
+SensorReading* Sensor::reading() const |
+{ |
+ if (!m_sensorReading.get()) |
+ return nullptr; |
+ return m_sensorReading.get(); |
timvolodine
2016/05/17 17:44:40
could you just return m_sensorReading.get() here w
riju_
2016/05/20 11:20:11
Done.
|
+} |
+ |
+// Default implementation of these ActiveDOMObject methods is empty as |
+// the derived classes from Sensor will override them. |
+void Sensor::suspend() |
timvolodine
2016/05/17 17:44:39
if the methods inherited from ActiveDOMObject are
haraken
2016/05/17 23:42:48
If you don't have a plan to do something on suspen
riju_
2016/05/20 11:20:11
These are not empty any more.
|
+{ |
+} |
+ |
+void Sensor::resume() |
+{ |
+} |
+ |
+void Sensor::stop() |
+{ |
+} |
+ |
+DEFINE_TRACE(Sensor) |
+{ |
+ ActiveDOMObject::trace(visitor); |
+ EventTargetWithInlineData::trace(visitor); |
+ visitor->trace(m_sensorReading); |
+} |
+ |
+} // namespace blink |