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

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

Issue 2472403002: [Sensors] Align sensor reading attribute implementation with the specification (Closed)
Patch Set: Comments from Tim Created 4 years, 1 month 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
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef SensorReading_h 5 #ifndef SensorReading_h
6 #define SensorReading_h 6 #define SensorReading_h
7 7
8 #include "bindings/core/v8/ScriptWrappable.h" 8 #include "bindings/core/v8/ScriptWrappable.h"
9 #include "core/dom/DOMHighResTimeStamp.h" 9 #include "core/dom/DOMHighResTimeStamp.h"
10 #include "core/dom/DOMTimeStamp.h" 10 #include "core/dom/DOMTimeStamp.h"
11 #include "modules/sensor/SensorProxy.h" 11 #include "modules/sensor/SensorProxy.h"
12 12
13 namespace blink { 13 namespace blink {
14 14
15 class ScriptState; 15 class ScriptState;
16 16
17 class SensorReading : public GarbageCollectedFinalized<SensorReading>, 17 class SensorReading : public GarbageCollectedFinalized<SensorReading>,
18 public ScriptWrappable { 18 public ScriptWrappable {
19 DEFINE_WRAPPERTYPEINFO(); 19 DEFINE_WRAPPERTYPEINFO();
20 20
21 public: 21 public:
22 DECLARE_VIRTUAL_TRACE(); 22 DEFINE_INLINE_VIRTUAL_TRACE() {}
23 23
24 DOMHighResTimeStamp timeStamp(ScriptState*) const; 24 DOMHighResTimeStamp timeStamp(ScriptState*) const;
25 25
26 // Returns 'true' if the current reading value is different than the given 26 // Returns 'true' if the current reading value is different than the given
27 // previous one; otherwise returns 'false'. 27 // previous one; otherwise returns 'false'.
28 virtual bool isReadingUpdated(const SensorProxy::Reading& previous) const = 0; 28 virtual bool isReadingUpdated(
29 const device::SensorReading& previous) const = 0;
30
31 const device::SensorReading& data() const { return m_data; }
29 32
30 virtual ~SensorReading(); 33 virtual ~SensorReading();
31 34
32 protected: 35 protected:
33 explicit SensorReading(SensorProxy*); 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;
34 45
35 protected: 46 protected:
36 Member<SensorProxy> m_sensorProxy; 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 }
37 }; 57 };
38 58
39 } // namepsace blink 59 } // namepsace blink
40 60
41 #endif // SensorReading_h 61 #endif // SensorReading_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/sensor/SensorProxy.cpp ('k') | third_party/WebKit/Source/modules/sensor/SensorReading.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698