Commit c077cf68 authored by Hajime Hoshi's avatar Hajime Hoshi Committed by Commit Bot

Merge MediaElementEventQueue into EventQueueImpl

Design Doc: https://docs.google.com/document/d/1BBtBPTarOF4NeVKSWZe3XaDHo4yTGhdlqYm35yVzPs4/edit#

Bug: 846618
Change-Id: I15903843b0377c45db9caf3d54914ed942caf361
Reviewed-on: https://chromium-review.googlesource.com/1098742
Commit-Queue: Hajime Hoshi <hajimehoshi@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Reviewed-by: default avatarAlexander Timin <altimin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#568767}
parent 7787593d
...@@ -136,8 +136,6 @@ blink_core_sources("dom") { ...@@ -136,8 +136,6 @@ blink_core_sources("dom") {
"events/event_target.h", "events/event_target.h",
"events/event_target_impl.cc", "events/event_target_impl.cc",
"events/event_target_impl.h", "events/event_target_impl.h",
"events/media_element_event_queue.cc",
"events/media_element_event_queue.h",
"events/node_event_context.cc", "events/node_event_context.cc",
"events/node_event_context.h", "events/node_event_context.h",
"events/scoped_event_queue.cc", "events/scoped_event_queue.cc",
...@@ -306,6 +304,7 @@ blink_core_sources("dom") { ...@@ -306,6 +304,7 @@ blink_core_sources("dom") {
"//services/metrics/public/cpp:metrics_cpp", "//services/metrics/public/cpp:metrics_cpp",
"//services/metrics/public/cpp:ukm_builders", "//services/metrics/public/cpp:ukm_builders",
"//services/metrics/public/mojom", "//services/metrics/public/mojom",
# Needed to generate add_event_listener_options.h # Needed to generate add_event_listener_options.h
"//third_party/blink/renderer/bindings/core/v8:bindings_core_impl_generated", "//third_party/blink/renderer/bindings/core/v8:bindings_core_impl_generated",
] ]
......
...@@ -43,6 +43,7 @@ class CORE_EXPORT EventQueue : public GarbageCollectedFinalized<EventQueue> { ...@@ -43,6 +43,7 @@ class CORE_EXPORT EventQueue : public GarbageCollectedFinalized<EventQueue> {
virtual void Trace(blink::Visitor* visitor) {} virtual void Trace(blink::Visitor* visitor) {}
virtual bool EnqueueEvent(const base::Location&, Event*) = 0; virtual bool EnqueueEvent(const base::Location&, Event*) = 0;
virtual void CancelAllEvents() = 0; virtual void CancelAllEvents() = 0;
virtual bool HasPendingEvents() const = 0;
}; };
} // namespace blink } // namespace blink
......
...@@ -99,14 +99,11 @@ void EventQueueImpl::DispatchEvent(Event* event) { ...@@ -99,14 +99,11 @@ void EventQueueImpl::DispatchEvent(Event* event) {
DCHECK(GetExecutionContext()); DCHECK(GetExecutionContext());
probe::AsyncTask async_task(GetExecutionContext(), event); probe::AsyncTask async_task(GetExecutionContext(), event);
// TODO(hajimehoshi): Don't use |event->target()| here. Assuming the taget EventTarget* target = event->target();
// exists here is weird since event target is set later at if (LocalDOMWindow* window = target->ToLocalDOMWindow())
// |EventTarget::DispatchEvent|.
EventTarget* event_target = event->target();
if (LocalDOMWindow* window = event_target->ToLocalDOMWindow())
window->DispatchEvent(event, nullptr); window->DispatchEvent(event, nullptr);
else else
event_target->DispatchEvent(event); target->DispatchEvent(event);
} }
void EventQueueImpl::ContextDestroyed(ExecutionContext* context) { void EventQueueImpl::ContextDestroyed(ExecutionContext* context) {
...@@ -124,4 +121,8 @@ void EventQueueImpl::DoCancelAllEvents(ExecutionContext* context) { ...@@ -124,4 +121,8 @@ void EventQueueImpl::DoCancelAllEvents(ExecutionContext* context) {
queued_events_.clear(); queued_events_.clear();
} }
bool EventQueueImpl::HasPendingEvents() const {
return queued_events_.size() > 0;
}
} // namespace blink } // namespace blink
...@@ -51,6 +51,7 @@ class CORE_EXPORT EventQueueImpl final : public EventQueue, ...@@ -51,6 +51,7 @@ class CORE_EXPORT EventQueueImpl final : public EventQueue,
void Trace(blink::Visitor*) override; void Trace(blink::Visitor*) override;
bool EnqueueEvent(const base::Location&, Event*) override; bool EnqueueEvent(const base::Location&, Event*) override;
void CancelAllEvents() override; void CancelAllEvents() override;
bool HasPendingEvents() const override;
private: private:
EventQueueImpl(ExecutionContext*, TaskType); EventQueueImpl(ExecutionContext*, TaskType);
......
/*
* Copyright (C) 2012 Victor Carbune (victor@rosedu.org)
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "third_party/blink/renderer/core/dom/events/media_element_event_queue.h"
#include "third_party/blink/public/platform/task_type.h"
#include "third_party/blink/renderer/core/dom/events/event.h"
#include "third_party/blink/renderer/core/probe/core_probes.h"
#include "third_party/blink/renderer/platform/instrumentation/tracing/trace_event.h"
namespace blink {
MediaElementEventQueue* MediaElementEventQueue::Create(
ExecutionContext* context) {
return new MediaElementEventQueue(context);
}
MediaElementEventQueue::MediaElementEventQueue(ExecutionContext* context)
: ContextLifecycleObserver(context), is_closed_(false) {
if (!GetExecutionContext())
Close(nullptr);
}
MediaElementEventQueue::~MediaElementEventQueue() = default;
void MediaElementEventQueue::Trace(blink::Visitor* visitor) {
visitor->Trace(pending_events_);
ContextLifecycleObserver::Trace(visitor);
}
bool MediaElementEventQueue::EnqueueEvent(const base::Location& from_here,
Event* event) {
if (is_closed_)
return false;
DCHECK(event->target());
DCHECK(GetExecutionContext());
TRACE_EVENT_ASYNC_BEGIN1("event", "MediaElementEventQueue:enqueueEvent",
event, "type", event->type().Ascii());
probe::AsyncTaskScheduled(GetExecutionContext(), event->type(), event);
pending_events_.insert(event);
GetExecutionContext()
->GetTaskRunner(TaskType::kMediaElementEvent)
->PostTask(FROM_HERE,
WTF::Bind(&MediaElementEventQueue::DispatchEvent,
WrapPersistent(this), WrapPersistent(event)));
return true;
}
bool MediaElementEventQueue::RemoveEvent(Event* event) {
auto found = pending_events_.find(event);
if (found == pending_events_.end())
return false;
pending_events_.erase(found);
return true;
}
void MediaElementEventQueue::DispatchEvent(Event* event) {
if (!RemoveEvent(event))
return;
DCHECK(GetExecutionContext());
CString type(event->type().Ascii());
probe::AsyncTask async_task(GetExecutionContext(), event);
TRACE_EVENT_ASYNC_STEP_INTO1("event", "MediaElementEventQueue:enqueueEvent",
event, "dispatch", "type", type);
event->target()->DispatchEvent(event);
TRACE_EVENT_ASYNC_END1("event", "MediaElementEventQueue:enqueueEvent", event,
"type", type);
}
void MediaElementEventQueue::CancelAllEvents() {
if (!GetExecutionContext()) {
DCHECK(!pending_events_.size());
return;
}
DoCancelAllEvents(GetExecutionContext());
}
bool MediaElementEventQueue::HasPendingEvents() const {
return pending_events_.size() > 0;
}
void MediaElementEventQueue::ContextDestroyed(ExecutionContext* context) {
Close(context);
}
void MediaElementEventQueue::Close(ExecutionContext* context) {
is_closed_ = true;
DoCancelAllEvents(context);
}
void MediaElementEventQueue::DoCancelAllEvents(ExecutionContext* context) {
DCHECK(!pending_events_.size() || context);
for (auto& event : pending_events_) {
TRACE_EVENT_ASYNC_END2("event", "MediaElementEventQueue:enqueueEvent",
event, "type", event->type().Ascii(), "status",
"cancelled");
probe::AsyncTaskCanceled(context, event);
}
pending_events_.clear();
}
} // namespace blink
/*
* Copyright (C) 2012 Victor Carbune (victor@rosedu.org)
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_DOM_EVENTS_MEDIA_ELEMENT_EVENT_QUEUE_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_DOM_EVENTS_MEDIA_ELEMENT_EVENT_QUEUE_H_
#include "base/location.h"
#include "base/memory/scoped_refptr.h"
#include "third_party/blink/renderer/core/core_export.h"
#include "third_party/blink/renderer/core/dom/context_lifecycle_observer.h"
#include "third_party/blink/renderer/core/dom/events/event_target.h"
#include "third_party/blink/renderer/platform/timer.h"
#include "third_party/blink/renderer/platform/wtf/vector.h"
namespace blink {
// Queue for events originating in MediaElement and having
// "media element event" task type according to the spec.
class CORE_EXPORT MediaElementEventQueue final
: public GarbageCollectedFinalized<MediaElementEventQueue>,
public ContextLifecycleObserver {
USING_GARBAGE_COLLECTED_MIXIN(MediaElementEventQueue);
public:
static MediaElementEventQueue* Create(ExecutionContext*);
~MediaElementEventQueue();
void Trace(blink::Visitor*) override;
bool EnqueueEvent(const base::Location&, Event*);
void CancelAllEvents();
bool HasPendingEvents() const;
private:
explicit MediaElementEventQueue(ExecutionContext*);
bool RemoveEvent(Event* event);
void DispatchEvent(Event* event);
void ContextDestroyed(ExecutionContext*) override;
void Close(ExecutionContext*);
void DoCancelAllEvents(ExecutionContext*);
HeapHashSet<Member<Event>> pending_events_;
bool is_closed_;
};
} // namespace blink
#endif
...@@ -52,6 +52,7 @@ ...@@ -52,6 +52,7 @@
#include "third_party/blink/renderer/core/dom/dom_exception.h" #include "third_party/blink/renderer/core/dom/dom_exception.h"
#include "third_party/blink/renderer/core/dom/element_traversal.h" #include "third_party/blink/renderer/core/dom/element_traversal.h"
#include "third_party/blink/renderer/core/dom/events/event.h" #include "third_party/blink/renderer/core/dom/events/event.h"
#include "third_party/blink/renderer/core/dom/events/event_queue_impl.h"
#include "third_party/blink/renderer/core/dom/shadow_root.h" #include "third_party/blink/renderer/core/dom/shadow_root.h"
#include "third_party/blink/renderer/core/frame/csp/content_security_policy.h" #include "third_party/blink/renderer/core/frame/csp/content_security_policy.h"
#include "third_party/blink/renderer/core/frame/local_frame.h" #include "third_party/blink/renderer/core/frame/local_frame.h"
...@@ -464,7 +465,8 @@ HTMLMediaElement::HTMLMediaElement(const QualifiedName& tag_name, ...@@ -464,7 +465,8 @@ HTMLMediaElement::HTMLMediaElement(const QualifiedName& tag_name,
this, this,
&HTMLMediaElement::CheckViewportIntersectionTimerFired), &HTMLMediaElement::CheckViewportIntersectionTimerFired),
played_time_ranges_(), played_time_ranges_(),
async_event_queue_(MediaElementEventQueue::Create(GetExecutionContext())), async_event_queue_(EventQueueImpl::Create(GetExecutionContext(),
TaskType::kMediaElementEvent)),
playback_rate_(1.0f), playback_rate_(1.0f),
default_playback_rate_(1.0f), default_playback_rate_(1.0f),
network_state_(kNetworkEmpty), network_state_(kNetworkEmpty),
......
...@@ -35,7 +35,6 @@ ...@@ -35,7 +35,6 @@
#include "third_party/blink/renderer/bindings/core/v8/active_script_wrappable.h" #include "third_party/blink/renderer/bindings/core/v8/active_script_wrappable.h"
#include "third_party/blink/renderer/bindings/core/v8/script_promise.h" #include "third_party/blink/renderer/bindings/core/v8/script_promise.h"
#include "third_party/blink/renderer/core/core_export.h" #include "third_party/blink/renderer/core/core_export.h"
#include "third_party/blink/renderer/core/dom/events/media_element_event_queue.h"
#include "third_party/blink/renderer/core/dom/pausable_object.h" #include "third_party/blink/renderer/core/dom/pausable_object.h"
#include "third_party/blink/renderer/core/html/html_element.h" #include "third_party/blink/renderer/core/html/html_element.h"
#include "third_party/blink/renderer/core/html/media/media_controls.h" #include "third_party/blink/renderer/core/html/media/media_controls.h"
...@@ -44,6 +43,7 @@ ...@@ -44,6 +43,7 @@
#include "third_party/blink/renderer/platform/bindings/trace_wrapper_member.h" #include "third_party/blink/renderer/platform/bindings/trace_wrapper_member.h"
#include "third_party/blink/renderer/platform/network/mime/mime_type_registry.h" #include "third_party/blink/renderer/platform/network/mime/mime_type_registry.h"
#include "third_party/blink/renderer/platform/supplementable.h" #include "third_party/blink/renderer/platform/supplementable.h"
#include "third_party/blink/renderer/platform/timer.h"
#include "third_party/blink/renderer/platform/web_task_runner.h" #include "third_party/blink/renderer/platform/web_task_runner.h"
namespace cc { namespace cc {
...@@ -60,6 +60,7 @@ class ContentType; ...@@ -60,6 +60,7 @@ class ContentType;
class CueTimeline; class CueTimeline;
class EnumerationHistogram; class EnumerationHistogram;
class Event; class Event;
class EventQueue;
class ExceptionState; class ExceptionState;
class HTMLMediaElementControlsList; class HTMLMediaElementControlsList;
class HTMLMediaSource; class HTMLMediaSource;
...@@ -567,7 +568,7 @@ class CORE_EXPORT HTMLMediaElement ...@@ -567,7 +568,7 @@ class CORE_EXPORT HTMLMediaElement
TaskRunnerTimer<HTMLMediaElement> check_viewport_intersection_timer_; TaskRunnerTimer<HTMLMediaElement> check_viewport_intersection_timer_;
Member<TimeRanges> played_time_ranges_; Member<TimeRanges> played_time_ranges_;
Member<MediaElementEventQueue> async_event_queue_; Member<EventQueue> async_event_queue_;
double playback_rate_; double playback_rate_;
double default_playback_rate_; double default_playback_rate_;
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
#include "third_party/blink/renderer/core/html/track/text_track_list.h" #include "third_party/blink/renderer/core/html/track/text_track_list.h"
#include "third_party/blink/renderer/core/dom/events/media_element_event_queue.h" #include "third_party/blink/renderer/core/dom/events/event_queue_impl.h"
#include "third_party/blink/renderer/core/html/media/html_media_element.h" #include "third_party/blink/renderer/core/html/media/html_media_element.h"
#include "third_party/blink/renderer/core/html/track/inband_text_track.h" #include "third_party/blink/renderer/core/html/track/inband_text_track.h"
#include "third_party/blink/renderer/core/html/track/loadable_text_track.h" #include "third_party/blink/renderer/core/html/track/loadable_text_track.h"
...@@ -37,8 +37,9 @@ namespace blink { ...@@ -37,8 +37,9 @@ namespace blink {
TextTrackList::TextTrackList(HTMLMediaElement* owner) TextTrackList::TextTrackList(HTMLMediaElement* owner)
: owner_(owner), : owner_(owner),
async_event_queue_( async_event_queue_(EventQueueImpl::Create(GetExecutionContext(),
MediaElementEventQueue::Create(GetExecutionContext())) {} TaskType::kMediaElementEvent)) {
}
TextTrackList::~TextTrackList() = default; TextTrackList::~TextTrackList() = default;
......
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
namespace blink { namespace blink {
class MediaElementEventQueue; class EventQueue;
class TextTrack; class TextTrack;
class CORE_EXPORT TextTrackList final : public EventTargetWithInlineData { class CORE_EXPORT TextTrackList final : public EventTargetWithInlineData {
...@@ -87,7 +87,7 @@ class CORE_EXPORT TextTrackList final : public EventTargetWithInlineData { ...@@ -87,7 +87,7 @@ class CORE_EXPORT TextTrackList final : public EventTargetWithInlineData {
Member<HTMLMediaElement> owner_; Member<HTMLMediaElement> owner_;
Member<MediaElementEventQueue> async_event_queue_; Member<EventQueue> async_event_queue_;
HeapVector<TraceWrapperMember<TextTrack>> add_track_tracks_; HeapVector<TraceWrapperMember<TextTrack>> add_track_tracks_;
HeapVector<TraceWrapperMember<TextTrack>> element_tracks_; HeapVector<TraceWrapperMember<TextTrack>> element_tracks_;
......
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
#include "third_party/blink/renderer/bindings/core/v8/script_promise_resolver.h" #include "third_party/blink/renderer/bindings/core/v8/script_promise_resolver.h"
#include "third_party/blink/renderer/core/dom/dom_exception.h" #include "third_party/blink/renderer/core/dom/dom_exception.h"
#include "third_party/blink/renderer/core/dom/events/event.h" #include "third_party/blink/renderer/core/dom/events/event.h"
#include "third_party/blink/renderer/core/dom/events/media_element_event_queue.h" #include "third_party/blink/renderer/core/dom/events/event_queue_impl.h"
#include "third_party/blink/renderer/core/execution_context/execution_context.h" #include "third_party/blink/renderer/core/execution_context/execution_context.h"
#include "third_party/blink/renderer/core/typed_arrays/dom_array_buffer.h" #include "third_party/blink/renderer/core/typed_arrays/dom_array_buffer.h"
#include "third_party/blink/renderer/modules/encryptedmedia/content_decryption_module_result_promise.h" #include "third_party/blink/renderer/modules/encryptedmedia/content_decryption_module_result_promise.h"
...@@ -329,7 +329,8 @@ MediaKeySession::MediaKeySession(ScriptState* script_state, ...@@ -329,7 +329,8 @@ MediaKeySession::MediaKeySession(ScriptState* script_state,
MediaKeys* media_keys, MediaKeys* media_keys,
WebEncryptedMediaSessionType session_type) WebEncryptedMediaSessionType session_type)
: ContextLifecycleObserver(ExecutionContext::From(script_state)), : ContextLifecycleObserver(ExecutionContext::From(script_state)),
async_event_queue_(MediaElementEventQueue::Create(GetExecutionContext())), async_event_queue_(EventQueueImpl::Create(GetExecutionContext(),
TaskType::kMediaElementEvent)),
media_keys_(media_keys), media_keys_(media_keys),
session_type_(session_type), session_type_(session_type),
expiration_(std::numeric_limits<double>::quiet_NaN()), expiration_(std::numeric_limits<double>::quiet_NaN()),
......
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
namespace blink { namespace blink {
class DOMException; class DOMException;
class MediaElementEventQueue; class EventQueue;
class MediaKeys; class MediaKeys;
// References are held by JS only. However, even if all JS references are // References are held by JS only. However, even if all JS references are
...@@ -135,7 +135,7 @@ class MediaKeySession final ...@@ -135,7 +135,7 @@ class MediaKeySession final
void KeysStatusesChange(const WebVector<WebEncryptedMediaKeyInformation>&, void KeysStatusesChange(const WebVector<WebEncryptedMediaKeyInformation>&,
bool has_additional_usable_key) override; bool has_additional_usable_key) override;
Member<MediaElementEventQueue> async_event_queue_; Member<EventQueue> async_event_queue_;
std::unique_ptr<WebContentDecryptionModuleSession> session_; std::unique_ptr<WebContentDecryptionModuleSession> session_;
// Used to determine if MediaKeys is still active. // Used to determine if MediaKeys is still active.
......
...@@ -611,7 +611,6 @@ void IDBRequest::ContextDestroyed(ExecutionContext*) { ...@@ -611,7 +611,6 @@ void IDBRequest::ContextDestroyed(ExecutionContext*) {
transaction_->UnregisterRequest(this); transaction_->UnregisterRequest(this);
} }
event_queue_->CancelAllEvents();
if (source_.IsIDBCursor()) if (source_.IsIDBCursor())
source_.GetAsIDBCursor()->ContextWillBeDestroyed(); source_.GetAsIDBCursor()->ContextWillBeDestroyed();
if (result_) if (result_)
......
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
#include "third_party/blink/public/platform/web_media_source.h" #include "third_party/blink/public/platform/web_media_source.h"
#include "third_party/blink/public/platform/web_source_buffer.h" #include "third_party/blink/public/platform/web_source_buffer.h"
#include "third_party/blink/renderer/core/dom/events/event.h" #include "third_party/blink/renderer/core/dom/events/event.h"
#include "third_party/blink/renderer/core/dom/events/media_element_event_queue.h" #include "third_party/blink/renderer/core/dom/events/event_queue_impl.h"
#include "third_party/blink/renderer/core/frame/deprecation.h" #include "third_party/blink/renderer/core/frame/deprecation.h"
#include "third_party/blink/renderer/core/frame/use_counter.h" #include "third_party/blink/renderer/core/frame/use_counter.h"
#include "third_party/blink/renderer/core/html/media/html_media_element.h" #include "third_party/blink/renderer/core/html/media/html_media_element.h"
...@@ -113,7 +113,8 @@ MediaSource* MediaSource::Create(ExecutionContext* context) { ...@@ -113,7 +113,8 @@ MediaSource* MediaSource::Create(ExecutionContext* context) {
MediaSource::MediaSource(ExecutionContext* context) MediaSource::MediaSource(ExecutionContext* context)
: ContextLifecycleObserver(context), : ContextLifecycleObserver(context),
ready_state_(ClosedKeyword()), ready_state_(ClosedKeyword()),
async_event_queue_(MediaElementEventQueue::Create(context)), async_event_queue_(
EventQueueImpl::Create(context, TaskType::kMediaElementEvent)),
attached_element_(nullptr), attached_element_(nullptr),
source_buffers_(SourceBufferList::Create(GetExecutionContext(), source_buffers_(SourceBufferList::Create(GetExecutionContext(),
async_event_queue_.Get())), async_event_queue_.Get())),
......
...@@ -46,8 +46,8 @@ ...@@ -46,8 +46,8 @@
namespace blink { namespace blink {
class EventQueue;
class ExceptionState; class ExceptionState;
class MediaElementEventQueue;
class WebSourceBuffer; class WebSourceBuffer;
class MediaSource final : public EventTargetWithInlineData, class MediaSource final : public EventTargetWithInlineData,
...@@ -146,7 +146,7 @@ class MediaSource final : public EventTargetWithInlineData, ...@@ -146,7 +146,7 @@ class MediaSource final : public EventTargetWithInlineData,
std::unique_ptr<WebMediaSource> web_media_source_; std::unique_ptr<WebMediaSource> web_media_source_;
AtomicString ready_state_; AtomicString ready_state_;
Member<MediaElementEventQueue> async_event_queue_; Member<EventQueue> async_event_queue_;
WeakMember<HTMLMediaElement> attached_element_; WeakMember<HTMLMediaElement> attached_element_;
Member<SourceBufferList> source_buffers_; Member<SourceBufferList> source_buffers_;
......
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
#include "third_party/blink/public/platform/task_type.h" #include "third_party/blink/public/platform/task_type.h"
#include "third_party/blink/public/platform/web_source_buffer.h" #include "third_party/blink/public/platform/web_source_buffer.h"
#include "third_party/blink/renderer/core/dom/events/event.h" #include "third_party/blink/renderer/core/dom/events/event.h"
#include "third_party/blink/renderer/core/dom/events/media_element_event_queue.h" #include "third_party/blink/renderer/core/dom/events/event_queue_impl.h"
#include "third_party/blink/renderer/core/execution_context/execution_context.h" #include "third_party/blink/renderer/core/execution_context/execution_context.h"
#include "third_party/blink/renderer/core/frame/deprecation.h" #include "third_party/blink/renderer/core/frame/deprecation.h"
#include "third_party/blink/renderer/core/frame/use_counter.h" #include "third_party/blink/renderer/core/frame/use_counter.h"
...@@ -106,7 +106,7 @@ WTF::String WebTimeRangesToString(const WebTimeRanges& ranges) { ...@@ -106,7 +106,7 @@ WTF::String WebTimeRangesToString(const WebTimeRanges& ranges) {
SourceBuffer* SourceBuffer::Create( SourceBuffer* SourceBuffer::Create(
std::unique_ptr<WebSourceBuffer> web_source_buffer, std::unique_ptr<WebSourceBuffer> web_source_buffer,
MediaSource* source, MediaSource* source,
MediaElementEventQueue* async_event_queue) { EventQueue* async_event_queue) {
SourceBuffer* source_buffer = SourceBuffer* source_buffer =
new SourceBuffer(std::move(web_source_buffer), source, async_event_queue); new SourceBuffer(std::move(web_source_buffer), source, async_event_queue);
source_buffer->PauseIfNeeded(); source_buffer->PauseIfNeeded();
...@@ -115,7 +115,7 @@ SourceBuffer* SourceBuffer::Create( ...@@ -115,7 +115,7 @@ SourceBuffer* SourceBuffer::Create(
SourceBuffer::SourceBuffer(std::unique_ptr<WebSourceBuffer> web_source_buffer, SourceBuffer::SourceBuffer(std::unique_ptr<WebSourceBuffer> web_source_buffer,
MediaSource* source, MediaSource* source,
MediaElementEventQueue* async_event_queue) EventQueue* async_event_queue)
: PausableObject(source->GetExecutionContext()), : PausableObject(source->GetExecutionContext()),
web_source_buffer_(std::move(web_source_buffer)), web_source_buffer_(std::move(web_source_buffer)),
source_(source), source_(source),
......
...@@ -47,8 +47,8 @@ namespace blink { ...@@ -47,8 +47,8 @@ namespace blink {
class AudioTrackList; class AudioTrackList;
class DOMArrayBuffer; class DOMArrayBuffer;
class DOMArrayBufferView; class DOMArrayBufferView;
class EventQueue;
class ExceptionState; class ExceptionState;
class MediaElementEventQueue;
class MediaSource; class MediaSource;
class TimeRanges; class TimeRanges;
class VideoTrackList; class VideoTrackList;
...@@ -65,7 +65,7 @@ class SourceBuffer final : public EventTargetWithInlineData, ...@@ -65,7 +65,7 @@ class SourceBuffer final : public EventTargetWithInlineData,
public: public:
static SourceBuffer* Create(std::unique_ptr<WebSourceBuffer>, static SourceBuffer* Create(std::unique_ptr<WebSourceBuffer>,
MediaSource*, MediaSource*,
MediaElementEventQueue*); EventQueue*);
static const AtomicString& SegmentsKeyword(); static const AtomicString& SegmentsKeyword();
static const AtomicString& SequenceKeyword(); static const AtomicString& SequenceKeyword();
...@@ -119,9 +119,7 @@ class SourceBuffer final : public EventTargetWithInlineData, ...@@ -119,9 +119,7 @@ class SourceBuffer final : public EventTargetWithInlineData,
void Trace(blink::Visitor*) override; void Trace(blink::Visitor*) override;
private: private:
SourceBuffer(std::unique_ptr<WebSourceBuffer>, SourceBuffer(std::unique_ptr<WebSourceBuffer>, MediaSource*, EventQueue*);
MediaSource*,
MediaElementEventQueue*);
void Dispose(); void Dispose();
bool IsRemoved() const; bool IsRemoved() const;
...@@ -160,7 +158,7 @@ class SourceBuffer final : public EventTargetWithInlineData, ...@@ -160,7 +158,7 @@ class SourceBuffer final : public EventTargetWithInlineData,
std::unique_ptr<WebSourceBuffer> web_source_buffer_; std::unique_ptr<WebSourceBuffer> web_source_buffer_;
Member<MediaSource> source_; Member<MediaSource> source_;
Member<TrackDefaultList> track_defaults_; Member<TrackDefaultList> track_defaults_;
Member<MediaElementEventQueue> async_event_queue_; Member<EventQueue> async_event_queue_;
AtomicString mode_; AtomicString mode_;
bool updating_; bool updating_;
......
...@@ -30,14 +30,14 @@ ...@@ -30,14 +30,14 @@
#include "third_party/blink/renderer/modules/mediasource/source_buffer_list.h" #include "third_party/blink/renderer/modules/mediasource/source_buffer_list.h"
#include "third_party/blink/renderer/core/dom/events/media_element_event_queue.h" #include "third_party/blink/renderer/core/dom/events/event_queue.h"
#include "third_party/blink/renderer/modules/event_modules.h" #include "third_party/blink/renderer/modules/event_modules.h"
#include "third_party/blink/renderer/modules/mediasource/source_buffer.h" #include "third_party/blink/renderer/modules/mediasource/source_buffer.h"
namespace blink { namespace blink {
SourceBufferList::SourceBufferList(ExecutionContext* context, SourceBufferList::SourceBufferList(ExecutionContext* context,
MediaElementEventQueue* async_event_queue) EventQueue* async_event_queue)
: ContextClient(context), async_event_queue_(async_event_queue) {} : ContextClient(context), async_event_queue_(async_event_queue) {}
SourceBufferList::~SourceBufferList() = default; SourceBufferList::~SourceBufferList() = default;
......
...@@ -37,8 +37,8 @@ ...@@ -37,8 +37,8 @@
namespace blink { namespace blink {
class EventQueue;
class SourceBuffer; class SourceBuffer;
class MediaElementEventQueue;
class SourceBufferList final : public EventTargetWithInlineData, class SourceBufferList final : public EventTargetWithInlineData,
public ContextClient { public ContextClient {
...@@ -47,7 +47,7 @@ class SourceBufferList final : public EventTargetWithInlineData, ...@@ -47,7 +47,7 @@ class SourceBufferList final : public EventTargetWithInlineData,
public: public:
static SourceBufferList* Create(ExecutionContext* context, static SourceBufferList* Create(ExecutionContext* context,
MediaElementEventQueue* async_event_queue) { EventQueue* async_event_queue) {
return new SourceBufferList(context, async_event_queue); return new SourceBufferList(context, async_event_queue);
} }
~SourceBufferList() override; ~SourceBufferList() override;
...@@ -79,11 +79,11 @@ class SourceBufferList final : public EventTargetWithInlineData, ...@@ -79,11 +79,11 @@ class SourceBufferList final : public EventTargetWithInlineData,
void Trace(blink::Visitor*) override; void Trace(blink::Visitor*) override;
private: private:
SourceBufferList(ExecutionContext*, MediaElementEventQueue*); SourceBufferList(ExecutionContext*, EventQueue*);
void ScheduleEvent(const AtomicString&); void ScheduleEvent(const AtomicString&);
Member<MediaElementEventQueue> async_event_queue_; Member<EventQueue> async_event_queue_;
HeapVector<Member<SourceBuffer>> list_; HeapVector<Member<SourceBuffer>> list_;
}; };
......
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