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 "content/renderer/media/buffered_data_source.h" | 5 #include "content/renderer/media/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/message_loop/message_loop_proxy.h" | 9 #include "base/message_loop/message_loop_proxy.h" |
10 #include "media/base/media_log.h" | 10 #include "media/base/media_log.h" |
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
363 | 363 |
364 // All responses must be successful. Resources that are assumed to be fully | 364 // All responses must be successful. Resources that are assumed to be fully |
365 // buffered must have a known content length. | 365 // buffered must have a known content length. |
366 bool success = status == BufferedResourceLoader::kOk && | 366 bool success = status == BufferedResourceLoader::kOk && |
367 (!assume_fully_buffered_ || | 367 (!assume_fully_buffered_ || |
368 loader_->instance_size() != kPositionNotSpecified); | 368 loader_->instance_size() != kPositionNotSpecified); |
369 | 369 |
370 if (success) { | 370 if (success) { |
371 total_bytes_ = loader_->instance_size(); | 371 total_bytes_ = loader_->instance_size(); |
372 streaming_ = !assume_fully_buffered_ && | 372 streaming_ = !assume_fully_buffered_ && |
373 (total_bytes_ == kPositionNotSpecified || !loader_->range_supported()); | 373 (total_bytes_ == kPositionNotSpecified || !loader_->range_supported()); |
scherkus (not reviewing)
2013/08/22 01:32:58
I'd actually have total bytes logged in this class
Ty Overby
2013/09/09 22:40:13
Do you still want this done?
scherkus (not reviewing)
2013/09/09 22:42:58
Ah so I'm *not* crazy! I swore I saw you add Media
Ty Overby
2013/09/09 22:52:32
Haha, yeah, I do plan on landing this.
Done.
| |
374 } else { | 374 } else { |
375 loader_->Stop(); | 375 loader_->Stop(); |
376 } | 376 } |
377 | 377 |
378 // TODO(scherkus): we shouldn't have to lock to signal host(), see | 378 // TODO(scherkus): we shouldn't have to lock to signal host(), see |
379 // http://crbug.com/113712 for details. | 379 // http://crbug.com/113712 for details. |
380 base::AutoLock auto_lock(lock_); | 380 base::AutoLock auto_lock(lock_); |
381 if (stop_signal_received_) | 381 if (stop_signal_received_) |
382 return; | 382 return; |
383 | 383 |
384 if (success) | 384 if (success) { |
385 UpdateHostState_Locked(); | 385 UpdateHostState_Locked(); |
386 media_log_->SetBooleanProperty("single_origin", loader_->HasSingleOrigin()); | |
387 media_log_->SetBooleanProperty("pass_cors_access_check", | |
scherkus (not reviewing)
2013/08/22 01:32:59
nit: s/pass/passed/
Ty Overby
2013/09/09 22:40:13
Done.
| |
388 loader_->DidPassCORSAccessCheck()); | |
389 // HTTP range header | |
scherkus (not reviewing)
2013/08/22 01:32:59
nit: remove this comment
Ty Overby
2013/09/09 22:40:13
Done.
| |
390 media_log_->SetBooleanProperty("range_supported", | |
391 loader_->range_supported()); | |
392 } | |
386 | 393 |
387 base::ResetAndReturn(&init_cb_).Run(success); | 394 base::ResetAndReturn(&init_cb_).Run(success); |
388 } | 395 } |
389 | 396 |
390 void BufferedDataSource::PartialReadStartCallback( | 397 void BufferedDataSource::PartialReadStartCallback( |
391 BufferedResourceLoader::Status status) { | 398 BufferedResourceLoader::Status status) { |
392 DCHECK(render_loop_->BelongsToCurrentThread()); | 399 DCHECK(render_loop_->BelongsToCurrentThread()); |
393 DCHECK(loader_.get()); | 400 DCHECK(loader_.get()); |
394 | 401 |
395 if (status == BufferedResourceLoader::kOk) { | 402 if (status == BufferedResourceLoader::kOk) { |
(...skipping 26 matching lines...) Expand all Loading... | |
422 return; | 429 return; |
423 | 430 |
424 if (status != BufferedResourceLoader::kOk) { | 431 if (status != BufferedResourceLoader::kOk) { |
425 // Stop the resource load if it failed. | 432 // Stop the resource load if it failed. |
426 loader_->Stop(); | 433 loader_->Stop(); |
427 | 434 |
428 if (status == BufferedResourceLoader::kCacheMiss && | 435 if (status == BufferedResourceLoader::kCacheMiss && |
429 read_op_->retries() < kNumCacheMissRetries) { | 436 read_op_->retries() < kNumCacheMissRetries) { |
430 read_op_->IncrementRetries(); | 437 read_op_->IncrementRetries(); |
431 | 438 |
439 media_log_->SetIntegerProperty("read_retries", read_op_->retries()); | |
scherkus (not reviewing)
2013/08/22 01:32:59
for now you can remove it ... it's a lower priorit
Ty Overby
2013/09/09 22:40:13
Done.
| |
440 | |
432 // Recreate a loader starting from where we last left off until the | 441 // Recreate a loader starting from where we last left off until the |
433 // end of the resource. | 442 // end of the resource. |
434 loader_.reset(CreateResourceLoader( | 443 loader_.reset(CreateResourceLoader( |
435 read_op_->position(), kPositionNotSpecified)); | 444 read_op_->position(), kPositionNotSpecified)); |
436 loader_->Start( | 445 loader_->Start( |
437 base::Bind(&BufferedDataSource::PartialReadStartCallback, weak_this_), | 446 base::Bind(&BufferedDataSource::PartialReadStartCallback, weak_this_), |
438 base::Bind(&BufferedDataSource::LoadingStateChangedCallback, | 447 base::Bind(&BufferedDataSource::LoadingStateChangedCallback, |
439 weak_this_), | 448 weak_this_), |
440 base::Bind(&BufferedDataSource::ProgressCallback, weak_this_), | 449 base::Bind(&BufferedDataSource::ProgressCallback, weak_this_), |
441 frame_); | 450 frame_); |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
529 if (total_bytes_ == kPositionNotSpecified) | 538 if (total_bytes_ == kPositionNotSpecified) |
530 return; | 539 return; |
531 | 540 |
532 host()->SetTotalBytes(total_bytes_); | 541 host()->SetTotalBytes(total_bytes_); |
533 | 542 |
534 if (assume_fully_buffered_) | 543 if (assume_fully_buffered_) |
535 host()->AddBufferedByteRange(0, total_bytes_); | 544 host()->AddBufferedByteRange(0, total_bytes_); |
536 } | 545 } |
537 | 546 |
538 } // namespace content | 547 } // namespace content |
OLD | NEW |