OLD | NEW |
| (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 SensorReading_h | |
6 #define SensorReading_h | |
7 | |
8 #include "bindings/core/v8/ScriptWrappable.h" | |
9 #include "core/dom/DOMHighResTimeStamp.h" | |
10 #include "core/dom/DOMTimeStamp.h" | |
11 #include "modules/sensor/SensorProxy.h" | |
12 | |
13 namespace blink { | |
14 | |
15 class ScriptState; | |
16 | |
17 class SensorReading : public GarbageCollectedFinalized<SensorReading>, | |
18 public ScriptWrappable { | |
19 DEFINE_WRAPPERTYPEINFO(); | |
20 | |
21 public: | |
22 DEFINE_INLINE_VIRTUAL_TRACE() {} | |
23 | |
24 DOMHighResTimeStamp timeStamp(ScriptState*) const; | |
25 | |
26 // Returns 'true' if the current reading value is different than the given | |
27 // previous one; otherwise returns 'false'. | |
28 virtual bool isReadingUpdated( | |
29 const device::SensorReading& previous) const = 0; | |
30 | |
31 const device::SensorReading& data() const { return m_data; } | |
32 | |
33 virtual ~SensorReading(); | |
34 | |
35 protected: | |
36 explicit SensorReading(const device::SensorReading&); | |
37 | |
38 private: | |
39 device::SensorReading m_data; | |
40 }; | |
41 | |
42 class SensorReadingFactory { | |
43 public: | |
44 virtual SensorReading* createSensorReading(const device::SensorReading&) = 0; | |
45 | |
46 protected: | |
47 SensorReadingFactory() = default; | |
48 }; | |
49 | |
50 template <typename SensorReadingType> | |
51 class SensorReadingFactoryImpl : public SensorReadingFactory { | |
52 public: | |
53 SensorReading* createSensorReading( | |
54 const device::SensorReading& reading) override { | |
55 return SensorReadingType::create(reading); | |
56 } | |
57 }; | |
58 | |
59 } // namepsace blink | |
60 | |
61 #endif // SensorReading_h | |
OLD | NEW |