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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef Sensor_h
6 #define Sensor_h
7
8 #include "bindings/core/v8/ActiveScriptWrappable.h"
9 #include "bindings/core/v8/ScriptPromise.h"
10 #include "bindings/core/v8/ScriptWrappable.h"
11 #include "core/dom/ActiveDOMObject.h"
12 #include "core/dom/ContextLifecycleObserver.h"
13 #include "modules/EventTargetModules.h"
14 #include "modules/ModulesExport.h"
15 #include "modules/sensor/SensorOptions.h"
16 #include "modules/sensor/SensorReading.h"
17 #include "modules/sensor/sensor_state_type.h"
18 #include "platform/heap/Handle.h"
19
20 namespace blink {
21
22 class ExceptionState;
23 class ScriptState;
24 class SensorReading;
25
26 class MODULES_EXPORT Sensor
27 : public EventTargetWithInlineData
28 , public ActiveScriptWrappable
29 , public ActiveDOMObject {
30 USING_GARBAGE_COLLECTED_MIXIN(Sensor);
31 DEFINE_WRAPPERTYPEINFO();
32
33 public:
34 ~Sensor() override;
35
36 virtual void start(ScriptState*, ExceptionState&) = 0;
37 virtual void stop(ScriptState*, ExceptionState&) = 0;
38 virtual void updateState(SensorState) = 0;
39
40 // EventTarget implementation.
41 const AtomicString& interfaceName() const override { return EventTargetNames ::Sensor; }
42 ExecutionContext* getExecutionContext() const override { return ContextLifec ycleObserver::getExecutionContext(); }
43
44 // Getters
45 String state();
46 SensorReading& reading();
47
48 DEFINE_ATTRIBUTE_EVENT_LISTENER(error);
49 DEFINE_ATTRIBUTE_EVENT_LISTENER(change);
50 DEFINE_ATTRIBUTE_EVENT_LISTENER(statechange);
51
52 // ActiveDOMObject implementation.
53 void suspend() override;
54 void resume() override;
55 void stop() override;
56
57 // ActiveScriptWrappable implementation.
58 bool hasPendingActivity() const override;
59
60 DECLARE_VIRTUAL_TRACE();
61
62 protected:
63 Sensor(ExecutionContext*, const SensorOptions&);
64
65 SensorOptions m_sensorOptions;
66 SensorState m_sensorState;
67 Member<SensorReading> m_sensorReading;
68 };
69
70 } // namespace blink
71
72 #endif // Sensor_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698