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) {
case TaskType::FileReading:
case TaskType::DatabaseAccess:
case TaskType::Presentation:
case TaskType::Sensor:
case TaskType::Timer:
case TaskType::Internal:
case TaskType::Unspecified:
......
......@@ -36,6 +36,7 @@ enum class TaskType : unsigned {
FileReading,
DatabaseAccess,
Presentation,
Sensor,
// 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
......
......@@ -7,6 +7,7 @@
#include "core/dom/Document.h"
#include "core/dom/ExceptionCode.h"
#include "core/dom/ExecutionContextTask.h"
#include "core/dom/TaskRunnerHelper.h"
#include "core/inspector/ConsoleMessage.h"
#include "device/generic_sensor/public/interfaces/sensor.mojom-blink.h"
#include "modules/sensor/SensorErrorEvent.h"
......@@ -265,7 +266,7 @@ void Sensor::onSensorUpdateNotification() {
if (getExecutionContext() &&
m_sensorProxy->sensorReading()->isReadingUpdated(m_storedData)) {
getExecutionContext()->postTask(
BLINK_FROM_HERE,
TaskType::Sensor, BLINK_FROM_HERE,
createSameThreadTask(&Sensor::notifySensorReadingChanged,
wrapWeakPersistent(this)));
}
......@@ -280,8 +281,9 @@ void Sensor::updateState(Sensor::SensorState newState) {
if (newState == SensorState::Activated && getExecutionContext()) {
DCHECK_EQ(SensorState::Activating, m_state);
getExecutionContext()->postTask(
BLINK_FROM_HERE, createSameThreadTask(&Sensor::notifyOnActivate,
wrapWeakPersistent(this)));
TaskType::Sensor, BLINK_FROM_HERE,
createSameThreadTask(&Sensor::notifyOnActivate,
wrapWeakPersistent(this)));
}
m_state = newState;
......@@ -295,7 +297,7 @@ void Sensor::reportError(ExceptionCode code,
auto error =
DOMException::create(code, sanitizedMessage, unsanitizedMessage);
getExecutionContext()->postTask(
BLINK_FROM_HERE,
TaskType::Sensor, BLINK_FROM_HERE,
createSameThreadTask(&Sensor::notifyError, wrapWeakPersistent(this),
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