| 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/SensorProxy.h" | 5 #include "modules/sensor/SensorProxy.h" |
| 6 | 6 |
| 7 #include "core/frame/LocalFrame.h" | 7 #include "core/frame/LocalFrame.h" |
| 8 #include "modules/sensor/SensorProviderProxy.h" | 8 #include "modules/sensor/SensorProviderProxy.h" |
| 9 #include "modules/sensor/SensorReading.h" | 9 #include "modules/sensor/SensorReading.h" |
| 10 #include "platform/mojo/MojoHelper.h" | 10 #include "platform/mojo/MojoHelper.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 } | 48 } |
| 49 | 49 |
| 50 void SensorProxy::removeObserver(Observer* observer) { | 50 void SensorProxy::removeObserver(Observer* observer) { |
| 51 m_observers.remove(observer); | 51 m_observers.remove(observer); |
| 52 } | 52 } |
| 53 | 53 |
| 54 void SensorProxy::initialize() { | 54 void SensorProxy::initialize() { |
| 55 if (m_state != Uninitialized) | 55 if (m_state != Uninitialized) |
| 56 return; | 56 return; |
| 57 | 57 |
| 58 if (!m_provider->sensorProvider()) { | 58 if (!m_provider->getSensorProvider()) { |
| 59 handleSensorError(); | 59 handleSensorError(); |
| 60 return; | 60 return; |
| 61 } | 61 } |
| 62 | 62 |
| 63 m_state = Initializing; | 63 m_state = Initializing; |
| 64 auto callback = convertToBaseCallback( | 64 auto callback = convertToBaseCallback( |
| 65 WTF::bind(&SensorProxy::onSensorCreated, wrapWeakPersistent(this))); | 65 WTF::bind(&SensorProxy::onSensorCreated, wrapWeakPersistent(this))); |
| 66 m_provider->sensorProvider()->GetSensor(m_type, mojo::GetProxy(&m_sensor), | 66 m_provider->getSensorProvider()->GetSensor(m_type, mojo::GetProxy(&m_sensor), |
| 67 callback); | 67 callback); |
| 68 } | 68 } |
| 69 | 69 |
| 70 void SensorProxy::addConfiguration( | 70 void SensorProxy::addConfiguration( |
| 71 SensorConfigurationPtr configuration, | 71 SensorConfigurationPtr configuration, |
| 72 std::unique_ptr<Function<void(bool)>> callback) { | 72 std::unique_ptr<Function<void(bool)>> callback) { |
| 73 DCHECK(isInitialized()); | 73 DCHECK(isInitialized()); |
| 74 auto wrapper = WTF::bind(&SensorProxy::onAddConfigurationCompleted, | 74 auto wrapper = WTF::bind(&SensorProxy::onAddConfigurationCompleted, |
| 75 wrapWeakPersistent(this), configuration->frequency, | 75 wrapWeakPersistent(this), configuration->frequency, |
| 76 passed(std::move(callback))); | 76 passed(std::move(callback))); |
| 77 m_sensor->AddConfiguration(std::move(configuration), | 77 m_sensor->AddConfiguration(std::move(configuration), |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 updateSensorReading(); | 293 updateSensorReading(); |
| 294 m_timer.startRepeating(repeatInterval, BLINK_FROM_HERE); | 294 m_timer.startRepeating(repeatInterval, BLINK_FROM_HERE); |
| 295 } | 295 } |
| 296 } | 296 } |
| 297 | 297 |
| 298 void SensorProxy::onTimerFired(TimerBase*) { | 298 void SensorProxy::onTimerFired(TimerBase*) { |
| 299 updateSensorReading(); | 299 updateSensorReading(); |
| 300 } | 300 } |
| 301 | 301 |
| 302 } // namespace blink | 302 } // namespace blink |
| OLD | NEW |