| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/message_loop.h" | 8 #include "base/message_loop.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 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 playback_rate_ = playback_rate; | 273 playback_rate_ = playback_rate; |
| 274 loader_->SetPlaybackRate(playback_rate); | 274 loader_->SetPlaybackRate(playback_rate); |
| 275 | 275 |
| 276 if (!loader_->range_supported()) { | 276 if (!loader_->range_supported()) { |
| 277 // 200 responses end up not being reused to satisfy future range requests, | 277 // 200 responses end up not being reused to satisfy future range requests, |
| 278 // and we don't want to get too far ahead of the read-head (and thus require | 278 // and we don't want to get too far ahead of the read-head (and thus require |
| 279 // a restart), so keep to the thresholds. | 279 // a restart), so keep to the thresholds. |
| 280 loader_->UpdateDeferStrategy(BufferedResourceLoader::kThresholdDefer); | 280 loader_->UpdateDeferStrategy(BufferedResourceLoader::kThresholdDefer); |
| 281 } else if (media_has_played_ && playback_rate == 0) { | 281 } else if (media_has_played_ && playback_rate == 0) { |
| 282 // If the playback has started (at which point the preload value is ignored) | 282 // If the playback has started (at which point the preload value is ignored) |
| 283 // and we're paused, then try to load as much as possible. | 283 // and we're paused, then try to load as much as possible (the loader will |
| 284 // TODO(fischman): except, don't do this if we can prove that the media | 284 // fall back to kThresholdDefer if it knows the current response won't be |
| 285 // cache is just throwing away the bits anyway. http://crbug.com/123074 | 285 // useful from the cache in the future). |
| 286 loader_->UpdateDeferStrategy(BufferedResourceLoader::kNeverDefer); | 286 loader_->UpdateDeferStrategy(BufferedResourceLoader::kNeverDefer); |
| 287 } else { | 287 } else { |
| 288 // If media is currently playing or the page indicated preload=auto, | 288 // If media is currently playing or the page indicated preload=auto, |
| 289 // use threshold strategy to enable/disable deferring when the buffer | 289 // use threshold strategy to enable/disable deferring when the buffer |
| 290 // is full/depleted. | 290 // is full/depleted. |
| 291 loader_->UpdateDeferStrategy(BufferedResourceLoader::kThresholdDefer); | 291 loader_->UpdateDeferStrategy(BufferedResourceLoader::kThresholdDefer); |
| 292 } | 292 } |
| 293 } | 293 } |
| 294 | 294 |
| 295 void BufferedDataSource::SetBitrateTask(int bitrate) { | 295 void BufferedDataSource::SetBitrateTask(int bitrate) { |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 577 | 577 |
| 578 if (!host()) | 578 if (!host()) |
| 579 return; | 579 return; |
| 580 | 580 |
| 581 if (total_bytes_ != kPositionNotSpecified) | 581 if (total_bytes_ != kPositionNotSpecified) |
| 582 host()->SetTotalBytes(total_bytes_); | 582 host()->SetTotalBytes(total_bytes_); |
| 583 host()->SetBufferedBytes(buffered_bytes_); | 583 host()->SetBufferedBytes(buffered_bytes_); |
| 584 } | 584 } |
| 585 | 585 |
| 586 } // namespace webkit_media | 586 } // namespace webkit_media |
| OLD | NEW |