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 "content/public/common/url_constants.h" | 10 #include "content/public/common/url_constants.h" |
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
504 // TODO(scherkus): we shouldn't have to lock to signal host(), see | 504 // TODO(scherkus): we shouldn't have to lock to signal host(), see |
505 // http://crbug.com/113712 for details. | 505 // http://crbug.com/113712 for details. |
506 base::AutoLock auto_lock(lock_); | 506 base::AutoLock auto_lock(lock_); |
507 if (stop_signal_received_) | 507 if (stop_signal_received_) |
508 return; | 508 return; |
509 | 509 |
510 host_->AddBufferedByteRange(loader_->first_byte_position(), position); | 510 host_->AddBufferedByteRange(loader_->first_byte_position(), position); |
511 } | 511 } |
512 | 512 |
513 void BufferedDataSource::UpdateDeferStrategy(bool paused) { | 513 void BufferedDataSource::UpdateDeferStrategy(bool paused) { |
514 // 200 responses end up not being reused to satisfy future range requests, | 514 // No need to aggressively buffer when we are assuming the resource is fully |
515 // and we don't want to get too far ahead of the read-head (and thus require | 515 // buffered. |
516 // a restart), so keep to the thresholds. | 516 if (assume_fully_buffered()) { |
517 if (!loader_->range_supported()) { | |
518 loader_->UpdateDeferStrategy(BufferedResourceLoader::kCapacityDefer); | 517 loader_->UpdateDeferStrategy(BufferedResourceLoader::kCapacityDefer); |
519 return; | 518 return; |
520 } | 519 } |
521 | 520 |
522 // If the playback has started (at which point the preload value is ignored) | 521 // If the playback has started (at which point the preload value is ignored) |
523 // and we're paused, then try to load as much as possible (the loader will | 522 // and we're paused, then try to load as much as possible (the loader will |
524 // fall back to kCapacityDefer if it knows the current response won't be | 523 // fall back to kCapacityDefer if it knows the current response won't be |
525 // useful from the cache in the future). | 524 // useful from the cache in the future). |
526 if (media_has_played_ && paused) { | 525 if (media_has_played_ && paused && loader_->range_supported()) { |
527 loader_->UpdateDeferStrategy(BufferedResourceLoader::kNeverDefer); | 526 loader_->UpdateDeferStrategy(BufferedResourceLoader::kNeverDefer); |
528 return; | 527 return; |
529 } | 528 } |
530 | 529 |
531 // If media is currently playing or the page indicated preload=auto, | 530 // If media is currently playing or the page indicated preload=auto or the |
532 // use threshold strategy to enable/disable deferring when the buffer | 531 // the server does not support the byte range request or we do not want to go |
533 // is full/depleted. | 532 // too far ahead of the read head, use threshold strategy to enable/disable |
| 533 // deferring when the buffer is full/depleted. |
534 loader_->UpdateDeferStrategy(BufferedResourceLoader::kCapacityDefer); | 534 loader_->UpdateDeferStrategy(BufferedResourceLoader::kCapacityDefer); |
535 } | 535 } |
536 | 536 |
537 } // namespace content | 537 } // namespace content |
OLD | NEW |