| OLD | NEW |
| 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/Sensor.h" | 5 #include "modules/sensor/Sensor.h" |
| 6 | 6 |
| 7 #include "core/dom/Document.h" | 7 #include "core/dom/Document.h" |
| 8 #include "core/dom/ExceptionCode.h" | 8 #include "core/dom/ExceptionCode.h" |
| 9 #include "core/dom/ExecutionContextTask.h" | 9 #include "core/dom/ExecutionContextTask.h" |
| 10 #include "core/events/Event.h" | 10 #include "core/events/Event.h" |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 | 84 |
| 85 void Sensor::updateState(SensorState newState) | 85 void Sensor::updateState(SensorState newState) |
| 86 { | 86 { |
| 87 DCHECK(isMainThread()); | 87 DCHECK(isMainThread()); |
| 88 if (m_sensorState == newState) | 88 if (m_sensorState == newState) |
| 89 return; | 89 return; |
| 90 | 90 |
| 91 m_sensorState = newState; | 91 m_sensorState = newState; |
| 92 // Notify context that state changed. | 92 // Notify context that state changed. |
| 93 if (getExecutionContext()) | 93 if (getExecutionContext()) |
| 94 getExecutionContext()->postTask(BLINK_FROM_HERE, createSameThreadTask(&S
ensor::notifyStateChange, this)); | 94 getExecutionContext()->postTask(BLINK_FROM_HERE, createSameThreadTask(&S
ensor::notifyStateChange, wrapPersistent(this))); |
| 95 } | 95 } |
| 96 | 96 |
| 97 void Sensor::notifyStateChange() | 97 void Sensor::notifyStateChange() |
| 98 { | 98 { |
| 99 dispatchEvent(Event::create(EventTypeNames::statechange)); | 99 dispatchEvent(Event::create(EventTypeNames::statechange)); |
| 100 } | 100 } |
| 101 | 101 |
| 102 void Sensor::suspend() | 102 void Sensor::suspend() |
| 103 { | 103 { |
| 104 m_hasEventListener = false; | 104 m_hasEventListener = false; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 126 | 126 |
| 127 DEFINE_TRACE(Sensor) | 127 DEFINE_TRACE(Sensor) |
| 128 { | 128 { |
| 129 ActiveDOMObject::trace(visitor); | 129 ActiveDOMObject::trace(visitor); |
| 130 EventTargetWithInlineData::trace(visitor); | 130 EventTargetWithInlineData::trace(visitor); |
| 131 PlatformEventController::trace(visitor); | 131 PlatformEventController::trace(visitor); |
| 132 visitor->trace(m_sensorReading); | 132 visitor->trace(m_sensorReading); |
| 133 } | 133 } |
| 134 | 134 |
| 135 } // namespace blink | 135 } // namespace blink |
| OLD | NEW |