Commit b8f30548 authored by Alok Priyadarshi's avatar Alok Priyadarshi Committed by Commit Bot

Cleanup MultibufferDataSource constructor params.

Replaces GURL, CORSMode and UrlIndex parameters with UrlData.

Change-Id: I42e723381ad53c3a9d33289b3da585d5d825f587
Reviewed-on: https://chromium-review.googlesource.com/581610Reviewed-by: default avatarFredrik Hubinette <hubbe@chromium.org>
Commit-Queue: Alok Priyadarshi <alokp@chromium.org>
Cr-Commit-Position: refs/heads/master@{#488819}
parent 6971b156
...@@ -102,20 +102,17 @@ void MultibufferDataSource::ReadOperation::Run( ...@@ -102,20 +102,17 @@ void MultibufferDataSource::ReadOperation::Run(
} }
MultibufferDataSource::MultibufferDataSource( MultibufferDataSource::MultibufferDataSource(
const GURL& url,
UrlData::CORSMode cors_mode,
const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
linked_ptr<UrlIndex> url_index, scoped_refptr<UrlData> url_data,
MediaLog* media_log, MediaLog* media_log,
BufferedDataSourceHost* host, BufferedDataSourceHost* host,
const DownloadingCB& downloading_cb) const DownloadingCB& downloading_cb)
: cors_mode_(cors_mode), : total_bytes_(kPositionNotSpecified),
total_bytes_(kPositionNotSpecified),
streaming_(false), streaming_(false),
loading_(false), loading_(false),
failed_(false), failed_(false),
render_task_runner_(task_runner), render_task_runner_(task_runner),
url_index_(url_index), url_data_(std::move(url_data)),
stop_signal_received_(false), stop_signal_received_(false),
media_has_played_(false), media_has_played_(false),
single_origin_(true), single_origin_(true),
...@@ -131,9 +128,8 @@ MultibufferDataSource::MultibufferDataSource( ...@@ -131,9 +128,8 @@ MultibufferDataSource::MultibufferDataSource(
DCHECK(host_); DCHECK(host_);
DCHECK(!downloading_cb_.is_null()); DCHECK(!downloading_cb_.is_null());
DCHECK(render_task_runner_->BelongsToCurrentThread()); DCHECK(render_task_runner_->BelongsToCurrentThread());
url_data_ = url_index_->GetByUrl(url, cors_mode_);
url_data_->Use();
DCHECK(url_data_); DCHECK(url_data_);
url_data_->Use();
url_data_->OnRedirect( url_data_->OnRedirect(
base::Bind(&MultibufferDataSource::OnRedirect, weak_ptr_)); base::Bind(&MultibufferDataSource::OnRedirect, weak_ptr_));
} }
...@@ -252,7 +248,7 @@ bool MultibufferDataSource::HasSingleOrigin() { ...@@ -252,7 +248,7 @@ bool MultibufferDataSource::HasSingleOrigin() {
} }
bool MultibufferDataSource::DidPassCORSAccessCheck() const { bool MultibufferDataSource::DidPassCORSAccessCheck() const {
if (cors_mode_ == UrlData::CORS_UNSPECIFIED) if (url_data_->cors_mode() == UrlData::CORS_UNSPECIFIED)
return false; return false;
// If init_cb is set, we initialization is not finished yet. // If init_cb is set, we initialization is not finished yet.
if (!init_cb_.is_null()) if (!init_cb_.is_null())
......
...@@ -57,10 +57,8 @@ class MEDIA_BLINK_EXPORT MultibufferDataSource : public DataSource { ...@@ -57,10 +57,8 @@ class MEDIA_BLINK_EXPORT MultibufferDataSource : public DataSource {
// will be reported to |host|. |downloading_cb| will be called whenever the // will be reported to |host|. |downloading_cb| will be called whenever the
// downloading/paused state of the source changes. // downloading/paused state of the source changes.
MultibufferDataSource( MultibufferDataSource(
const GURL& url,
UrlData::CORSMode cors_mode,
const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
linked_ptr<UrlIndex> url_index, scoped_refptr<UrlData> url_data,
MediaLog* media_log, MediaLog* media_log,
BufferedDataSourceHost* host, BufferedDataSourceHost* host,
const DownloadingCB& downloading_cb); const DownloadingCB& downloading_cb);
...@@ -161,12 +159,6 @@ class MEDIA_BLINK_EXPORT MultibufferDataSource : public DataSource { ...@@ -161,12 +159,6 @@ class MEDIA_BLINK_EXPORT MultibufferDataSource : public DataSource {
// Update |reader_|'s preload and buffer settings. // Update |reader_|'s preload and buffer settings.
void UpdateBufferSizes(); void UpdateBufferSizes();
// crossorigin attribute on the corresponding HTML media element, if any.
UrlData::CORSMode cors_mode_;
// URL of the resource requested.
scoped_refptr<UrlData> url_data_;
// The total size of the resource. Set during StartCallback() if the size is // The total size of the resource. Set during StartCallback() if the size is
// known, otherwise it will remain kPositionNotSpecified until the size is // known, otherwise it will remain kPositionNotSpecified until the size is
// determined by reaching EOF. // determined by reaching EOF.
...@@ -186,8 +178,8 @@ class MEDIA_BLINK_EXPORT MultibufferDataSource : public DataSource { ...@@ -186,8 +178,8 @@ class MEDIA_BLINK_EXPORT MultibufferDataSource : public DataSource {
// The task runner of the render thread. // The task runner of the render thread.
const scoped_refptr<base::SingleThreadTaskRunner> render_task_runner_; const scoped_refptr<base::SingleThreadTaskRunner> render_task_runner_;
// Shared cache. // URL of the resource requested.
linked_ptr<UrlIndex> url_index_; scoped_refptr<UrlData> url_data_;
// A resource reader for the media resource. // A resource reader for the media resource.
std::unique_ptr<MultiBufferReader> reader_; std::unique_ptr<MultiBufferReader> reader_;
......
...@@ -183,16 +183,12 @@ class MockBufferedDataSourceHost : public BufferedDataSourceHost { ...@@ -183,16 +183,12 @@ class MockBufferedDataSourceHost : public BufferedDataSourceHost {
class MockMultibufferDataSource : public MultibufferDataSource { class MockMultibufferDataSource : public MultibufferDataSource {
public: public:
MockMultibufferDataSource( MockMultibufferDataSource(
const GURL& url,
UrlData::CORSMode cors_mode,
const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
linked_ptr<UrlIndex> url_index, scoped_refptr<UrlData> url_data,
BufferedDataSourceHost* host) BufferedDataSourceHost* host)
: MultibufferDataSource( : MultibufferDataSource(
url,
cors_mode,
task_runner, task_runner,
url_index, std::move(url_data),
&media_log_, &media_log_,
host, host,
base::Bind(&MockMultibufferDataSource::set_downloading, base::Bind(&MockMultibufferDataSource::set_downloading,
...@@ -240,7 +236,8 @@ class MultibufferDataSourceTest : public testing::Test { ...@@ -240,7 +236,8 @@ class MultibufferDataSourceTest : public testing::Test {
size_t file_size = kFileSize) { size_t file_size = kFileSize) {
GURL gurl(url); GURL gurl(url);
data_source_.reset(new MockMultibufferDataSource( data_source_.reset(new MockMultibufferDataSource(
gurl, cors_mode, message_loop_.task_runner(), url_index_, &host_)); message_loop_.task_runner(), url_index_->GetByUrl(gurl, cors_mode),
&host_));
data_source_->SetPreload(preload_); data_source_->SetPreload(preload_);
response_generator_.reset(new TestResponseGenerator(gurl, file_size)); response_generator_.reset(new TestResponseGenerator(gurl, file_size));
...@@ -1016,9 +1013,9 @@ TEST_F(MultibufferDataSourceTest, Http_ShareData) { ...@@ -1016,9 +1013,9 @@ TEST_F(MultibufferDataSourceTest, Http_ShareData) {
EXPECT_TRUE(data_source_->downloading()); EXPECT_TRUE(data_source_->downloading());
StrictMock<MockBufferedDataSourceHost> host2; StrictMock<MockBufferedDataSourceHost> host2;
MockMultibufferDataSource source2(GURL(kHttpUrl), UrlData::CORS_UNSPECIFIED, MockMultibufferDataSource source2(
message_loop_.task_runner(), url_index_, message_loop_.task_runner(),
&host2); url_index_->GetByUrl(GURL(kHttpUrl), UrlData::CORS_UNSPECIFIED), &host2);
source2.SetPreload(preload_); source2.SetPreload(preload_);
EXPECT_CALL(*this, OnInitialize(true)); EXPECT_CALL(*this, OnInitialize(true));
...@@ -1309,8 +1306,8 @@ TEST_F(MultibufferDataSourceTest, ...@@ -1309,8 +1306,8 @@ TEST_F(MultibufferDataSourceTest,
TEST_F(MultibufferDataSourceTest, SeekPastEOF) { TEST_F(MultibufferDataSourceTest, SeekPastEOF) {
GURL gurl(kHttpUrl); GURL gurl(kHttpUrl);
data_source_.reset(new MockMultibufferDataSource( data_source_.reset(new MockMultibufferDataSource(
gurl, UrlData::CORS_UNSPECIFIED, message_loop_.task_runner(), url_index_, message_loop_.task_runner(),
&host_)); url_index_->GetByUrl(gurl, UrlData::CORS_UNSPECIFIED), &host_));
data_source_->SetPreload(preload_); data_source_->SetPreload(preload_);
response_generator_.reset(new TestResponseGenerator(gurl, kDataSize + 1)); response_generator_.reset(new TestResponseGenerator(gurl, kDataSize + 1));
...@@ -1590,8 +1587,8 @@ TEST_F(MultibufferDataSourceTest, CheckBufferSizeForSmallFiles) { ...@@ -1590,8 +1587,8 @@ TEST_F(MultibufferDataSourceTest, CheckBufferSizeForSmallFiles) {
TEST_F(MultibufferDataSourceTest, Http_CheckLoadingTransition) { TEST_F(MultibufferDataSourceTest, Http_CheckLoadingTransition) {
GURL gurl(kHttpUrl); GURL gurl(kHttpUrl);
data_source_.reset(new MockMultibufferDataSource( data_source_.reset(new MockMultibufferDataSource(
gurl, UrlData::CORS_UNSPECIFIED, message_loop_.task_runner(), url_index_, message_loop_.task_runner(),
&host_)); url_index_->GetByUrl(gurl, UrlData::CORS_UNSPECIFIED), &host_));
data_source_->SetPreload(preload_); data_source_->SetPreload(preload_);
response_generator_.reset(new TestResponseGenerator(gurl, kDataSize * 1)); response_generator_.reset(new TestResponseGenerator(gurl, kDataSize * 1));
......
...@@ -510,8 +510,9 @@ void WebMediaPlayerImpl::DoLoad(LoadType load_type, ...@@ -510,8 +510,9 @@ void WebMediaPlayerImpl::DoLoad(LoadType load_type,
StartPipeline(); StartPipeline();
} else { } else {
data_source_.reset(new MultibufferDataSource( data_source_.reset(new MultibufferDataSource(
url, static_cast<UrlData::CORSMode>(cors_mode), main_task_runner_, main_task_runner_,
url_index_, media_log_.get(), &buffered_data_source_host_, url_index_->GetByUrl(url, static_cast<UrlData::CORSMode>(cors_mode)),
media_log_.get(), &buffered_data_source_host_,
base::Bind(&WebMediaPlayerImpl::NotifyDownloading, AsWeakPtr()))); base::Bind(&WebMediaPlayerImpl::NotifyDownloading, AsWeakPtr())));
data_source_->SetPreload(preload_); data_source_->SetPreload(preload_);
data_source_->Initialize( data_source_->Initialize(
......
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