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

Side by Side Diff: content/common/resource_dispatcher.cc

Issue 8773007: Don't call CancelPendingRequest for synchronously answered requests (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 // See http://dev.chromium.org/developers/design-documents/multi-process-resourc e-loading 5 // See http://dev.chromium.org/developers/design-documents/multi-process-resourc e-loading
6 6
7 #include "content/common/resource_dispatcher.h" 7 #include "content/common/resource_dispatcher.h"
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 66
67 // The request to send, created on initialization for modification and 67 // The request to send, created on initialization for modification and
68 // appending data. 68 // appending data.
69 ResourceHostMsg_Request request_; 69 ResourceHostMsg_Request request_;
70 70
71 // ID for the request, valid once Start()ed, -1 if not valid yet. 71 // ID for the request, valid once Start()ed, -1 if not valid yet.
72 int request_id_; 72 int request_id_;
73 73
74 // The routing id used when sending IPC messages. 74 // The routing id used when sending IPC messages.
75 int routing_id_; 75 int routing_id_;
76
77 bool is_synchronous_request_;
76 }; 78 };
77 79
78 IPCResourceLoaderBridge::IPCResourceLoaderBridge( 80 IPCResourceLoaderBridge::IPCResourceLoaderBridge(
79 ResourceDispatcher* dispatcher, 81 ResourceDispatcher* dispatcher,
80 const webkit_glue::ResourceLoaderBridge::RequestInfo& request_info) 82 const webkit_glue::ResourceLoaderBridge::RequestInfo& request_info)
81 : peer_(NULL), 83 : peer_(NULL),
82 dispatcher_(dispatcher), 84 dispatcher_(dispatcher),
83 request_id_(-1), 85 request_id_(-1),
84 routing_id_(request_info.routing_id) { 86 routing_id_(request_info.routing_id),
87 is_synchronous_request_(false) {
85 DCHECK(dispatcher_) << "no resource dispatcher"; 88 DCHECK(dispatcher_) << "no resource dispatcher";
86 request_.method = request_info.method; 89 request_.method = request_info.method;
87 request_.url = request_info.url; 90 request_.url = request_info.url;
88 request_.first_party_for_cookies = request_info.first_party_for_cookies; 91 request_.first_party_for_cookies = request_info.first_party_for_cookies;
89 request_.referrer = request_info.referrer; 92 request_.referrer = request_info.referrer;
90 request_.headers = request_info.headers; 93 request_.headers = request_info.headers;
91 request_.load_flags = request_info.load_flags; 94 request_.load_flags = request_info.load_flags;
92 request_.origin_pid = request_info.requestor_pid; 95 request_.origin_pid = request_info.requestor_pid;
93 request_.resource_type = request_info.request_type; 96 request_.resource_type = request_info.request_type;
94 request_.request_context = request_info.request_context; 97 request_.request_context = request_info.request_context;
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 return dispatcher_->message_sender()->Send( 186 return dispatcher_->message_sender()->Send(
184 new ResourceHostMsg_RequestResource(routing_id_, request_id_, request_)); 187 new ResourceHostMsg_RequestResource(routing_id_, request_id_, request_));
185 } 188 }
186 189
187 void IPCResourceLoaderBridge::Cancel() { 190 void IPCResourceLoaderBridge::Cancel() {
188 if (request_id_ < 0) { 191 if (request_id_ < 0) {
189 NOTREACHED() << "Trying to cancel an unstarted request"; 192 NOTREACHED() << "Trying to cancel an unstarted request";
190 return; 193 return;
191 } 194 }
192 195
193 dispatcher_->CancelPendingRequest(routing_id_, request_id_); 196 if (!is_synchronous_request_)
197 dispatcher_->CancelPendingRequest(routing_id_, request_id_);
194 198
195 // We can't remove the request ID from the resource dispatcher because more 199 // We can't remove the request ID from the resource dispatcher because more
196 // data might be pending. Sending the cancel message may cause more data 200 // data might be pending. Sending the cancel message may cause more data
197 // to be flushed, and will then cause a complete message to be sent. 201 // to be flushed, and will then cause a complete message to be sent.
198 } 202 }
199 203
200 void IPCResourceLoaderBridge::SetDefersLoading(bool value) { 204 void IPCResourceLoaderBridge::SetDefersLoading(bool value) {
201 if (request_id_ < 0) { 205 if (request_id_ < 0) {
202 NOTREACHED() << "Trying to (un)defer an unstarted request"; 206 NOTREACHED() << "Trying to (un)defer an unstarted request";
203 return; 207 return;
204 } 208 }
205 209
206 dispatcher_->SetDefersLoading(request_id_, value); 210 dispatcher_->SetDefersLoading(request_id_, value);
207 } 211 }
208 212
209 void IPCResourceLoaderBridge::SyncLoad(SyncLoadResponse* response) { 213 void IPCResourceLoaderBridge::SyncLoad(SyncLoadResponse* response) {
210 if (request_id_ != -1) { 214 if (request_id_ != -1) {
211 NOTREACHED() << "Starting a request twice"; 215 NOTREACHED() << "Starting a request twice";
212 response->status.set_status(net::URLRequestStatus::FAILED); 216 response->status.set_status(net::URLRequestStatus::FAILED);
213 return; 217 return;
214 } 218 }
215 219
216 request_id_ = MakeRequestID(); 220 request_id_ = MakeRequestID();
221 is_synchronous_request_ = true;
217 222
218 content::SyncLoadResult result; 223 content::SyncLoadResult result;
219 IPC::SyncMessage* msg = new ResourceHostMsg_SyncLoad(routing_id_, request_id_, 224 IPC::SyncMessage* msg = new ResourceHostMsg_SyncLoad(routing_id_, request_id_,
220 request_, &result); 225 request_, &result);
221 // NOTE: This may pump events (see RenderThread::Send). 226 // NOTE: This may pump events (see RenderThread::Send).
222 if (!dispatcher_->message_sender()->Send(msg)) { 227 if (!dispatcher_->message_sender()->Send(msg)) {
223 response->status.set_status(net::URLRequestStatus::FAILED); 228 response->status.set_status(net::URLRequestStatus::FAILED);
224 return; 229 return;
225 } 230 }
226 231
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
610 615
611 // static 616 // static
612 void ResourceDispatcher::ReleaseResourcesInMessageQueue(MessageQueue* queue) { 617 void ResourceDispatcher::ReleaseResourcesInMessageQueue(MessageQueue* queue) {
613 while (!queue->empty()) { 618 while (!queue->empty()) {
614 IPC::Message* message = queue->front(); 619 IPC::Message* message = queue->front();
615 ReleaseResourcesInDataMessage(*message); 620 ReleaseResourcesInDataMessage(*message);
616 queue->pop_front(); 621 queue->pop_front();
617 delete message; 622 delete message;
618 } 623 }
619 } 624 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698