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

Unified Diff: webkit/glue/media/buffered_data_source.cc

Issue 6815012: Only make Range requests when the desired range doesn't cover the whole file. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix unit tests Created 9 years, 8 months 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 side-by-side diff with in-line comments
Download patch
Index: webkit/glue/media/buffered_data_source.cc
diff --git a/webkit/glue/media/buffered_data_source.cc b/webkit/glue/media/buffered_data_source.cc
index 03b2a0a3a5b1cebb3bc2e52ea3ffb1a761401f4a..b1a21e3f8f659ae9ace6dbf8653d07c4e0d1e6e0 100644
--- a/webkit/glue/media/buffered_data_source.cc
+++ b/webkit/glue/media/buffered_data_source.cc
@@ -458,7 +458,6 @@ void BufferedDataSource::HttpInitialStartCallback(int error) {
DCHECK(loader_.get());
int64 instance_size = loader_->instance_size();
- bool partial_response = loader_->partial_response();
bool success = error == net::OK;
if (!initialize_callback_.get()) {
@@ -471,7 +470,8 @@ void BufferedDataSource::HttpInitialStartCallback(int error) {
// request or their partial response is not complete.
total_bytes_ = instance_size;
loaded_ = false;
- streaming_ = (instance_size == kPositionNotSpecified) || !partial_response;
+ streaming_ = (instance_size == kPositionNotSpecified) ||
+ !loader_->range_supported();
} else {
// TODO(hclam): In case of failure, we can retry several times.
loader_->Stop();
@@ -572,11 +572,8 @@ void BufferedDataSource::PartialReadStartCallback(int error) {
DCHECK(MessageLoop::current() == render_loop_);
DCHECK(loader_.get());
- // This callback method is invoked after we have verified the server has
- // range request capability, so as a safety guard verify again the response
- // is partial.
- if (error == net::OK && loader_->partial_response()) {
- // Once the range request has started successfully, we can proceed with
+ if (error == net::OK) {
acolwell GONE FROM CHROMIUM 2011/04/07 22:56:48 loader_->partial_response() is not needed here any
+ // Once the request has started successfully, we can proceed with
// reading from it.
ReadInternal();
return;
@@ -631,6 +628,14 @@ void BufferedDataSource::ReadCallback(int error) {
// If a position error code is received, read was successful. So copy
// from intermediate read buffer to the target read buffer.
memcpy(read_buffer_, intermediate_read_buffer_.get(), error);
+ } else if (error == 0 && total_bytes_ == kPositionNotSpecified) {
+ // We've reached the end of the file and we didn't know the total size
+ // before. Update the total size so Read()s past the end of the file will
+ // fail like they would if we had known the file size at the beginning.
+ total_bytes_ = loader_->instance_size();
+
+ if (total_bytes_ != kPositionNotSpecified)
+ host()->SetTotalBytes(total_bytes_);
Ami GONE FROM CHROMIUM 2011/04/08 03:02:10 Do you not need to check that host()!=NULL?
acolwell GONE FROM CHROMIUM 2011/04/18 22:09:56 Done.
}
DoneRead_Locked(error);
}
« no previous file with comments | « no previous file | webkit/glue/media/buffered_data_source_unittest.cc » ('j') | webkit/glue/media/buffered_data_source_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698