| 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/SensorProviderProxy.h" | 5 #include "modules/sensor/SensorProviderProxy.h" |
| 6 | 6 |
| 7 #include "modules/sensor/SensorProxy.h" | 7 #include "modules/sensor/SensorProxy.h" |
| 8 #include "platform/mojo/MojoHelper.h" | 8 #include "platform/mojo/MojoHelper.h" |
| 9 #include "public/platform/InterfaceProvider.h" | 9 #include "public/platform/InterfaceProvider.h" |
| 10 #include "public/platform/Platform.h" |
| 10 | 11 |
| 11 namespace blink { | 12 namespace blink { |
| 12 | 13 |
| 13 // SensorProviderProxy | 14 // SensorProviderProxy |
| 14 SensorProviderProxy::SensorProviderProxy(LocalFrame* frame) { | 15 SensorProviderProxy::SensorProviderProxy(LocalFrame* frame) { |
| 15 frame->interfaceProvider()->getInterface(mojo::GetProxy(&m_sensorProvider)); | 16 frame->interfaceProvider()->getInterface(mojo::GetProxy(&m_sensorProvider)); |
| 16 m_sensorProvider.set_connection_error_handler(convertToBaseCallback( | 17 m_sensorProvider.set_connection_error_handler(convertToBaseCallback( |
| 17 WTF::bind(&SensorProviderProxy::onSensorProviderConnectionError, | 18 WTF::bind(&SensorProviderProxy::onSensorProviderConnectionError, |
| 18 wrapWeakPersistent(this)))); | 19 wrapWeakPersistent(this)))); |
| 19 } | 20 } |
| (...skipping 28 matching lines...) Expand all Loading... |
| 48 return sensor; | 49 return sensor; |
| 49 } | 50 } |
| 50 | 51 |
| 51 SensorProxy* sensor = new SensorProxy(type, this); | 52 SensorProxy* sensor = new SensorProxy(type, this); |
| 52 m_sensors.add(sensor); | 53 m_sensors.add(sensor); |
| 53 | 54 |
| 54 return sensor; | 55 return sensor; |
| 55 } | 56 } |
| 56 | 57 |
| 57 void SensorProviderProxy::onSensorProviderConnectionError() { | 58 void SensorProviderProxy::onSensorProviderConnectionError() { |
| 59 if (!Platform::current()) { |
| 60 // TODO(rockot): Clean this up once renderer shutdown sequence is fixed. |
| 61 return; |
| 62 } |
| 63 |
| 58 m_sensorProvider.reset(); | 64 m_sensorProvider.reset(); |
| 59 for (SensorProxy* sensor : m_sensors) | 65 for (SensorProxy* sensor : m_sensors) |
| 60 sensor->handleSensorError(); | 66 sensor->handleSensorError(); |
| 61 } | 67 } |
| 62 | 68 |
| 63 } // namespace blink | 69 } // namespace blink |
| OLD | NEW |