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

Side by Side Diff: content/child/url_response_body_consumer.cc

Issue 2463753002: Add virtual tests for XHR with mojo-loading (Closed)
Patch Set: fix Created 4 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/FlagExpectations/site-per-process » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "content/child/url_response_body_consumer.h" 5 #include "content/child/url_response_body_consumer.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "content/child/resource_dispatcher.h" 10 #include "content/child/resource_dispatcher.h"
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 80
81 void URLResponseBodyConsumer::Reclaim(uint32_t size) { 81 void URLResponseBodyConsumer::Reclaim(uint32_t size) {
82 MojoResult result = mojo::EndReadDataRaw(handle_.get(), size); 82 MojoResult result = mojo::EndReadDataRaw(handle_.get(), size);
83 DCHECK_EQ(MOJO_RESULT_OK, result); 83 DCHECK_EQ(MOJO_RESULT_OK, result);
84 } 84 }
85 85
86 void URLResponseBodyConsumer::OnReadable(MojoResult unused) { 86 void URLResponseBodyConsumer::OnReadable(MojoResult unused) {
87 if (has_been_cancelled_ || has_seen_end_of_data_) 87 if (has_been_cancelled_ || has_seen_end_of_data_)
88 return; 88 return;
89 89
90 // Protect |this| as RequestPeer::OnReceivedData may call deref.
91 scoped_refptr<URLResponseBodyConsumer> protect(this);
92
90 // TODO(yhirano): Suppress notification when deferred. 93 // TODO(yhirano): Suppress notification when deferred.
91 while (!has_been_cancelled_) { 94 while (!has_been_cancelled_) {
92 const void* buffer = nullptr; 95 const void* buffer = nullptr;
93 uint32_t available = 0; 96 uint32_t available = 0;
94 MojoResult result = mojo::BeginReadDataRaw( 97 MojoResult result = mojo::BeginReadDataRaw(
95 handle_.get(), &buffer, &available, MOJO_READ_DATA_FLAG_NONE); 98 handle_.get(), &buffer, &available, MOJO_READ_DATA_FLAG_NONE);
96 if (result == MOJO_RESULT_SHOULD_WAIT) 99 if (result == MOJO_RESULT_SHOULD_WAIT)
97 return; 100 return;
98 if (result == MOJO_RESULT_FAILED_PRECONDITION) { 101 if (result == MOJO_RESULT_FAILED_PRECONDITION) {
99 has_seen_end_of_data_ = true; 102 has_seen_end_of_data_ = true;
(...skipping 22 matching lines...) Expand all
122 return; 125 return;
123 // Cancel this instance in order not to notify twice. 126 // Cancel this instance in order not to notify twice.
124 Cancel(); 127 Cancel();
125 128
126 resource_dispatcher_->OnMessageReceived( 129 resource_dispatcher_->OnMessageReceived(
127 ResourceMsg_RequestComplete(request_id_, completion_status_)); 130 ResourceMsg_RequestComplete(request_id_, completion_status_));
128 // |this| may be deleted. 131 // |this| may be deleted.
129 } 132 }
130 133
131 } // namespace content 134 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/FlagExpectations/site-per-process » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698