Commit 8d67c678 authored by Matt Wolenetz's avatar Matt Wolenetz Committed by Commit Bot

MSE-in-Workers: Rename MediaSourceAttachmentImpl to SameThreadMediaSourceAttachment

As suggested in previous review [1], this change makes it more clear
that the concrete attachment being renamed here is the same-thread
version, since later changes will introduce a cross-thread version.

[1] https://chromium-review.googlesource.com/c/chromium/src/+/2380571/comment/7c8dd1e5_df26fa86/

BUG=878133

Change-Id: I74c8d1dce6f1d17095f8c71f84628c4a49c52413
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2388435
Commit-Queue: Matthew Wolenetz <wolenetz@chromium.org>
Reviewed-by: default avatarWill Cassella <cassew@google.com>
Cr-Commit-Position: refs/heads/master@{#803635}
parent 55f941e9
...@@ -10,12 +10,12 @@ blink_modules_sources("mediasource") { ...@@ -10,12 +10,12 @@ blink_modules_sources("mediasource") {
"html_video_element_media_source.h", "html_video_element_media_source.h",
"media_source.cc", "media_source.cc",
"media_source.h", "media_source.h",
"media_source_attachment_impl.cc",
"media_source_attachment_impl.h",
"media_source_registry_impl.cc", "media_source_registry_impl.cc",
"media_source_registry_impl.h", "media_source_registry_impl.h",
"media_source_tracer_impl.cc", "media_source_tracer_impl.cc",
"media_source_tracer_impl.h", "media_source_tracer_impl.h",
"same_thread_media_source_attachment.cc",
"same_thread_media_source_attachment.h",
"source_buffer.cc", "source_buffer.cc",
"source_buffer.h", "source_buffer.h",
"source_buffer_list.cc", "source_buffer_list.cc",
......
...@@ -16,9 +16,9 @@ class MediaSource; ...@@ -16,9 +16,9 @@ class MediaSource;
// Concrete MediaSourceTracer that enables an HTMLMediaElement and its attached // Concrete MediaSourceTracer that enables an HTMLMediaElement and its attached
// MediaSource on the same (main) thread to trace into each other. This enables // MediaSource on the same (main) thread to trace into each other. This enables
// garbage collection to automatically detect and collect idle attachments of // garbage collection to automatically detect and collect idle attachments of
// these objects that have no other strong references. // these objects that have no other strong references. Concrete
// A MediaSourceAttachmentImpl uses a MediaSourceTracerImpl as the authoritative // MediaSourceAttachments use MediaSourceTracerImpls as the authoritative
// reference holder for each side of the attachment. // reference holders for each side of the attachments.
class MediaSourceTracerImpl final : public MediaSourceTracer { class MediaSourceTracerImpl final : public MediaSourceTracer {
public: public:
MediaSourceTracerImpl(HTMLMediaElement* media_element, MediaSourceTracerImpl(HTMLMediaElement* media_element,
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "third_party/blink/renderer/modules/mediasource/media_source_attachment_impl.h" #include "third_party/blink/renderer/modules/mediasource/same_thread_media_source_attachment.h"
#include "third_party/blink/renderer/modules/mediasource/media_source.h" #include "third_party/blink/renderer/modules/mediasource/media_source.h"
#include "third_party/blink/renderer/modules/mediasource/media_source_tracer_impl.h" #include "third_party/blink/renderer/modules/mediasource/media_source_tracer_impl.h"
...@@ -24,7 +24,8 @@ blink::MediaSource* GetMediaSource(blink::MediaSourceTracer* tracer) { ...@@ -24,7 +24,8 @@ blink::MediaSource* GetMediaSource(blink::MediaSourceTracer* tracer) {
namespace blink { namespace blink {
MediaSourceAttachmentImpl::MediaSourceAttachmentImpl(MediaSource* media_source) SameThreadMediaSourceAttachment::SameThreadMediaSourceAttachment(
MediaSource* media_source)
: registered_media_source_(media_source) { : registered_media_source_(media_source) {
// This kind of attachment only operates on the main thread. // This kind of attachment only operates on the main thread.
DCHECK(IsMainThread()); DCHECK(IsMainThread());
...@@ -36,9 +37,9 @@ MediaSourceAttachmentImpl::MediaSourceAttachmentImpl(MediaSource* media_source) ...@@ -36,9 +37,9 @@ MediaSourceAttachmentImpl::MediaSourceAttachmentImpl(MediaSource* media_source)
DCHECK(HasOneRef()); DCHECK(HasOneRef());
} }
MediaSourceAttachmentImpl::~MediaSourceAttachmentImpl() = default; SameThreadMediaSourceAttachment::~SameThreadMediaSourceAttachment() = default;
void MediaSourceAttachmentImpl::Unregister() { void SameThreadMediaSourceAttachment::Unregister() {
DVLOG(1) << __func__ << " this=" << this; DVLOG(1) << __func__ << " this=" << this;
// The only expected caller is a MediaSourceRegistryImpl on the main thread. // The only expected caller is a MediaSourceRegistryImpl on the main thread.
...@@ -52,7 +53,8 @@ void MediaSourceAttachmentImpl::Unregister() { ...@@ -52,7 +53,8 @@ void MediaSourceAttachmentImpl::Unregister() {
registered_media_source_ = nullptr; registered_media_source_ = nullptr;
} }
MediaSourceTracer* MediaSourceAttachmentImpl::StartAttachingToMediaElement( MediaSourceTracer*
SameThreadMediaSourceAttachment::StartAttachingToMediaElement(
HTMLMediaElement* element) { HTMLMediaElement* element) {
if (!registered_media_source_) if (!registered_media_source_)
return nullptr; return nullptr;
...@@ -60,42 +62,44 @@ MediaSourceTracer* MediaSourceAttachmentImpl::StartAttachingToMediaElement( ...@@ -60,42 +62,44 @@ MediaSourceTracer* MediaSourceAttachmentImpl::StartAttachingToMediaElement(
return registered_media_source_->StartAttachingToMediaElement(element); return registered_media_source_->StartAttachingToMediaElement(element);
} }
void MediaSourceAttachmentImpl::CompleteAttachingToMediaElement( void SameThreadMediaSourceAttachment::CompleteAttachingToMediaElement(
MediaSourceTracer* tracer, MediaSourceTracer* tracer,
std::unique_ptr<WebMediaSource> web_media_source) { std::unique_ptr<WebMediaSource> web_media_source) {
GetMediaSource(tracer)->CompleteAttachingToMediaElement( GetMediaSource(tracer)->CompleteAttachingToMediaElement(
std::move(web_media_source)); std::move(web_media_source));
} }
void MediaSourceAttachmentImpl::Close(MediaSourceTracer* tracer) { void SameThreadMediaSourceAttachment::Close(MediaSourceTracer* tracer) {
GetMediaSource(tracer)->Close(); GetMediaSource(tracer)->Close();
} }
bool MediaSourceAttachmentImpl::IsClosed(MediaSourceTracer* tracer) const { bool SameThreadMediaSourceAttachment::IsClosed(
MediaSourceTracer* tracer) const {
return GetMediaSource(tracer)->IsClosed(); return GetMediaSource(tracer)->IsClosed();
} }
double MediaSourceAttachmentImpl::duration(MediaSourceTracer* tracer) const { double SameThreadMediaSourceAttachment::duration(
MediaSourceTracer* tracer) const {
return GetMediaSource(tracer)->duration(); return GetMediaSource(tracer)->duration();
} }
WebTimeRanges MediaSourceAttachmentImpl::BufferedInternal( WebTimeRanges SameThreadMediaSourceAttachment::BufferedInternal(
MediaSourceTracer* tracer) const { MediaSourceTracer* tracer) const {
return GetMediaSource(tracer)->BufferedInternal(); return GetMediaSource(tracer)->BufferedInternal();
} }
WebTimeRanges MediaSourceAttachmentImpl::SeekableInternal( WebTimeRanges SameThreadMediaSourceAttachment::SeekableInternal(
MediaSourceTracer* tracer) const { MediaSourceTracer* tracer) const {
return GetMediaSource(tracer)->SeekableInternal(); return GetMediaSource(tracer)->SeekableInternal();
} }
TimeRanges* MediaSourceAttachmentImpl::Buffered( TimeRanges* SameThreadMediaSourceAttachment::Buffered(
MediaSourceTracer* tracer) const { MediaSourceTracer* tracer) const {
return GetMediaSource(tracer)->Buffered(); return GetMediaSource(tracer)->Buffered();
} }
void MediaSourceAttachmentImpl::OnTrackChanged(MediaSourceTracer* tracer, void SameThreadMediaSourceAttachment::OnTrackChanged(MediaSourceTracer* tracer,
TrackBase* track) { TrackBase* track) {
GetMediaSource(tracer)->OnTrackChanged(track); GetMediaSource(tracer)->OnTrackChanged(track);
} }
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef THIRD_PARTY_BLINK_RENDERER_MODULES_MEDIASOURCE_MEDIA_SOURCE_ATTACHMENT_IMPL_H_ #ifndef THIRD_PARTY_BLINK_RENDERER_MODULES_MEDIASOURCE_SAME_THREAD_MEDIA_SOURCE_ATTACHMENT_H_
#define THIRD_PARTY_BLINK_RENDERER_MODULES_MEDIASOURCE_MEDIA_SOURCE_ATTACHMENT_IMPL_H_ #define THIRD_PARTY_BLINK_RENDERER_MODULES_MEDIASOURCE_SAME_THREAD_MEDIA_SOURCE_ATTACHMENT_H_
#include <memory> #include <memory>
#include "third_party/blink/public/platform/web_time_range.h" #include "third_party/blink/public/platform/web_time_range.h"
...@@ -21,12 +21,12 @@ class TrackBase; ...@@ -21,12 +21,12 @@ class TrackBase;
class WebMediaSource; class WebMediaSource;
// Concrete attachment that supports operation only on the main thread. // Concrete attachment that supports operation only on the main thread.
class MediaSourceAttachmentImpl final : public MediaSourceAttachment { class SameThreadMediaSourceAttachment final : public MediaSourceAttachment {
public: public:
// The only intended caller of this constructor is // The only intended caller of this constructor is
// URLMediaSource::createObjectUrl. The raw pointer is then adopted into a // URLMediaSource::createObjectUrl. The raw pointer is then adopted into a
// scoped_refptr in MediaSourceRegistryImpl::RegisterURL. // scoped_refptr in SameThreadMediaSourceRegistry::RegisterURL.
explicit MediaSourceAttachmentImpl(MediaSource* media_source); explicit SameThreadMediaSourceAttachment(MediaSource* media_source);
void Unregister() override; void Unregister() override;
...@@ -44,15 +44,15 @@ class MediaSourceAttachmentImpl final : public MediaSourceAttachment { ...@@ -44,15 +44,15 @@ class MediaSourceAttachmentImpl final : public MediaSourceAttachment {
void OnTrackChanged(MediaSourceTracer* tracer, TrackBase*) override; void OnTrackChanged(MediaSourceTracer* tracer, TrackBase*) override;
private: private:
~MediaSourceAttachmentImpl() override; ~SameThreadMediaSourceAttachment() override;
// Cache of the registered MediaSource. Retains strong reference until // Cache of the registered MediaSource. Retains strong reference until
// Unregister() is called. // Unregister() is called.
Persistent<MediaSource> registered_media_source_; Persistent<MediaSource> registered_media_source_;
DISALLOW_COPY_AND_ASSIGN(MediaSourceAttachmentImpl); DISALLOW_COPY_AND_ASSIGN(SameThreadMediaSourceAttachment);
}; };
} // namespace blink } // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_MODULES_MEDIASOURCE_MEDIA_SOURCE_ATTACHMENT_IMPL_H_ #endif // THIRD_PARTY_BLINK_RENDERER_MODULES_MEDIASOURCE_SAME_THREAD_MEDIA_SOURCE_ATTACHMENT_H_
...@@ -35,8 +35,8 @@ ...@@ -35,8 +35,8 @@
#include "third_party/blink/renderer/core/html/media/media_source_attachment.h" #include "third_party/blink/renderer/core/html/media/media_source_attachment.h"
#include "third_party/blink/renderer/core/url/dom_url.h" #include "third_party/blink/renderer/core/url/dom_url.h"
#include "third_party/blink/renderer/modules/mediasource/media_source.h" #include "third_party/blink/renderer/modules/mediasource/media_source.h"
#include "third_party/blink/renderer/modules/mediasource/media_source_attachment_impl.h"
#include "third_party/blink/renderer/modules/mediasource/media_source_registry_impl.h" #include "third_party/blink/renderer/modules/mediasource/media_source_registry_impl.h"
#include "third_party/blink/renderer/modules/mediasource/same_thread_media_source_attachment.h"
#include "third_party/blink/renderer/platform/bindings/script_state.h" #include "third_party/blink/renderer/platform/bindings/script_state.h"
#include "third_party/blink/renderer/platform/instrumentation/use_counter.h" #include "third_party/blink/renderer/platform/instrumentation/use_counter.h"
...@@ -63,7 +63,8 @@ String URLMediaSource::createObjectURL(ScriptState* script_state, ...@@ -63,7 +63,8 @@ String URLMediaSource::createObjectURL(ScriptState* script_state,
// further detail. // further detail.
// TODO(https://crbug.com/878133): Support creation of a cross-thread // TODO(https://crbug.com/878133): Support creation of a cross-thread
// attachment. // attachment.
MediaSourceAttachment* attachment = new MediaSourceAttachmentImpl(source); MediaSourceAttachment* attachment =
new SameThreadMediaSourceAttachment(source);
DCHECK(attachment->HasOneRef()); DCHECK(attachment->HasOneRef());
String url = DOMURL::CreatePublicURL(execution_context, attachment); String url = DOMURL::CreatePublicURL(execution_context, attachment);
......
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