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

Unified Diff: media/blink/resource_multibuffer_data_provider.cc

Issue 2078833003: fix a semi-rare crash in multibuffers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments addressed Created 4 years, 6 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
« no previous file with comments | « media/blink/multibuffer_data_source_unittest.cc ('k') | media/blink/test_response_generator.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/blink/resource_multibuffer_data_provider.cc
diff --git a/media/blink/resource_multibuffer_data_provider.cc b/media/blink/resource_multibuffer_data_provider.cc
index ae9c1c72eb5195e99612613afe7591e27fba6a33..e107270af0f937a27b20123ef3d8375b122e1a46 100644
--- a/media/blink/resource_multibuffer_data_provider.cc
+++ b/media/blink/resource_multibuffer_data_provider.cc
@@ -258,6 +258,7 @@ void ResourceMultiBufferDataProvider::didReceiveResponse(
// Expected content length can be |kPositionNotSpecified|, in that case
// |content_length_| is not specified and this is a streaming response.
int64_t content_length = response.expectedContentLength();
+ bool end_of_file = false;
// We make a strong assumption that when we reach here we have either
// received a response from HTTP/HTTPS protocol or the request was
@@ -285,12 +286,12 @@ void ResourceMultiBufferDataProvider::didReceiveResponse(
// to return.
destination_url_data->set_length(content_length);
} else if (response.httpStatusCode() == kHttpRangeNotSatisfiable) {
+ // Unsatisfiable range
// Really, we should never request a range that doesn't exist, but
// if we do, let's handle it in a sane way.
- // Unsatisfiable range
- fifo_.push_back(DataBuffer::CreateEOSBuffer());
- destination_url_data->multibuffer()->OnDataProviderEvent(this);
- return;
+ // Note, we can't just call OnDataProviderEvent() here, because
+ // url_data_ hasn't been updated to the final destination yet.
+ end_of_file = true;
} else {
active_loader_ = nullptr;
destination_url_data->Fail();
@@ -337,6 +338,11 @@ void ResourceMultiBufferDataProvider::didReceiveResponse(
url_data_->Fail();
return; // "this" may be deleted now.
}
+
+ if (end_of_file) {
+ fifo_.push_back(DataBuffer::CreateEOSBuffer());
+ url_data_->multibuffer()->OnDataProviderEvent(this);
+ }
}
void ResourceMultiBufferDataProvider::didReceiveData(WebURLLoader* loader,
« no previous file with comments | « media/blink/multibuffer_data_source_unittest.cc ('k') | media/blink/test_response_generator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698