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

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

Issue 2330943002: [Sensors] Handle default sensor configuration (Closed)
Patch Set: Rebased Created 4 years, 3 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
« no previous file with comments | « third_party/WebKit/Source/modules/sensor/SensorProxy.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/modules/sensor/SensorProxy.cpp
diff --git a/third_party/WebKit/Source/modules/sensor/SensorProxy.cpp b/third_party/WebKit/Source/modules/sensor/SensorProxy.cpp
index 0c14fb3e9cdc5eee8592b3ac471ead37735f1518..973a29d61d5fd098d033fe52cb479f496e1a2b8c 100644
--- a/third_party/WebKit/Source/modules/sensor/SensorProxy.cpp
+++ b/third_party/WebKit/Source/modules/sensor/SensorProxy.cpp
@@ -97,6 +97,12 @@ void SensorProxy::resume()
m_suspended = false;
}
+const device::mojom::blink::SensorConfiguration* SensorProxy::defaultConfig() const
+{
+ DCHECK(isInitialized());
+ return m_defaultConfig.get();
+}
+
void SensorProxy::updateInternalReading()
{
DCHECK(isInitialized());
@@ -119,28 +125,38 @@ void SensorProxy::handleSensorError()
{
m_state = Uninitialized;
m_sensor.reset();
+ m_sharedBuffer.reset();
+ m_sharedBufferHandle.reset();
+ m_defaultConfig.reset();
+ m_clientBinding.Close();
+
for (Observer* observer : m_observers)
observer->onSensorError();
}
-void SensorProxy::onSensorCreated(SensorReadBufferPtr buffer, SensorClientRequest clientRequest)
+void SensorProxy::onSensorCreated(SensorInitParamsPtr params, SensorClientRequest clientRequest)
{
DCHECK_EQ(Initializing, m_state);
- if (!buffer) {
+ if (!params) {
handleSensorError();
return;
}
- DCHECK_EQ(0u, buffer->offset % SensorReadBuffer::kReadBufferSize);
+ DCHECK_EQ(0u, params->buffer_offset % SensorInitParams::kReadBufferSize);
- m_mode = buffer->mode;
+ m_mode = params->mode;
+ m_defaultConfig = std::move(params->default_configuration);
+ if (!m_defaultConfig) {
+ handleSensorError();
+ return;
+ }
DCHECK(m_sensor.is_bound());
m_clientBinding.Bind(std::move(clientRequest));
- m_sharedBufferHandle = std::move(buffer->memory);
+ m_sharedBufferHandle = std::move(params->memory);
DCHECK(!m_sharedBuffer);
- m_sharedBuffer = m_sharedBufferHandle->MapAtOffset(buffer->offset, SensorReadBuffer::kReadBufferSize);
+ m_sharedBuffer = m_sharedBufferHandle->MapAtOffset(SensorInitParams::kReadBufferSize, params->buffer_offset);
if (!m_sharedBuffer) {
handleSensorError();
« no previous file with comments | « third_party/WebKit/Source/modules/sensor/SensorProxy.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698