| OLD | NEW |
| 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/remoteplayback/RemotePlayback.h" | 5 #include "modules/remoteplayback/RemotePlayback.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/ScriptPromiseResolver.h" | 7 #include "bindings/core/v8/ScriptPromiseResolver.h" |
| 8 #include "bindings/modules/v8/RemotePlaybackAvailabilityCallback.h" | 8 #include "bindings/modules/v8/RemotePlaybackAvailabilityCallback.h" |
| 9 #include "core/HTMLNames.h" | 9 #include "core/HTMLNames.h" |
| 10 #include "core/dom/DOMException.h" | 10 #include "core/dom/DOMException.h" |
| 11 #include "core/dom/Document.h" | 11 #include "core/dom/Document.h" |
| 12 #include "core/dom/ExecutionContextTask.h" | 12 #include "core/dom/ExecutionContextTask.h" |
| 13 #include "core/dom/TaskRunnerHelper.h" |
| 13 #include "core/events/Event.h" | 14 #include "core/events/Event.h" |
| 14 #include "core/html/HTMLMediaElement.h" | 15 #include "core/html/HTMLMediaElement.h" |
| 15 #include "modules/EventTargetModules.h" | 16 #include "modules/EventTargetModules.h" |
| 16 #include "platform/MemoryCoordinator.h" | 17 #include "platform/MemoryCoordinator.h" |
| 17 #include "platform/UserGestureIndicator.h" | 18 #include "platform/UserGestureIndicator.h" |
| 18 | 19 |
| 19 namespace blink { | 20 namespace blink { |
| 20 | 21 |
| 21 namespace { | 22 namespace { |
| 22 | 23 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 int id; | 83 int id; |
| 83 do { | 84 do { |
| 84 id = getExecutionContext()->circularSequentialID(); | 85 id = getExecutionContext()->circularSequentialID(); |
| 85 } while (!m_availabilityCallbacks | 86 } while (!m_availabilityCallbacks |
| 86 .add(id, TraceWrapperMember<RemotePlaybackAvailabilityCallback>( | 87 .add(id, TraceWrapperMember<RemotePlaybackAvailabilityCallback>( |
| 87 this, callback)) | 88 this, callback)) |
| 88 .isNewEntry); | 89 .isNewEntry); |
| 89 | 90 |
| 90 // Report the current availability via the callback. | 91 // Report the current availability via the callback. |
| 91 getExecutionContext()->postTask( | 92 getExecutionContext()->postTask( |
| 92 BLINK_FROM_HERE, | 93 TaskType::MediaElementEvent, BLINK_FROM_HERE, |
| 93 createSameThreadTask(&RemotePlayback::notifyInitialAvailability, | 94 createSameThreadTask(&RemotePlayback::notifyInitialAvailability, |
| 94 wrapPersistent(this), id), | 95 wrapPersistent(this), id), |
| 95 "watchAvailabilityCallback"); | 96 "watchAvailabilityCallback"); |
| 96 | 97 |
| 97 // TODO(avayvod): Currently the availability is tracked for each media element | 98 // TODO(avayvod): Currently the availability is tracked for each media element |
| 98 // as soon as it's created, we probably want to limit that to when the | 99 // as soon as it's created, we probably want to limit that to when the |
| 99 // page/element is visible (see https://crbug.com/597281) and has default | 100 // page/element is visible (see https://crbug.com/597281) and has default |
| 100 // controls. If there are no default controls, we should also start tracking | 101 // controls. If there are no default controls, we should also start tracking |
| 101 // availability on demand meaning the Promise returned by watchAvailability() | 102 // availability on demand meaning the Promise returned by watchAvailability() |
| 102 // will be resolved asynchronously. | 103 // will be resolved asynchronously. |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 } | 307 } |
| 307 | 308 |
| 308 DEFINE_TRACE_WRAPPERS(RemotePlayback) { | 309 DEFINE_TRACE_WRAPPERS(RemotePlayback) { |
| 309 for (auto callback : m_availabilityCallbacks.values()) { | 310 for (auto callback : m_availabilityCallbacks.values()) { |
| 310 visitor->traceWrappers(callback); | 311 visitor->traceWrappers(callback); |
| 311 } | 312 } |
| 312 EventTargetWithInlineData::traceWrappers(visitor); | 313 EventTargetWithInlineData::traceWrappers(visitor); |
| 313 } | 314 } |
| 314 | 315 |
| 315 } // namespace blink | 316 } // namespace blink |
| OLD | NEW |