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

Unified Diff: media/blink/resource_multibuffer_data_provider.cc

Issue 2455693004: Media: fail properly on 404 after redirect (Closed)
Patch Set: Created 4 years, 2 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') | no next file » | 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 ba9d386f280ff87011c8acabeb81164fc78b7f97..446a7706e0cfd55f1d096e627534663e0958452c 100644
--- a/media/blink/resource_multibuffer_data_provider.cc
+++ b/media/blink/resource_multibuffer_data_provider.cc
@@ -172,6 +172,7 @@ void ResourceMultiBufferDataProvider::SetDeferred(bool deferred) {
bool ResourceMultiBufferDataProvider::willFollowRedirect(
const WebURLRequest& newRequest,
const WebURLResponse& redirectResponse) {
+ DVLOG(1) << "willFollowRedirect";
redirects_to_ = newRequest.url();
url_data_->set_valid_until(base::Time::Now() +
GetCacheValidUntil(redirectResponse));
@@ -201,8 +202,8 @@ void ResourceMultiBufferDataProvider::didSendData(
void ResourceMultiBufferDataProvider::didReceiveResponse(
const WebURLResponse& response) {
-#if ENABLE_DLOG
- string version;
+#if DCHECK_IS_ON()
+ std::string version;
switch (response.httpVersion()) {
case WebURLResponse::HTTPVersion_0_9:
version = "0.9";
@@ -216,6 +217,9 @@ void ResourceMultiBufferDataProvider::didReceiveResponse(
case WebURLResponse::HTTPVersion_2_0:
version = "2.1";
break;
+ case WebURLResponse::HTTPVersionUnknown:
+ version = "unknown";
+ break;
}
DVLOG(1) << "didReceiveResponse: HTTP/" << version << " "
<< response.httpStatusCode();
@@ -270,6 +274,7 @@ void ResourceMultiBufferDataProvider::didReceiveResponse(
// |content_length_| is not specified and this is a streaming response.
int64_t content_length = response.expectedContentLength();
bool end_of_file = false;
+ bool do_fail = 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
@@ -305,8 +310,9 @@ void ResourceMultiBufferDataProvider::didReceiveResponse(
end_of_file = true;
} else {
active_loader_ = nullptr;
- destination_url_data->Fail();
- return; // "this" may be deleted now.
+ // Can't call fail until readers have been migrated to the new
+ // url data below.
+ do_fail = true;
}
} else {
destination_url_data->set_range_supported();
@@ -315,7 +321,7 @@ void ResourceMultiBufferDataProvider::didReceiveResponse(
}
}
- if (url_index) {
+ if (url_index && !do_fail) {
destination_url_data = url_index->TryInsert(destination_url_data);
}
@@ -340,6 +346,11 @@ void ResourceMultiBufferDataProvider::didReceiveResponse(
old_url_data->RedirectTo(destination_url_data);
}
+ if (do_fail) {
+ destination_url_data->Fail();
+ return; // "this" may be deleted now.
+ }
+
// This test is vital for security!
const GURL& original_url = response.wasFetchedViaServiceWorker()
? response.originalURLViaServiceWorker()
« no previous file with comments | « media/blink/multibuffer_data_source_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698