Chromium Code Reviews| 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/inspector/ConsoleMessage.h" | 10 #include "core/inspector/ConsoleMessage.h" |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 281 wrapWeakPersistent(this))); | 281 wrapWeakPersistent(this))); |
| 282 } | 282 } |
| 283 | 283 |
| 284 m_storedData = m_sensorProxy->sensorReading()->data(); | 284 m_storedData = m_sensorProxy->sensorReading()->data(); |
| 285 } | 285 } |
| 286 | 286 |
| 287 void Sensor::updateState(Sensor::SensorState newState) { | 287 void Sensor::updateState(Sensor::SensorState newState) { |
| 288 if (newState == m_state) | 288 if (newState == m_state) |
| 289 return; | 289 return; |
| 290 m_state = newState; | 290 m_state = newState; |
| 291 if (getExecutionContext()) { | 291 if (m_state == SensorState::ACTIVE && getExecutionContext()) { |
|
shalamov
2016/11/09 11:17:16
if (m_state == ACTIVATING && newState == ACTIVE &&
| |
| 292 getExecutionContext()->postTask( | 292 getExecutionContext()->postTask( |
| 293 BLINK_FROM_HERE, createSameThreadTask(&Sensor::notifyStateChanged, | 293 BLINK_FROM_HERE, createSameThreadTask(&Sensor::notifyOnActivate, |
| 294 wrapWeakPersistent(this))); | 294 wrapWeakPersistent(this))); |
| 295 } | 295 } |
| 296 | 296 |
| 297 updatePollingStatus(); | 297 updatePollingStatus(); |
| 298 } | 298 } |
| 299 | 299 |
| 300 void Sensor::reportError(ExceptionCode code, | 300 void Sensor::reportError(ExceptionCode code, |
| 301 const String& sanitizedMessage, | 301 const String& sanitizedMessage, |
| 302 const String& unsanitizedMessage) { | 302 const String& unsanitizedMessage) { |
| 303 updateState(Sensor::SensorState::ERRORED); | 303 updateState(Sensor::SensorState::ERRORED); |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 320 m_polling->stopPolling(); | 320 m_polling->stopPolling(); |
| 321 } else { | 321 } else { |
| 322 m_polling->startPolling(); | 322 m_polling->startPolling(); |
| 323 } | 323 } |
| 324 } | 324 } |
| 325 | 325 |
| 326 void Sensor::notifySensorReadingChanged() { | 326 void Sensor::notifySensorReadingChanged() { |
| 327 dispatchEvent(Event::create(EventTypeNames::change)); | 327 dispatchEvent(Event::create(EventTypeNames::change)); |
| 328 } | 328 } |
| 329 | 329 |
| 330 void Sensor::notifyStateChanged() { | 330 void Sensor::notifyOnActivate() { |
| 331 dispatchEvent(Event::create(EventTypeNames::statechange)); | 331 dispatchEvent(Event::create(EventTypeNames::activate)); |
| 332 } | 332 } |
| 333 | 333 |
| 334 void Sensor::notifyError(DOMException* error) { | 334 void Sensor::notifyError(DOMException* error) { |
| 335 dispatchEvent( | 335 dispatchEvent( |
| 336 SensorErrorEvent::create(EventTypeNames::error, std::move(error))); | 336 SensorErrorEvent::create(EventTypeNames::error, std::move(error))); |
| 337 } | 337 } |
| 338 | 338 |
| 339 } // namespace blink | 339 } // namespace blink |
| OLD | NEW |