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

Unified Diff: content/child/url_response_body_consumer.cc

Issue 2591383003: Implement SetDefersLoading on content::URLLoaderClientImpl (Closed)
Patch Set: fix Created 4 years 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 | « content/child/url_response_body_consumer.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/child/url_response_body_consumer.cc
diff --git a/content/child/url_response_body_consumer.cc b/content/child/url_response_body_consumer.cc
index 9d5c017d6e35597d4c6a9813dca9866a60f8f149..5014eeb1ed6eb81443d4ba6642c5827f32e2b912 100644
--- a/content/child/url_response_body_consumer.cc
+++ b/content/child/url_response_body_consumer.cc
@@ -76,6 +76,15 @@ void URLResponseBodyConsumer::Cancel() {
handle_watcher_.Cancel();
}
+void URLResponseBodyConsumer::SetDefersLoading() {
+ is_deferred_ = true;
+}
+
+void URLResponseBodyConsumer::UnsetDefersLoading() {
+ is_deferred_ = false;
+ OnReadable(MOJO_RESULT_OK);
+}
+
void URLResponseBodyConsumer::Reclaim(uint32_t size) {
MojoResult result = mojo::EndReadDataRaw(handle_.get(), size);
DCHECK_EQ(MOJO_RESULT_OK, result);
@@ -89,17 +98,16 @@ void URLResponseBodyConsumer::Reclaim(uint32_t size) {
}
void URLResponseBodyConsumer::OnReadable(MojoResult unused) {
- DCHECK(!is_in_on_readable_);
-
- if (has_been_cancelled_ || has_seen_end_of_data_)
+ if (has_been_cancelled_ || has_seen_end_of_data_ || is_deferred_)
return;
+ DCHECK(!is_in_on_readable_);
+
// Protect |this| as RequestPeer::OnReceivedData may call deref.
scoped_refptr<URLResponseBodyConsumer> protect(this);
base::AutoReset<bool> is_in_on_readable(&is_in_on_readable_, true);
- // TODO(yhirano): Suppress notification when deferred.
- while (!has_been_cancelled_) {
+ while (!has_been_cancelled_ && !is_deferred_) {
const void* buffer = nullptr;
uint32_t available = 0;
MojoResult result = mojo::BeginReadDataRaw(
@@ -134,7 +142,7 @@ void URLResponseBodyConsumer::NotifyCompletionIfAppropriate() {
// Cancel this instance in order not to notify twice.
Cancel();
- resource_dispatcher_->OnMessageReceived(
+ resource_dispatcher_->DispatchMessage(
ResourceMsg_RequestComplete(request_id_, completion_status_));
// |this| may be deleted.
}
« no previous file with comments | « content/child/url_response_body_consumer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698