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

Side by Side Diff: third_party/WebKit/Source/modules/sensor/Sensor.cpp

Issue 2644873002: [Sensors] Fix reading updates after page refresh (Closed)
Patch Set: Comments from haraken@. Rebased. Created 3 years, 10 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 unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/modules/sensor/SensorProviderProxy.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "modules/sensor/Sensor.h" 5 #include "modules/sensor/Sensor.h"
6 6
7 #include "core/dom/Document.h" 7 #include "core/dom/Document.h"
8 #include "core/dom/ExceptionCode.h" 8 #include "core/dom/ExceptionCode.h"
9 #include "core/dom/ExecutionContextTask.h" 9 #include "core/dom/ExecutionContextTask.h"
10 #include "core/dom/TaskRunnerHelper.h" 10 #include "core/dom/TaskRunnerHelper.h"
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 return; 157 return;
158 158
159 Document* document = toDocument(getExecutionContext()); 159 Document* document = toDocument(getExecutionContext());
160 if (!document || !document->frame()) 160 if (!document || !document->frame())
161 return; 161 return;
162 162
163 auto provider = SensorProviderProxy::from(document->frame()); 163 auto provider = SensorProviderProxy::from(document->frame());
164 m_sensorProxy = provider->getSensorProxy(m_type); 164 m_sensorProxy = provider->getSensorProxy(m_type);
165 165
166 if (!m_sensorProxy) { 166 if (!m_sensorProxy) {
167 m_sensorProxy = provider->createSensorProxy(m_type, document, 167 m_sensorProxy = provider->createSensorProxy(m_type, document->page(),
168 createSensorReadingFactory()); 168 createSensorReadingFactory());
169 } 169 }
170 } 170 }
171 171
172 void Sensor::contextDestroyed(ExecutionContext*) { 172 void Sensor::contextDestroyed(ExecutionContext*) {
173 if (m_state == Sensor::SensorState::Activated || 173 if (m_state == Sensor::SensorState::Activated ||
174 m_state == Sensor::SensorState::Activating) 174 m_state == Sensor::SensorState::Activating)
175 stopListening(); 175 stopListening();
176 } 176 }
177 177
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 void Sensor::notifyOnActivate() { 294 void Sensor::notifyOnActivate() {
295 dispatchEvent(Event::create(EventTypeNames::activate)); 295 dispatchEvent(Event::create(EventTypeNames::activate));
296 } 296 }
297 297
298 void Sensor::notifyError(DOMException* error) { 298 void Sensor::notifyError(DOMException* error) {
299 dispatchEvent( 299 dispatchEvent(
300 SensorErrorEvent::create(EventTypeNames::error, std::move(error))); 300 SensorErrorEvent::create(EventTypeNames::error, std::move(error)));
301 } 301 }
302 302
303 } // namespace blink 303 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/modules/sensor/SensorProviderProxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698