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

Unified Diff: third_party/WebKit/Source/modules/sensor/SensorProviderProxy.cpp

Issue 2529343002: [sensors] Fix flakiness in generic sensors tests (Closed)
Patch Set: Fixes for review comments from Reilly Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
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..be951e0af2bab2aa63f5226ac4304dd8ceb13c58 100644
--- a/third_party/WebKit/Source/modules/sensor/SensorProviderProxy.cpp
+++ b/third_party/WebKit/Source/modules/sensor/SensorProviderProxy.cpp
@@ -14,6 +14,12 @@ namespace blink {
// SensorProviderProxy
SensorProviderProxy::SensorProviderProxy(LocalFrame* frame) {
+ initialize(frame);
+}
+
+void SensorProviderProxy::initialize(LocalFrame* frame) {
+ DCHECK(!isInitialized());
+
frame->interfaceProvider()->getInterface(mojo::GetProxy(&m_sensorProvider));
m_sensorProvider.set_connection_error_handler(convertToBaseCallback(
WTF::bind(&SensorProviderProxy::onSensorProviderConnectionError,
@@ -24,15 +30,20 @@ const char* SensorProviderProxy::supplementName() {
return "SensorProvider";
}
+// static
SensorProviderProxy* SensorProviderProxy::from(LocalFrame* frame) {
DCHECK(frame);
- SensorProviderProxy* result = static_cast<SensorProviderProxy*>(
+ SensorProviderProxy* providerProxy = static_cast<SensorProviderProxy*>(
Supplement<LocalFrame>::from(*frame, supplementName()));
- if (!result) {
- result = new SensorProviderProxy(frame);
- Supplement<LocalFrame>::provideTo(*frame, supplementName(), result);
+ if (!providerProxy) {
+ providerProxy = new SensorProviderProxy(frame);
+ Supplement<LocalFrame>::provideTo(*frame, supplementName(), providerProxy);
}
- return result;
+
+ if (!providerProxy->isInitialized())
+ providerProxy->initialize(frame);
+
+ return providerProxy;
}
SensorProviderProxy::~SensorProviderProxy() {}

Powered by Google App Engine
This is Rietveld 408576698