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

Side by Side Diff: third_party/WebKit/Source/modules/sensor/Sensor.h

Issue 1942663003: [sensors]: Introduce the Generic Sensor API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: use postTask Created 4 years, 7 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/ScriptWrappable.h"
10 #include "core/dom/ActiveDOMObject.h"
11 #include "core/dom/ContextLifecycleObserver.h"
12 #include "core/frame/PlatformEventController.h"
13 #include "modules/EventTargetModules.h"
14 #include "modules/ModulesExport.h"
15 #include "modules/sensor/SensorOptions.h"
16 #include "modules/sensor/SensorState.h"
17 #include "platform/heap/Handle.h"
18
19 namespace blink {
20
21 class ExceptionState;
22 class ScriptState;
23 class SensorReading;
24
25 class MODULES_EXPORT Sensor
26 : public EventTargetWithInlineData
27 , public ActiveScriptWrappable
28 , public ActiveDOMObject
29 , public PlatformEventController {
30 USING_GARBAGE_COLLECTED_MIXIN(Sensor);
31 DEFINE_WRAPPERTYPEINFO();
32
33 public:
34 ~Sensor() override;
35
36 void start(ScriptState*, ExceptionState&);
37 void stop(ScriptState*, ExceptionState&);
38 void updateState(SensorState);
39 void notifyStateChange();
timvolodine 2016/05/27 18:40:57 does it need to be public?
riju_ 2016/05/30 10:15:13 Done.
40
41 // EventTarget implementation.
42 const AtomicString& interfaceName() const override { return EventTargetNames ::Sensor; }
43 ExecutionContext* getExecutionContext() const override { return ContextLifec ycleObserver::getExecutionContext(); }
44
45 // Getters
46 String state() const;
47 // TODO(riju): crbug.com/614797 .
48 SensorReading* reading() const;
49
50 DEFINE_ATTRIBUTE_EVENT_LISTENER(error);
51 DEFINE_ATTRIBUTE_EVENT_LISTENER(change);
52 DEFINE_ATTRIBUTE_EVENT_LISTENER(statechange);
53
54 // ActiveDOMObject implementation.
55 void suspend() override;
56 void resume() override;
57 void stop() override;
58 bool hasPendingActivity() const override;
59
60 DECLARE_VIRTUAL_TRACE();
61
62 protected:
63 Sensor(ExecutionContext*, const SensorOptions&);
64 SensorState m_sensorState;
65 Member<SensorReading> m_sensorReading;
66 SensorOptions m_sensorOptions;
67 };
68
69 } // namespace blink
70
71 #endif // Sensor_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698