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

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

Issue 2472403002: [Sensors] Align sensor reading attribute implementation with the specification (Closed)
Patch Set: Comments from Tim 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 5039dbab7b6c718112a0ef01d3ed814a7f104de9..243c8f567abd3b83ac192d914e82462333631f7b 100644
--- a/third_party/WebKit/Source/modules/sensor/SensorProviderProxy.cpp
+++ b/third_party/WebKit/Source/modules/sensor/SensorProviderProxy.cpp
@@ -5,6 +5,7 @@
#include "modules/sensor/SensorProviderProxy.h"
#include "modules/sensor/SensorProxy.h"
+#include "modules/sensor/SensorReading.h"
#include "platform/mojo/MojoHelper.h"
#include "public/platform/InterfaceProvider.h"
#include "public/platform/Platform.h"
@@ -41,7 +42,18 @@ DEFINE_TRACE(SensorProviderProxy) {
Supplement<LocalFrame>::trace(visitor);
}
-SensorProxy* SensorProviderProxy::getOrCreateSensor(
+SensorProxy* SensorProviderProxy::createSensor(
+ device::mojom::blink::SensorType type,
+ std::unique_ptr<SensorReadingFactory> readingFactory) {
+ DCHECK(!getSensor(type));
+
+ SensorProxy* sensor = new SensorProxy(type, this, std::move(readingFactory));
+ m_sensors.add(sensor);
+
+ return sensor;
+}
+
+SensorProxy* SensorProviderProxy::getSensor(
device::mojom::blink::SensorType type) {
for (SensorProxy* sensor : m_sensors) {
// TODO(Mikhail) : Hash sensors by type for efficiency.
@@ -49,10 +61,7 @@ SensorProxy* SensorProviderProxy::getOrCreateSensor(
return sensor;
}
- SensorProxy* sensor = new SensorProxy(type, this);
- m_sensors.add(sensor);
-
- return sensor;
+ return nullptr;
}
void SensorProviderProxy::onSensorProviderConnectionError() {
« 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