Index: third_party/WebKit/Source/modules/sensor/SensorProviderProxy.cpp |
diff --git a/third_party/WebKit/Source/modules/sensor/SensorProviderProxy.cpp b/third_party/WebKit/Source/modules/sensor/SensorProviderProxy.cpp |
index b2309114253196c350bd7826deba6e89434ab4e1..de85ce72ad14a2a4948e843ec87c2053d6c1931c 100644 |
--- a/third_party/WebKit/Source/modules/sensor/SensorProviderProxy.cpp |
+++ b/third_party/WebKit/Source/modules/sensor/SensorProviderProxy.cpp |
@@ -14,6 +14,13 @@ namespace blink { |
// SensorProviderProxy |
SensorProviderProxy::SensorProviderProxy(LocalFrame* frame) { |
+ initializeSensorProviderIfNeeded(frame); |
+} |
+ |
+void SensorProviderProxy::initializeSensorProviderIfNeeded(LocalFrame* frame) { |
+ if (m_sensorProvider) |
+ return; |
+ |
frame->interfaceProvider()->getInterface(mojo::GetProxy(&m_sensorProvider)); |
m_sensorProvider.set_connection_error_handler(convertToBaseCallback( |
WTF::bind(&SensorProviderProxy::onSensorProviderConnectionError, |
@@ -31,6 +38,8 @@ SensorProviderProxy* SensorProviderProxy::from(LocalFrame* frame) { |
if (!result) { |
result = new SensorProviderProxy(frame); |
Supplement<LocalFrame>::provideTo(*frame, supplementName(), result); |
+ } else { |
+ result->initializeSensorProviderIfNeeded(frame); |
Mikhail
2016/11/28 10:42:51
maybe split methods, like "isInitialized() const"
shalamov
2016/11/28 12:50:54
Done.
|
} |
return result; |
} |
@@ -66,6 +75,11 @@ SensorProxy* SensorProviderProxy::getSensorProxy( |
return nullptr; |
} |
+device::mojom::blink::SensorProvider* SensorProviderProxy::getSensorProvider() |
Mikhail
2016/11/28 10:42:51
why move it here (and rename)? IMO it's fine to ke
shalamov
2016/11/28 12:50:54
Wanted to make lazy getter, but then noticed that
|
+ const { |
+ return m_sensorProvider.get(); |
+} |
+ |
void SensorProviderProxy::onSensorProviderConnectionError() { |
if (!Platform::current()) { |
// TODO(rockot): Clean this up once renderer shutdown sequence is fixed. |