Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(542)

Side by Side Diff: media/blink/buffered_data_source.cc

Issue 1029763002: Introduce CancelUponDeferral() to buffered media loaders. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « media/blink/buffered_data_source.h ('k') | media/blink/buffered_data_source_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 base::Bind(&BufferedDataSource::StopLoader, weak_factory_.GetWeakPtr())); 224 base::Bind(&BufferedDataSource::StopLoader, weak_factory_.GetWeakPtr()));
225 } 225 }
226 226
227 void BufferedDataSource::SetBitrate(int bitrate) { 227 void BufferedDataSource::SetBitrate(int bitrate) {
228 render_task_runner_->PostTask(FROM_HERE, 228 render_task_runner_->PostTask(FROM_HERE,
229 base::Bind(&BufferedDataSource::SetBitrateTask, 229 base::Bind(&BufferedDataSource::SetBitrateTask,
230 weak_factory_.GetWeakPtr(), 230 weak_factory_.GetWeakPtr(),
231 bitrate)); 231 bitrate));
232 } 232 }
233 233
234 void BufferedDataSource::OnBufferingHaveEnough() {
235 DCHECK(render_task_runner_->BelongsToCurrentThread());
236 if (loader_ && preload_ == METADATA && !media_has_played_ && !IsStreaming())
237 loader_->CancelUponDeferral();
238 }
239
234 void BufferedDataSource::Read( 240 void BufferedDataSource::Read(
235 int64 position, int size, uint8* data, 241 int64 position, int size, uint8* data,
236 const DataSource::ReadCB& read_cb) { 242 const DataSource::ReadCB& read_cb) {
237 DVLOG(1) << "Read: " << position << " offset, " << size << " bytes"; 243 DVLOG(1) << "Read: " << position << " offset, " << size << " bytes";
238 DCHECK(!read_cb.is_null()); 244 DCHECK(!read_cb.is_null());
239 245
240 { 246 {
241 base::AutoLock auto_lock(lock_); 247 base::AutoLock auto_lock(lock_);
242 DCHECK(!read_op_); 248 DCHECK(!read_op_);
243 249
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 } 551 }
546 552
547 // If media is currently playing or the page indicated preload=auto or the 553 // If media is currently playing or the page indicated preload=auto or the
548 // the server does not support the byte range request or we do not want to go 554 // the server does not support the byte range request or we do not want to go
549 // too far ahead of the read head, use threshold strategy to enable/disable 555 // too far ahead of the read head, use threshold strategy to enable/disable
550 // deferring when the buffer is full/depleted. 556 // deferring when the buffer is full/depleted.
551 loader_->UpdateDeferStrategy(BufferedResourceLoader::kCapacityDefer); 557 loader_->UpdateDeferStrategy(BufferedResourceLoader::kCapacityDefer);
552 } 558 }
553 559
554 } // namespace media 560 } // namespace media
OLDNEW
« no previous file with comments | « media/blink/buffered_data_source.h ('k') | media/blink/buffered_data_source_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698