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

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

Issue 8680036: Move ResourceResponse struct into the Content API, since it's used in Chrome. While at it, I also... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: add gypi changes 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 | « content/common/resource_dispatcher.h ('k') | content/common/resource_dispatcher_unittest.cc » ('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 (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"
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/file_path.h" 12 #include "base/file_path.h"
13 #include "base/message_loop.h" 13 #include "base/message_loop.h"
14 #include "base/shared_memory.h" 14 #include "base/shared_memory.h"
15 #include "base/string_util.h" 15 #include "base/string_util.h"
16 #include "content/common/request_extra_data.h" 16 #include "content/common/request_extra_data.h"
17 #include "content/common/resource_messages.h" 17 #include "content/common/resource_messages.h"
18 #include "content/common/resource_response.h"
19 #include "content/public/common/resource_dispatcher_delegate.h" 18 #include "content/public/common/resource_dispatcher_delegate.h"
19 #include "content/public/common/resource_response.h"
20 #include "net/base/net_errors.h" 20 #include "net/base/net_errors.h"
21 #include "net/base/net_util.h" 21 #include "net/base/net_util.h"
22 #include "net/base/upload_data.h" 22 #include "net/base/upload_data.h"
23 #include "net/http/http_response_headers.h" 23 #include "net/http/http_response_headers.h"
24 #include "webkit/glue/resource_type.h" 24 #include "webkit/glue/resource_type.h"
25 25
26 // Each resource request is assigned an ID scoped to this process. 26 // Each resource request is assigned an ID scoped to this process.
27 static int MakeRequestID() { 27 static int MakeRequestID() {
28 // NOTE: The resource_dispatcher_host also needs probably unique 28 // NOTE: The resource_dispatcher_host also needs probably unique
29 // request_ids, so they count down from -2 (-1 is a special we're 29 // request_ids, so they count down from -2 (-1 is a special we're
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 208
209 void IPCResourceLoaderBridge::SyncLoad(SyncLoadResponse* response) { 209 void IPCResourceLoaderBridge::SyncLoad(SyncLoadResponse* response) {
210 if (request_id_ != -1) { 210 if (request_id_ != -1) {
211 NOTREACHED() << "Starting a request twice"; 211 NOTREACHED() << "Starting a request twice";
212 response->status.set_status(net::URLRequestStatus::FAILED); 212 response->status.set_status(net::URLRequestStatus::FAILED);
213 return; 213 return;
214 } 214 }
215 215
216 request_id_ = MakeRequestID(); 216 request_id_ = MakeRequestID();
217 217
218 SyncLoadResult result; 218 content::SyncLoadResult result;
219 IPC::SyncMessage* msg = new ResourceHostMsg_SyncLoad(routing_id_, request_id_, 219 IPC::SyncMessage* msg = new ResourceHostMsg_SyncLoad(routing_id_, request_id_,
220 request_, &result); 220 request_, &result);
221 // NOTE: This may pump events (see RenderThread::Send). 221 // NOTE: This may pump events (see RenderThread::Send).
222 if (!dispatcher_->message_sender()->Send(msg)) { 222 if (!dispatcher_->message_sender()->Send(msg)) {
223 response->status.set_status(net::URLRequestStatus::FAILED); 223 response->status.set_status(net::URLRequestStatus::FAILED);
224 return; 224 return;
225 } 225 }
226 226
227 response->status = result.status; 227 response->status = result.status;
228 response->url = result.final_url; 228 response->url = result.final_url;
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 return; 325 return;
326 326
327 request_info->peer->OnUploadProgress(position, size); 327 request_info->peer->OnUploadProgress(position, size);
328 328
329 // Acknowledge receipt 329 // Acknowledge receipt
330 message_sender()->Send( 330 message_sender()->Send(
331 new ResourceHostMsg_UploadProgress_ACK(message.routing_id(), request_id)); 331 new ResourceHostMsg_UploadProgress_ACK(message.routing_id(), request_id));
332 } 332 }
333 333
334 void ResourceDispatcher::OnReceivedResponse( 334 void ResourceDispatcher::OnReceivedResponse(
335 int request_id, const ResourceResponseHead& response_head) { 335 int request_id, const content::ResourceResponseHead& response_head) {
336 PendingRequestInfo* request_info = GetPendingRequestInfo(request_id); 336 PendingRequestInfo* request_info = GetPendingRequestInfo(request_id);
337 if (!request_info) 337 if (!request_info)
338 return; 338 return;
339 339
340 if (delegate_) { 340 if (delegate_) {
341 webkit_glue::ResourceLoaderBridge::Peer* new_peer = 341 webkit_glue::ResourceLoaderBridge::Peer* new_peer =
342 delegate_->OnReceivedResponse( 342 delegate_->OnReceivedResponse(
343 request_info->peer, response_head.mime_type, request_info->url); 343 request_info->peer, response_head.mime_type, request_info->url);
344 if (new_peer) 344 if (new_peer)
345 request_info->peer = new_peer; 345 request_info->peer = new_peer;
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
610 610
611 // static 611 // static
612 void ResourceDispatcher::ReleaseResourcesInMessageQueue(MessageQueue* queue) { 612 void ResourceDispatcher::ReleaseResourcesInMessageQueue(MessageQueue* queue) {
613 while (!queue->empty()) { 613 while (!queue->empty()) {
614 IPC::Message* message = queue->front(); 614 IPC::Message* message = queue->front();
615 ReleaseResourcesInDataMessage(*message); 615 ReleaseResourcesInDataMessage(*message);
616 queue->pop_front(); 616 queue->pop_front();
617 delete message; 617 delete message;
618 } 618 }
619 } 619 }
OLDNEW
« no previous file with comments | « content/common/resource_dispatcher.h ('k') | content/common/resource_dispatcher_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698