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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
9 #include "base/location.h" | 9 #include "base/location.h" |
10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 weak_factory_.GetWeakPtr(), | 230 weak_factory_.GetWeakPtr(), |
231 bitrate)); | 231 bitrate)); |
232 } | 232 } |
233 | 233 |
234 void BufferedDataSource::OnBufferingHaveEnough() { | 234 void BufferedDataSource::OnBufferingHaveEnough() { |
235 DCHECK(render_task_runner_->BelongsToCurrentThread()); | 235 DCHECK(render_task_runner_->BelongsToCurrentThread()); |
236 if (loader_ && preload_ == METADATA && !media_has_played_ && !IsStreaming()) | 236 if (loader_ && preload_ == METADATA && !media_has_played_ && !IsStreaming()) |
237 loader_->CancelUponDeferral(); | 237 loader_->CancelUponDeferral(); |
238 } | 238 } |
239 | 239 |
| 240 int64_t BufferedDataSource::GetMemoryUsage() const { |
| 241 DCHECK(render_task_runner_->BelongsToCurrentThread()); |
| 242 return loader_ ? loader_->GetMemoryUsage() : 0; |
| 243 } |
| 244 |
240 void BufferedDataSource::Read( | 245 void BufferedDataSource::Read( |
241 int64 position, int size, uint8* data, | 246 int64 position, int size, uint8* data, |
242 const DataSource::ReadCB& read_cb) { | 247 const DataSource::ReadCB& read_cb) { |
243 DVLOG(1) << "Read: " << position << " offset, " << size << " bytes"; | 248 DVLOG(1) << "Read: " << position << " offset, " << size << " bytes"; |
244 DCHECK(!read_cb.is_null()); | 249 DCHECK(!read_cb.is_null()); |
245 | 250 |
246 { | 251 { |
247 base::AutoLock auto_lock(lock_); | 252 base::AutoLock auto_lock(lock_); |
248 DCHECK(!read_op_); | 253 DCHECK(!read_op_); |
249 | 254 |
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
571 } | 576 } |
572 | 577 |
573 // If media is currently playing or the page indicated preload=auto or the | 578 // If media is currently playing or the page indicated preload=auto or the |
574 // the server does not support the byte range request or we do not want to go | 579 // the server does not support the byte range request or we do not want to go |
575 // too far ahead of the read head, use threshold strategy to enable/disable | 580 // too far ahead of the read head, use threshold strategy to enable/disable |
576 // deferring when the buffer is full/depleted. | 581 // deferring when the buffer is full/depleted. |
577 loader_->UpdateDeferStrategy(BufferedResourceLoader::kCapacityDefer); | 582 loader_->UpdateDeferStrategy(BufferedResourceLoader::kCapacityDefer); |
578 } | 583 } |
579 | 584 |
580 } // namespace media | 585 } // namespace media |
OLD | NEW |