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