| 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 "modules/sensor/SensorReading.h" | 8 #include "modules/sensor/SensorReading.h" |
| 9 #include "platform/mojo/MojoHelper.h" | 9 #include "platform/mojo/MojoHelper.h" |
| 10 #include "public/platform/InterfaceProvider.h" | 10 #include "public/platform/InterfaceProvider.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 | 48 |
| 49 SensorProviderProxy::~SensorProviderProxy() {} | 49 SensorProviderProxy::~SensorProviderProxy() {} |
| 50 | 50 |
| 51 DEFINE_TRACE(SensorProviderProxy) { | 51 DEFINE_TRACE(SensorProviderProxy) { |
| 52 visitor->trace(m_sensorProxies); | 52 visitor->trace(m_sensorProxies); |
| 53 Supplement<LocalFrame>::trace(visitor); | 53 Supplement<LocalFrame>::trace(visitor); |
| 54 } | 54 } |
| 55 | 55 |
| 56 SensorProxy* SensorProviderProxy::createSensorProxy( | 56 SensorProxy* SensorProviderProxy::createSensorProxy( |
| 57 device::mojom::blink::SensorType type, | 57 device::mojom::blink::SensorType type, |
| 58 Page* page, | 58 Document* document, |
| 59 std::unique_ptr<SensorReadingFactory> readingFactory) { | 59 std::unique_ptr<SensorReadingFactory> readingFactory) { |
| 60 DCHECK(!getSensorProxy(type)); | 60 DCHECK(!getSensorProxy(type)); |
| 61 | 61 |
| 62 SensorProxy* sensor = | 62 SensorProxy* sensor = |
| 63 new SensorProxy(type, this, page, std::move(readingFactory)); | 63 new SensorProxy(type, this, document, std::move(readingFactory)); |
| 64 m_sensorProxies.add(sensor); | 64 m_sensorProxies.add(sensor); |
| 65 | 65 |
| 66 return sensor; | 66 return sensor; |
| 67 } | 67 } |
| 68 | 68 |
| 69 SensorProxy* SensorProviderProxy::getSensorProxy( | 69 SensorProxy* SensorProviderProxy::getSensorProxy( |
| 70 device::mojom::blink::SensorType type) { | 70 device::mojom::blink::SensorType type) { |
| 71 for (SensorProxy* sensor : m_sensorProxies) { | 71 for (SensorProxy* sensor : m_sensorProxies) { |
| 72 // TODO(Mikhail) : Hash sensors by type for efficiency. | 72 // TODO(Mikhail) : Hash sensors by type for efficiency. |
| 73 if (sensor->type() == type) | 73 if (sensor->type() == type) |
| 74 return sensor; | 74 return sensor; |
| 75 } | 75 } |
| 76 | 76 |
| 77 return nullptr; | 77 return nullptr; |
| 78 } | 78 } |
| 79 | 79 |
| 80 void SensorProviderProxy::onSensorProviderConnectionError() { | 80 void SensorProviderProxy::onSensorProviderConnectionError() { |
| 81 if (!Platform::current()) { | 81 if (!Platform::current()) { |
| 82 // TODO(rockot): Clean this up once renderer shutdown sequence is fixed. | 82 // TODO(rockot): Clean this up once renderer shutdown sequence is fixed. |
| 83 return; | 83 return; |
| 84 } | 84 } |
| 85 | 85 |
| 86 m_sensorProvider.reset(); | 86 m_sensorProvider.reset(); |
| 87 for (SensorProxy* sensor : m_sensorProxies) | 87 for (SensorProxy* sensor : m_sensorProxies) |
| 88 sensor->handleSensorError(); | 88 sensor->handleSensorError(); |
| 89 } | 89 } |
| 90 | 90 |
| 91 } // namespace blink | 91 } // namespace blink |
| OLD | NEW |