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

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

Issue 1942663003: [sensors]: Introduce the Generic Sensor API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase , m_sensorReading and options are private 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 #include "modules/sensor/Sensor.h"
6
7 #include "bindings/core/v8/ScriptPromise.h"
8 #include "bindings/core/v8/ScriptPromiseResolver.h"
9 #include "modules/sensor/SensorReading.h"
10
11 namespace blink {
12
13 Sensor::~Sensor()
14 {
15 }
16
17 Sensor::Sensor(ExecutionContext* executionContext, const SensorOptions& sensorOp tions)
18 : ActiveScriptWrappable(this)
19 , ActiveDOMObject(executionContext)
20 , m_sensorState(SensorState::Idle)
21 , m_sensorOptions(sensorOptions)
22 {
23 }
24
25 // Getters
26 String Sensor::state() const
27 {
28 switch (m_sensorState) {
29 case SensorState::Idle:
timvolodine 2016/05/17 17:44:39 indentation
riju_ 2016/05/20 11:20:11 check-webkit-style does not complain https://www.c
timvolodine 2016/05/24 15:30:35 yes sorry you are correct, this should follow the
30 return "idle";
31 case SensorState::Activating:
32 return "activating";
33 case SensorState::Active:
34 return "active";
35 case SensorState::Errored:
36 return "errored";
37 }
38 ASSERT_NOT_REACHED();
39 return "idle";
40 }
41
42 SensorReading* Sensor::reading() const
43 {
44 if (!m_sensorReading.get())
45 return nullptr;
46 return m_sensorReading.get();
timvolodine 2016/05/17 17:44:40 could you just return m_sensorReading.get() here w
riju_ 2016/05/20 11:20:11 Done.
47 }
48
49 // Default implementation of these ActiveDOMObject methods is empty as
50 // the derived classes from Sensor will override them.
51 void Sensor::suspend()
timvolodine 2016/05/17 17:44:39 if the methods inherited from ActiveDOMObject are
haraken 2016/05/17 23:42:48 If you don't have a plan to do something on suspen
riju_ 2016/05/20 11:20:11 These are not empty any more.
52 {
53 }
54
55 void Sensor::resume()
56 {
57 }
58
59 void Sensor::stop()
60 {
61 }
62
63 DEFINE_TRACE(Sensor)
64 {
65 ActiveDOMObject::trace(visitor);
66 EventTargetWithInlineData::trace(visitor);
67 visitor->trace(m_sensorReading);
68 }
69
70 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698