Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(28)

Side by Side Diff: third_party/WebKit/Source/modules/sensor/SensorProviderProxy.cpp

Issue 2604483004: [Sensors] Reland: Reland: Align sensor reading updates and 'onchange' notification with rAF. (Closed)
Patch Set: Patch with fix Created 3 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/sensor/SensorProviderProxy.h ('k') | third_party/WebKit/Source/modules/sensor/SensorProxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698