| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "media/blink/buffered_data_source.h" | 5 #include "media/blink/buffered_data_source.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 base::Bind(&BufferedDataSource::StopLoader, weak_factory_.GetWeakPtr())); | 246 base::Bind(&BufferedDataSource::StopLoader, weak_factory_.GetWeakPtr())); |
| 247 } | 247 } |
| 248 | 248 |
| 249 void BufferedDataSource::SetBitrate(int bitrate) { | 249 void BufferedDataSource::SetBitrate(int bitrate) { |
| 250 render_task_runner_->PostTask(FROM_HERE, | 250 render_task_runner_->PostTask(FROM_HERE, |
| 251 base::Bind(&BufferedDataSource::SetBitrateTask, | 251 base::Bind(&BufferedDataSource::SetBitrateTask, |
| 252 weak_factory_.GetWeakPtr(), | 252 weak_factory_.GetWeakPtr(), |
| 253 bitrate)); | 253 bitrate)); |
| 254 } | 254 } |
| 255 | 255 |
| 256 void BufferedDataSource::OnBufferingHaveEnough() { | 256 void BufferedDataSource::OnBufferingHaveEnough(bool always_cancel) { |
| 257 DCHECK(render_task_runner_->BelongsToCurrentThread()); | 257 DCHECK(render_task_runner_->BelongsToCurrentThread()); |
| 258 if (loader_ && preload_ == METADATA && !media_has_played_ && !IsStreaming()) | 258 if (loader_ && (always_cancel || (preload_ == METADATA && |
| 259 !media_has_played_ && !IsStreaming()))) { |
| 259 loader_->CancelUponDeferral(); | 260 loader_->CancelUponDeferral(); |
| 261 } |
| 260 } | 262 } |
| 261 | 263 |
| 262 int64_t BufferedDataSource::GetMemoryUsage() const { | 264 int64_t BufferedDataSource::GetMemoryUsage() const { |
| 263 DCHECK(render_task_runner_->BelongsToCurrentThread()); | 265 DCHECK(render_task_runner_->BelongsToCurrentThread()); |
| 264 return loader_ ? loader_->GetMemoryUsage() : 0; | 266 return loader_ ? loader_->GetMemoryUsage() : 0; |
| 265 } | 267 } |
| 266 | 268 |
| 267 void BufferedDataSource::Read(int64_t position, | 269 void BufferedDataSource::Read(int64_t position, |
| 268 int size, | 270 int size, |
| 269 uint8_t* data, | 271 uint8_t* data, |
| (...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 605 } | 607 } |
| 606 | 608 |
| 607 // If media is currently playing or the page indicated preload=auto or the | 609 // If media is currently playing or the page indicated preload=auto or the |
| 608 // the server does not support the byte range request or we do not want to go | 610 // the server does not support the byte range request or we do not want to go |
| 609 // too far ahead of the read head, use threshold strategy to enable/disable | 611 // too far ahead of the read head, use threshold strategy to enable/disable |
| 610 // deferring when the buffer is full/depleted. | 612 // deferring when the buffer is full/depleted. |
| 611 loader_->UpdateDeferStrategy(BufferedResourceLoader::kCapacityDefer); | 613 loader_->UpdateDeferStrategy(BufferedResourceLoader::kCapacityDefer); |
| 612 } | 614 } |
| 613 | 615 |
| 614 } // namespace media | 616 } // namespace media |
| OLD | NEW |