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

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

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.h
diff --git a/third_party/WebKit/Source/modules/sensor/Sensor.h b/third_party/WebKit/Source/modules/sensor/Sensor.h
new file mode 100644
index 0000000000000000000000000000000000000000..660df3d0e6b2c1058f8b2554360d822a6d43ac14
--- /dev/null
+++ b/third_party/WebKit/Source/modules/sensor/Sensor.h
@@ -0,0 +1,72 @@
+// 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.
+
+#ifndef Sensor_h
+#define Sensor_h
+
+#include "bindings/core/v8/ActiveScriptWrappable.h"
+#include "bindings/core/v8/ScriptPromise.h"
+#include "bindings/core/v8/ScriptWrappable.h"
+#include "core/dom/ActiveDOMObject.h"
+#include "core/dom/ContextLifecycleObserver.h"
+#include "modules/EventTargetModules.h"
+#include "modules/ModulesExport.h"
+#include "modules/sensor/SensorOptions.h"
+#include "modules/sensor/SensorReading.h"
+#include "modules/sensor/sensor_state_type.h"
+#include "platform/heap/Handle.h"
+
+namespace blink {
+
+class ExceptionState;
+class ScriptState;
+class SensorReading;
+
+class MODULES_EXPORT Sensor
+ : public EventTargetWithInlineData
+ , public ActiveScriptWrappable
+ , public ActiveDOMObject {
+ USING_GARBAGE_COLLECTED_MIXIN(Sensor);
+ DEFINE_WRAPPERTYPEINFO();
+
+public:
+ ~Sensor() override;
+
+ virtual void start(ScriptState*, ExceptionState&) = 0;
+ virtual void stop(ScriptState*, ExceptionState&) = 0;
+ virtual void updateState(SensorState) = 0;
+
+ // EventTarget implementation.
+ const AtomicString& interfaceName() const override { return EventTargetNames::Sensor; }
+ ExecutionContext* getExecutionContext() const override { return ContextLifecycleObserver::getExecutionContext(); }
+
+ // Getters
+ String state();
+ SensorReading& reading();
+
+ DEFINE_ATTRIBUTE_EVENT_LISTENER(error);
+ DEFINE_ATTRIBUTE_EVENT_LISTENER(change);
+ DEFINE_ATTRIBUTE_EVENT_LISTENER(statechange);
+
+ // ActiveDOMObject implementation.
+ void suspend() override;
+ void resume() override;
+ void stop() override;
+
+ // ActiveScriptWrappable implementation.
+ bool hasPendingActivity() const override;
+
+ DECLARE_VIRTUAL_TRACE();
+
+protected:
+ Sensor(ExecutionContext*, const SensorOptions&);
+
+ SensorOptions m_sensorOptions;
+ SensorState m_sensorState;
+ Member<SensorReading> m_sensorReading;
+};
+
+} // namespace blink
+
+#endif // Sensor_h

Powered by Google App Engine
This is Rietveld 408576698