Chromium Code Reviews| Index: content/renderer/media/buffered_data_source.cc |
| diff --git a/content/renderer/media/buffered_data_source.cc b/content/renderer/media/buffered_data_source.cc |
| index f14bf493e57b4204e1c45a1b6605064b2e136565..bd82d46f95309a2dde6527ac745c8a0975489a48 100644 |
| --- a/content/renderer/media/buffered_data_source.cc |
| +++ b/content/renderer/media/buffered_data_source.cc |
| @@ -81,6 +81,7 @@ BufferedDataSource::BufferedDataSource( |
| const scoped_refptr<base::MessageLoopProxy>& render_loop, |
| WebFrame* frame, |
| media::MediaLog* media_log, |
| + media::DataSourceHost* host, |
| const DownloadingCB& downloading_cb) |
| : cors_mode_(BufferedResourceLoader::kUnspecified), |
| total_bytes_(kPositionNotSpecified), |
| @@ -96,6 +97,7 @@ BufferedDataSource::BufferedDataSource( |
| bitrate_(0), |
| playback_rate_(0.0), |
| media_log_(media_log), |
| + host_(host), |
| downloading_cb_(downloading_cb), |
| weak_factory_(this) { |
| DCHECK(!downloading_cb_.is_null()); |
|
scherkus (not reviewing)
2014/03/28 21:19:56
DCHECK(host_) here isn't a bad thing as it's requi
sandersd (OOO until July 31)
2014/03/29 01:15:07
Done.
|
| @@ -124,15 +126,6 @@ BufferedResourceLoader* BufferedDataSource::CreateResourceLoader( |
| media_log_.get()); |
| } |
| -void BufferedDataSource::set_host(media::DataSourceHost* host) { |
| - DataSource::set_host(host); |
| - |
| - if (loader_) { |
| - base::AutoLock auto_lock(lock_); |
| - UpdateHostState_Locked(); |
| - } |
| -} |
| - |
| void BufferedDataSource::Initialize( |
| const GURL& url, |
| BufferedResourceLoader::CORSMode cors_mode, |
| @@ -380,7 +373,12 @@ void BufferedDataSource::StartCallback( |
| return; |
| if (success) { |
| - UpdateHostState_Locked(); |
| + if (total_bytes_ != kPositionNotSpecified) { |
| + host_->SetTotalBytes(total_bytes_); |
| + if (assume_fully_buffered_) |
| + host_->AddBufferedByteRange(0, total_bytes_); |
| + } |
| + |
| media_log_->SetBooleanProperty("single_origin", loader_->HasSingleOrigin()); |
| media_log_->SetBooleanProperty("passed_cors_access_check", |
| loader_->DidPassCORSAccessCheck()); |
| @@ -460,10 +458,10 @@ void BufferedDataSource::ReadCallback( |
| // fail like they would if we had known the file size at the beginning. |
| total_bytes_ = loader_->instance_size(); |
| - if (host() && total_bytes_ != kPositionNotSpecified) { |
| - host()->SetTotalBytes(total_bytes_); |
| - host()->AddBufferedByteRange(loader_->first_byte_position(), |
| - total_bytes_); |
| + if (total_bytes_ != kPositionNotSpecified) { |
| + host_->SetTotalBytes(total_bytes_); |
| + host_->AddBufferedByteRange(loader_->first_byte_position(), |
| + total_bytes_); |
| } |
| } |
| ReadOperation::Run(read_op_.Pass(), bytes_read); |
| @@ -510,35 +508,7 @@ void BufferedDataSource::ProgressCallback(int64 position) { |
| if (stop_signal_received_) |
| return; |
| - ReportOrQueueBufferedBytes(loader_->first_byte_position(), position); |
| -} |
| - |
| -void BufferedDataSource::ReportOrQueueBufferedBytes(int64 start, int64 end) { |
| - if (host()) |
| - host()->AddBufferedByteRange(start, end); |
| - else |
| - queued_buffered_byte_ranges_.Add(start, end); |
| -} |
| - |
| -void BufferedDataSource::UpdateHostState_Locked() { |
| - lock_.AssertAcquired(); |
| - |
| - if (!host()) |
| - return; |
| - |
| - for (size_t i = 0; i < queued_buffered_byte_ranges_.size(); ++i) { |
| - host()->AddBufferedByteRange(queued_buffered_byte_ranges_.start(i), |
| - queued_buffered_byte_ranges_.end(i)); |
| - } |
| - queued_buffered_byte_ranges_.clear(); |
| - |
| - if (total_bytes_ == kPositionNotSpecified) |
| - return; |
| - |
| - host()->SetTotalBytes(total_bytes_); |
| - |
| - if (assume_fully_buffered_) |
| - host()->AddBufferedByteRange(0, total_bytes_); |
| + host_->AddBufferedByteRange(loader_->first_byte_position(), position); |
| } |
| void BufferedDataSource::UpdateDeferStrategy(bool paused) { |