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