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

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

Issue 2644873002: [Sensors] Fix reading updates after page refresh (Closed)
Patch Set: Comments from haraken@. Rebased. Created 3 years, 10 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 46
47 SensorProviderProxy::~SensorProviderProxy() {} 47 SensorProviderProxy::~SensorProviderProxy() {}
48 48
49 DEFINE_TRACE(SensorProviderProxy) { 49 DEFINE_TRACE(SensorProviderProxy) {
50 visitor->trace(m_sensorProxies); 50 visitor->trace(m_sensorProxies);
51 Supplement<LocalFrame>::trace(visitor); 51 Supplement<LocalFrame>::trace(visitor);
52 } 52 }
53 53
54 SensorProxy* SensorProviderProxy::createSensorProxy( 54 SensorProxy* SensorProviderProxy::createSensorProxy(
55 device::mojom::blink::SensorType type, 55 device::mojom::blink::SensorType type,
56 Document* document, 56 Page* page,
57 std::unique_ptr<SensorReadingFactory> readingFactory) { 57 std::unique_ptr<SensorReadingFactory> readingFactory) {
58 DCHECK(!getSensorProxy(type)); 58 DCHECK(!getSensorProxy(type));
59 59
60 SensorProxy* sensor = 60 SensorProxy* sensor =
61 new SensorProxy(type, this, document, std::move(readingFactory)); 61 new SensorProxy(type, this, page, std::move(readingFactory));
62 m_sensorProxies.insert(sensor); 62 m_sensorProxies.insert(sensor);
63 63
64 return sensor; 64 return sensor;
65 } 65 }
66 66
67 SensorProxy* SensorProviderProxy::getSensorProxy( 67 SensorProxy* SensorProviderProxy::getSensorProxy(
68 device::mojom::blink::SensorType type) { 68 device::mojom::blink::SensorType type) {
69 for (SensorProxy* sensor : m_sensorProxies) { 69 for (SensorProxy* sensor : m_sensorProxies) {
70 // TODO(Mikhail) : Hash sensors by type for efficiency. 70 // TODO(Mikhail) : Hash sensors by type for efficiency.
71 if (sensor->type() == type) 71 if (sensor->type() == type)
72 return sensor; 72 return sensor;
73 } 73 }
74 74
75 return nullptr; 75 return nullptr;
76 } 76 }
77 77
78 void SensorProviderProxy::onSensorProviderConnectionError() { 78 void SensorProviderProxy::onSensorProviderConnectionError() {
79 if (!Platform::current()) { 79 if (!Platform::current()) {
80 // TODO(rockot): Clean this up once renderer shutdown sequence is fixed. 80 // TODO(rockot): Clean this up once renderer shutdown sequence is fixed.
81 return; 81 return;
82 } 82 }
83 83
84 m_sensorProvider.reset(); 84 m_sensorProvider.reset();
85 for (SensorProxy* sensor : m_sensorProxies) 85 for (SensorProxy* sensor : m_sensorProxies)
86 sensor->handleSensorError(); 86 sensor->handleSensorError();
87 } 87 }
88 88
89 } // namespace blink 89 } // 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