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

Side by Side Diff: third_party/WebKit/Source/modules/sensor/AmbientLightSensorReading.cpp

Issue 2395853003: [Sensors] Improvements in shared buffer managing (Closed)
Patch Set: Test compilation fix + comment from Ken Created 4 years, 2 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
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 #include "modules/sensor/AmbientLightSensorReading.h" 5 #include "modules/sensor/AmbientLightSensorReading.h"
6 6
7 #include "modules/sensor/SensorProxy.h" 7 #include "modules/sensor/SensorProxy.h"
8 8
9 namespace blink { 9 namespace blink {
10 10
11 AmbientLightSensorReading::AmbientLightSensorReading( 11 AmbientLightSensorReading::AmbientLightSensorReading(
12 const AmbientLightSensorReadingInit& init) 12 const AmbientLightSensorReadingInit& init)
13 : SensorReading(nullptr), mAmbientLightSensorReadingInit(init) {} 13 : SensorReading(nullptr), mAmbientLightSensorReadingInit(init) {}
14 14
15 AmbientLightSensorReading::AmbientLightSensorReading(SensorProxy* proxy) 15 AmbientLightSensorReading::AmbientLightSensorReading(SensorProxy* proxy)
16 : SensorReading(proxy), 16 : SensorReading(proxy),
17 mAmbientLightSensorReadingInit(AmbientLightSensorReadingInit()) {} 17 mAmbientLightSensorReadingInit(AmbientLightSensorReadingInit()) {}
18 18
19 AmbientLightSensorReading::~AmbientLightSensorReading() = default; 19 AmbientLightSensorReading::~AmbientLightSensorReading() = default;
20 20
21 double AmbientLightSensorReading::illuminance() const { 21 double AmbientLightSensorReading::illuminance() const {
22 if (mAmbientLightSensorReadingInit.hasIlluminance()) 22 if (mAmbientLightSensorReadingInit.hasIlluminance())
23 return mAmbientLightSensorReadingInit.illuminance(); 23 return mAmbientLightSensorReadingInit.illuminance();
24 24
25 if (!m_sensorProxy) 25 if (!m_sensorProxy)
26 return 0.0; 26 return 0.0;
27 return m_sensorProxy->reading().reading[0]; 27 return m_sensorProxy->reading().values[0];
28 } 28 }
29 29
30 bool AmbientLightSensorReading::isReadingUpdated( 30 bool AmbientLightSensorReading::isReadingUpdated(
31 const SensorProxy::Reading& previous) const { 31 const SensorProxy::Reading& previous) const {
32 if (!m_sensorProxy) 32 if (!m_sensorProxy)
33 return false; 33 return false;
34 return previous.reading[0] != illuminance(); 34 return previous.values[0] != illuminance();
35 } 35 }
36 36
37 DEFINE_TRACE(AmbientLightSensorReading) { 37 DEFINE_TRACE(AmbientLightSensorReading) {
38 SensorReading::trace(visitor); 38 SensorReading::trace(visitor);
39 } 39 }
40 40
41 } // namespace blink 41 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/sensor/resources/sensor-helpers.js ('k') | third_party/WebKit/Source/modules/sensor/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698