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

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

Issue 2614143002: Use a new Supplement constructor for LocalFrame's supplements (Closed)
Patch Set: Created 3 years, 11 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 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 603e3e2bbdd84456e0bba6394a2bfadaeaf11d45..911c21cf7704f5c1a87d93859aa4da91a8f19de3 100644
--- a/third_party/WebKit/Source/modules/sensor/SensorProviderProxy.cpp
+++ b/third_party/WebKit/Source/modules/sensor/SensorProviderProxy.cpp
@@ -13,12 +13,12 @@
namespace blink {
// SensorProviderProxy
-SensorProviderProxy::SensorProviderProxy(LocalFrame* frame) {
- initialize(frame);
haraken 2017/01/06 12:46:55 This is not needed because it's called at line 43.
-}
+SensorProviderProxy::SensorProviderProxy(LocalFrame& frame)
+ : Supplement<LocalFrame>(frame) {}
-void SensorProviderProxy::initialize(LocalFrame* frame) {
- DCHECK(!isInitialized());
+void SensorProviderProxy::initializeIfNeeded(LocalFrame* frame) {
+ if (isInitialized())
+ return;
frame->interfaceProvider()->getInterface(
mojo::MakeRequest(&m_sensorProvider));
@@ -37,13 +37,10 @@ SensorProviderProxy* SensorProviderProxy::from(LocalFrame* frame) {
SensorProviderProxy* providerProxy = static_cast<SensorProviderProxy*>(
Supplement<LocalFrame>::from(*frame, supplementName()));
if (!providerProxy) {
- providerProxy = new SensorProviderProxy(frame);
+ providerProxy = new SensorProviderProxy(*frame);
Supplement<LocalFrame>::provideTo(*frame, supplementName(), providerProxy);
}
-
- if (!providerProxy->isInitialized())
- providerProxy->initialize(frame);
-
+ providerProxy->initializeIfNeeded(frame);
return providerProxy;
}

Powered by Google App Engine
This is Rietveld 408576698