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

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

Issue 1892083002: Generic Sensor API : Ambient Light Sensor API. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
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..18fb33402400c7882cf5b313a5926f05d750aa53
--- /dev/null
+++ b/third_party/WebKit/Source/modules/sensor/Sensor.cpp
@@ -0,0 +1,76 @@
+// 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 "core/dom/DOMException.h"
+#include "core/dom/ExceptionCode.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)
+{
+}
+
+// Getters
+String Sensor::state()
+{
+ switch (m_sensorState) {
+ case SensorState::Idle:
+ 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()
+{
+ return *m_sensorReading.get();
+}
+
+void Sensor::updateState(SensorState newState)
+{
+}
+
+void Sensor::suspend()
+{
+}
+
+void Sensor::resume()
+{
+}
+
+void Sensor::stop()
+{
+}
+
+bool Sensor::hasPendingActivity() const
+{
+ return false;
+}
+
+DEFINE_TRACE(Sensor)
+{
+ ActiveDOMObject::trace(visitor);
+ EventTargetWithInlineData::trace(visitor);
+ visitor->trace(m_sensorReading);
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698