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

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

Issue 8764002: Finish the base::Bind migration for webkit/media. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: rebase Created 9 years 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 | « no previous file | webkit/media/buffered_resource_loader.h » ('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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "webkit/media/buffered_data_source.h" 5 #include "webkit/media/buffered_data_source.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "media/base/filter_host.h" 8 #include "media/base/filter_host.h"
9 #include "media/base/media_log.h" 9 #include "media/base/media_log.h"
10 #include "net/base/net_errors.h" 10 #include "net/base/net_errors.h"
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 stop_signal_received_) { 218 stop_signal_received_) {
219 return; 219 return;
220 } 220 }
221 } 221 }
222 222
223 if (url_.SchemeIs(kHttpScheme) || url_.SchemeIs(kHttpsScheme)) { 223 if (url_.SchemeIs(kHttpScheme) || url_.SchemeIs(kHttpsScheme)) {
224 // Do an unbounded range request starting at the beginning. If the server 224 // Do an unbounded range request starting at the beginning. If the server
225 // responds with 200 instead of 206 we'll fall back into a streaming mode. 225 // responds with 200 instead of 206 we'll fall back into a streaming mode.
226 loader_ = CreateResourceLoader(0, kPositionNotSpecified); 226 loader_ = CreateResourceLoader(0, kPositionNotSpecified);
227 loader_->Start( 227 loader_->Start(
228 NewCallback(this, &BufferedDataSource::HttpInitialStartCallback), 228 base::Bind(&BufferedDataSource::HttpInitialStartCallback, this),
229 base::Bind(&BufferedDataSource::NetworkEventCallback, this), 229 base::Bind(&BufferedDataSource::NetworkEventCallback, this),
230 frame_); 230 frame_);
231 } else { 231 } else {
232 // For all other protocols, assume they support range request. We fetch 232 // For all other protocols, assume they support range request. We fetch
233 // the full range of the resource to obtain the instance size because 233 // the full range of the resource to obtain the instance size because
234 // we won't be served HTTP headers. 234 // we won't be served HTTP headers.
235 loader_ = CreateResourceLoader(kPositionNotSpecified, 235 loader_ = CreateResourceLoader(kPositionNotSpecified,
236 kPositionNotSpecified); 236 kPositionNotSpecified);
237 loader_->Start( 237 loader_->Start(
238 NewCallback(this, &BufferedDataSource::NonHttpInitialStartCallback), 238 base::Bind(&BufferedDataSource::NonHttpInitialStartCallback, this),
239 base::Bind(&BufferedDataSource::NetworkEventCallback, this), 239 base::Bind(&BufferedDataSource::NetworkEventCallback, this),
240 frame_); 240 frame_);
241 } 241 }
242 } 242 }
243 243
244 void BufferedDataSource::ReadTask( 244 void BufferedDataSource::ReadTask(
245 int64 position, 245 int64 position,
246 int read_size, 246 int read_size,
247 uint8* buffer) { 247 uint8* buffer) {
248 DCHECK(MessageLoop::current() == render_loop_); 248 DCHECK(MessageLoop::current() == render_loop_);
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 299
300 { 300 {
301 // If there's no outstanding read then return early. 301 // If there's no outstanding read then return early.
302 base::AutoLock auto_lock(lock_); 302 base::AutoLock auto_lock(lock_);
303 if (read_callback_.is_null()) 303 if (read_callback_.is_null())
304 return; 304 return;
305 } 305 }
306 306
307 loader_ = CreateResourceLoader(read_position_, kPositionNotSpecified); 307 loader_ = CreateResourceLoader(read_position_, kPositionNotSpecified);
308 loader_->Start( 308 loader_->Start(
309 NewCallback(this, &BufferedDataSource::PartialReadStartCallback), 309 base::Bind(&BufferedDataSource::PartialReadStartCallback, this),
310 base::Bind(&BufferedDataSource::NetworkEventCallback, this), 310 base::Bind(&BufferedDataSource::NetworkEventCallback, this),
311 frame_); 311 frame_);
312 } 312 }
313 313
314 void BufferedDataSource::SetPlaybackRateTask(float playback_rate) { 314 void BufferedDataSource::SetPlaybackRateTask(float playback_rate) {
315 DCHECK(MessageLoop::current() == render_loop_); 315 DCHECK(MessageLoop::current() == render_loop_);
316 DCHECK(loader_.get()); 316 DCHECK(loader_.get());
317 317
318 playback_rate_ = playback_rate; 318 playback_rate_ = playback_rate;
319 loader_->SetPlaybackRate(playback_rate); 319 loader_->SetPlaybackRate(playback_rate);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 DCHECK(loader_); 367 DCHECK(loader_);
368 368
369 // First we prepare the intermediate read buffer for BufferedResourceLoader 369 // First we prepare the intermediate read buffer for BufferedResourceLoader
370 // to write to. 370 // to write to.
371 if (read_size_ > intermediate_read_buffer_size_) { 371 if (read_size_ > intermediate_read_buffer_size_) {
372 intermediate_read_buffer_.reset(new uint8[read_size_]); 372 intermediate_read_buffer_.reset(new uint8[read_size_]);
373 } 373 }
374 374
375 // Perform the actual read with BufferedResourceLoader. 375 // Perform the actual read with BufferedResourceLoader.
376 loader_->Read(read_position_, read_size_, intermediate_read_buffer_.get(), 376 loader_->Read(read_position_, read_size_, intermediate_read_buffer_.get(),
377 NewCallback(this, &BufferedDataSource::ReadCallback)); 377 base::Bind(&BufferedDataSource::ReadCallback, this));
378 } 378 }
379 379
380 // Method to report the results of the current read request. Also reset all 380 // Method to report the results of the current read request. Also reset all
381 // the read parameters. 381 // the read parameters.
382 void BufferedDataSource::DoneRead_Locked(int error) { 382 void BufferedDataSource::DoneRead_Locked(int error) {
383 VLOG(1) << "DoneRead: " << error << " bytes"; 383 VLOG(1) << "DoneRead: " << error << " bytes";
384 384
385 DCHECK(MessageLoop::current() == render_loop_); 385 DCHECK(MessageLoop::current() == render_loop_);
386 DCHECK(!read_callback_.is_null()); 386 DCHECK(!read_callback_.is_null());
387 lock_.AssertAcquired(); 387 lock_.AssertAcquired();
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 loader_->Stop(); 439 loader_->Stop();
440 } 440 }
441 441
442 if (error == net::ERR_INVALID_RESPONSE && using_range_request_) { 442 if (error == net::ERR_INVALID_RESPONSE && using_range_request_) {
443 // Assuming that the Range header was causing the problem. Retry without 443 // Assuming that the Range header was causing the problem. Retry without
444 // the Range header. 444 // the Range header.
445 using_range_request_ = false; 445 using_range_request_ = false;
446 loader_ = CreateResourceLoader(kPositionNotSpecified, 446 loader_ = CreateResourceLoader(kPositionNotSpecified,
447 kPositionNotSpecified); 447 kPositionNotSpecified);
448 loader_->Start( 448 loader_->Start(
449 NewCallback(this, &BufferedDataSource::HttpInitialStartCallback), 449 base::Bind(&BufferedDataSource::HttpInitialStartCallback, this),
450 base::Bind(&BufferedDataSource::NetworkEventCallback, this), 450 base::Bind(&BufferedDataSource::NetworkEventCallback, this),
451 frame_); 451 frame_);
452 return; 452 return;
453 } 453 }
454 454
455 // Reference to prevent destruction while inside the |initialize_cb_| 455 // Reference to prevent destruction while inside the |initialize_cb_|
456 // call. This is a temporary fix to prevent crashes caused by holding the 456 // call. This is a temporary fix to prevent crashes caused by holding the
457 // lock and running the destructor. 457 // lock and running the destructor.
458 // TODO: Review locking in this class and figure out a way to run the callback 458 // TODO: Review locking in this class and figure out a way to run the callback
459 // w/o the lock. 459 // w/o the lock.
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
661 661
662 if (streaming_) 662 if (streaming_)
663 filter_host->SetStreaming(true); 663 filter_host->SetStreaming(true);
664 664
665 if (total_bytes_ != kPositionNotSpecified) 665 if (total_bytes_ != kPositionNotSpecified)
666 filter_host->SetTotalBytes(total_bytes_); 666 filter_host->SetTotalBytes(total_bytes_);
667 filter_host->SetBufferedBytes(buffered_bytes_); 667 filter_host->SetBufferedBytes(buffered_bytes_);
668 } 668 }
669 669
670 } // namespace webkit_media 670 } // namespace webkit_media
OLDNEW
« no previous file with comments | « no previous file | webkit/media/buffered_resource_loader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698