Chromium Code Reviews| Index: third_party/WebKit/Source/modules/remoteplayback/RemotePlayback.cpp |
| diff --git a/third_party/WebKit/Source/modules/remoteplayback/RemotePlayback.cpp b/third_party/WebKit/Source/modules/remoteplayback/RemotePlayback.cpp |
| index f16fb0eea9dbcc423b02d6c46bc693933f981984..6f7add59ffa78addf99cbdfaea10d3277cfa9861 100644 |
| --- a/third_party/WebKit/Source/modules/remoteplayback/RemotePlayback.cpp |
| +++ b/third_party/WebKit/Source/modules/remoteplayback/RemotePlayback.cpp |
| @@ -9,10 +9,10 @@ |
| #include "core/HTMLNames.h" |
| #include "core/dom/DOMException.h" |
| #include "core/dom/Document.h" |
| -#include "core/dom/ExecutionContextTask.h" |
| #include "core/dom/TaskRunnerHelper.h" |
| #include "core/events/Event.h" |
| #include "core/html/HTMLMediaElement.h" |
| +#include "core/inspector/InspectorInstrumentation.h" |
| #include "modules/EventTargetModules.h" |
| #include "platform/MemoryCoordinator.h" |
| #include "platform/UserGestureIndicator.h" |
| @@ -61,6 +61,13 @@ ExecutionContext* RemotePlayback::getExecutionContext() const { |
| return &m_mediaElement->document(); |
| } |
| +static void runNotifyInitialAvailabilityTask( |
|
nhiroki
2017/02/17 03:47:15
nit: Can you move this into the anonymous namespac
yuryu
2017/02/17 05:14:33
Done.
|
| + ExecutionContext* context, |
| + std::unique_ptr<WTF::Closure> task) { |
| + InspectorInstrumentation::AsyncTask asyncTask(context, task.get()); |
| + (*task)(); |
| +} |
| + |
| ScriptPromise RemotePlayback::watchAvailability( |
| ScriptState* scriptState, |
| RemotePlaybackAvailabilityCallback* callback) { |
| @@ -90,11 +97,18 @@ ScriptPromise RemotePlayback::watchAvailability( |
| .isNewEntry); |
| // Report the current availability via the callback. |
| - getExecutionContext()->postTask( |
| - TaskType::MediaElementEvent, BLINK_FROM_HERE, |
| - createSameThreadTask(&RemotePlayback::notifyInitialAvailability, |
| - wrapPersistent(this), id), |
| - "watchAvailabilityCallback"); |
| + // TODO(yuryu): Wrapping notifyInitialAvailability with WTF::Closure as |
| + // InspectorInstrumentation requires a globally unique pointer to track tasks. |
| + // We can remove the wrapper if InspectorInstrumentation returns a task id. |
| + std::unique_ptr<WTF::Closure> task = WTF::bind( |
| + &RemotePlayback::notifyInitialAvailability, wrapPersistent(this), id); |
| + InspectorInstrumentation::asyncTaskScheduled( |
| + getExecutionContext(), "watchAvailabilityCallback", task.get()); |
| + TaskRunnerHelper::get(TaskType::MediaElementEvent, getExecutionContext()) |
| + ->postTask(BLINK_FROM_HERE, |
| + WTF::bind(runNotifyInitialAvailabilityTask, |
| + wrapPersistent(getExecutionContext()), |
| + WTF::passed(std::move(task)))); |
| // TODO(avayvod): Currently the availability is tracked for each media element |
| // as soon as it's created, we probably want to limit that to when the |