Commit 605278fc authored by tzik's avatar tzik Committed by Commit bot

Specify TaskType of posted Task explicitly in Sensor API

The spec specifies its own Sensor task source.
https://w3c.github.io/sensors/#the-sensor-interface

BUG=624696

Review-Url: https://codereview.chromium.org/2587733002
Cr-Commit-Position: refs/heads/master@{#439430}
parent d48f4812
...@@ -30,6 +30,7 @@ WebTaskRunner* TaskRunnerHelper::get(TaskType type, LocalFrame* frame) { ...@@ -30,6 +30,7 @@ WebTaskRunner* TaskRunnerHelper::get(TaskType type, LocalFrame* frame) {
case TaskType::FileReading: case TaskType::FileReading:
case TaskType::DatabaseAccess: case TaskType::DatabaseAccess:
case TaskType::Presentation: case TaskType::Presentation:
case TaskType::Sensor:
case TaskType::Timer: case TaskType::Timer:
case TaskType::Internal: case TaskType::Internal:
case TaskType::Unspecified: case TaskType::Unspecified:
......
...@@ -36,6 +36,7 @@ enum class TaskType : unsigned { ...@@ -36,6 +36,7 @@ enum class TaskType : unsigned {
FileReading, FileReading,
DatabaseAccess, DatabaseAccess,
Presentation, Presentation,
Sensor,
// Other internal tasks that cannot fit any of the above task runners // Other internal tasks that cannot fit any of the above task runners
// can be posted here, but the usage is not encouraged. The task runner // can be posted here, but the usage is not encouraged. The task runner
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "core/dom/Document.h" #include "core/dom/Document.h"
#include "core/dom/ExceptionCode.h" #include "core/dom/ExceptionCode.h"
#include "core/dom/ExecutionContextTask.h" #include "core/dom/ExecutionContextTask.h"
#include "core/dom/TaskRunnerHelper.h"
#include "core/inspector/ConsoleMessage.h" #include "core/inspector/ConsoleMessage.h"
#include "device/generic_sensor/public/interfaces/sensor.mojom-blink.h" #include "device/generic_sensor/public/interfaces/sensor.mojom-blink.h"
#include "modules/sensor/SensorErrorEvent.h" #include "modules/sensor/SensorErrorEvent.h"
...@@ -265,7 +266,7 @@ void Sensor::onSensorUpdateNotification() { ...@@ -265,7 +266,7 @@ void Sensor::onSensorUpdateNotification() {
if (getExecutionContext() && if (getExecutionContext() &&
m_sensorProxy->sensorReading()->isReadingUpdated(m_storedData)) { m_sensorProxy->sensorReading()->isReadingUpdated(m_storedData)) {
getExecutionContext()->postTask( getExecutionContext()->postTask(
BLINK_FROM_HERE, TaskType::Sensor, BLINK_FROM_HERE,
createSameThreadTask(&Sensor::notifySensorReadingChanged, createSameThreadTask(&Sensor::notifySensorReadingChanged,
wrapWeakPersistent(this))); wrapWeakPersistent(this)));
} }
...@@ -280,7 +281,8 @@ void Sensor::updateState(Sensor::SensorState newState) { ...@@ -280,7 +281,8 @@ void Sensor::updateState(Sensor::SensorState newState) {
if (newState == SensorState::Activated && getExecutionContext()) { if (newState == SensorState::Activated && getExecutionContext()) {
DCHECK_EQ(SensorState::Activating, m_state); DCHECK_EQ(SensorState::Activating, m_state);
getExecutionContext()->postTask( getExecutionContext()->postTask(
BLINK_FROM_HERE, createSameThreadTask(&Sensor::notifyOnActivate, TaskType::Sensor, BLINK_FROM_HERE,
createSameThreadTask(&Sensor::notifyOnActivate,
wrapWeakPersistent(this))); wrapWeakPersistent(this)));
} }
...@@ -295,7 +297,7 @@ void Sensor::reportError(ExceptionCode code, ...@@ -295,7 +297,7 @@ void Sensor::reportError(ExceptionCode code,
auto error = auto error =
DOMException::create(code, sanitizedMessage, unsanitizedMessage); DOMException::create(code, sanitizedMessage, unsanitizedMessage);
getExecutionContext()->postTask( getExecutionContext()->postTask(
BLINK_FROM_HERE, TaskType::Sensor, BLINK_FROM_HERE,
createSameThreadTask(&Sensor::notifyError, wrapWeakPersistent(this), createSameThreadTask(&Sensor::notifyError, wrapWeakPersistent(this),
wrapPersistent(error))); wrapPersistent(error)));
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment