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

Side by Side Diff: content/browser/renderer_host/resource_dispatcher_host.cc

Issue 6628035: Move resource related IPCs to their own file in content. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 9 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 unified diff | Download patch | Annotate | Revision Log
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/browser/renderer_host/resource_dispatcher_host.h" 7 #include "content/browser/renderer_host/resource_dispatcher_host.h"
8 8
9 #include <set> 9 #include <set>
10 #include <vector> 10 #include <vector>
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 #include "content/browser/renderer_host/redirect_to_file_resource_handler.h" 54 #include "content/browser/renderer_host/redirect_to_file_resource_handler.h"
55 #include "content/browser/renderer_host/render_view_host.h" 55 #include "content/browser/renderer_host/render_view_host.h"
56 #include "content/browser/renderer_host/render_view_host_delegate.h" 56 #include "content/browser/renderer_host/render_view_host_delegate.h"
57 #include "content/browser/renderer_host/render_view_host_notification_task.h" 57 #include "content/browser/renderer_host/render_view_host_notification_task.h"
58 #include "content/browser/renderer_host/resource_dispatcher_host_request_info.h" 58 #include "content/browser/renderer_host/resource_dispatcher_host_request_info.h"
59 #include "content/browser/renderer_host/resource_message_filter.h" 59 #include "content/browser/renderer_host/resource_message_filter.h"
60 #include "content/browser/renderer_host/resource_queue.h" 60 #include "content/browser/renderer_host/resource_queue.h"
61 #include "content/browser/renderer_host/resource_request_details.h" 61 #include "content/browser/renderer_host/resource_request_details.h"
62 #include "content/browser/renderer_host/sync_resource_handler.h" 62 #include "content/browser/renderer_host/sync_resource_handler.h"
63 #include "content/browser/worker_host/worker_service.h" 63 #include "content/browser/worker_host/worker_service.h"
64 #include "content/common/resource_messages.h"
64 #include "net/base/auth.h" 65 #include "net/base/auth.h"
65 #include "net/base/cert_status_flags.h" 66 #include "net/base/cert_status_flags.h"
66 #include "net/base/cookie_monster.h" 67 #include "net/base/cookie_monster.h"
67 #include "net/base/load_flags.h" 68 #include "net/base/load_flags.h"
68 #include "net/base/mime_util.h" 69 #include "net/base/mime_util.h"
69 #include "net/base/net_errors.h" 70 #include "net/base/net_errors.h"
70 #include "net/base/request_priority.h" 71 #include "net/base/request_priority.h"
71 #include "net/base/ssl_cert_request_info.h" 72 #include "net/base/ssl_cert_request_info.h"
72 #include "net/base/upload_data.h" 73 #include "net/base/upload_data.h"
73 #include "net/http/http_response_headers.h" 74 #include "net/http/http_response_headers.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 // See delcaration of |max_outstanding_requests_cost_per_process_| for details. 120 // See delcaration of |max_outstanding_requests_cost_per_process_| for details.
120 // This bound is 25MB, which allows for around 6000 outstanding requests. 121 // This bound is 25MB, which allows for around 6000 outstanding requests.
121 const int kMaxOutstandingRequestsCostPerProcess = 26214400; 122 const int kMaxOutstandingRequestsCostPerProcess = 26214400;
122 123
123 // Consults the RendererSecurity policy to determine whether the 124 // Consults the RendererSecurity policy to determine whether the
124 // ResourceDispatcherHost should service this request. A request might be 125 // ResourceDispatcherHost should service this request. A request might be
125 // disallowed if the renderer is not authorized to retrieve the request URL or 126 // disallowed if the renderer is not authorized to retrieve the request URL or
126 // if the renderer is attempting to upload an unauthorized file. 127 // if the renderer is attempting to upload an unauthorized file.
127 bool ShouldServiceRequest(ChildProcessInfo::ProcessType process_type, 128 bool ShouldServiceRequest(ChildProcessInfo::ProcessType process_type,
128 int child_id, 129 int child_id,
129 const ViewHostMsg_Resource_Request& request_data) { 130 const ResourceHostMsg_Request& request_data) {
130 if (process_type == ChildProcessInfo::PLUGIN_PROCESS) 131 if (process_type == ChildProcessInfo::PLUGIN_PROCESS)
131 return true; 132 return true;
132 133
133 if (request_data.resource_type == ResourceType::PREFETCH) { 134 if (request_data.resource_type == ResourceType::PREFETCH) {
134 prerender::PrerenderManager::RecordPrefetchTagObserved(); 135 prerender::PrerenderManager::RecordPrefetchTagObserved();
135 if (!ResourceDispatcherHost::is_prefetch_enabled()) 136 if (!ResourceDispatcherHost::is_prefetch_enabled())
136 return false; 137 return false;
137 } 138 }
138 139
139 ChildProcessSecurityPolicy* policy = 140 ChildProcessSecurityPolicy* policy =
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 std::string()); // No security info necessary. 306 std::string()); // No security info necessary.
306 return true; 307 return true;
307 } 308 }
308 309
309 bool ResourceDispatcherHost::OnMessageReceived(const IPC::Message& message, 310 bool ResourceDispatcherHost::OnMessageReceived(const IPC::Message& message,
310 ResourceMessageFilter* filter, 311 ResourceMessageFilter* filter,
311 bool* message_was_ok) { 312 bool* message_was_ok) {
312 filter_ = filter; 313 filter_ = filter;
313 bool handled = true; 314 bool handled = true;
314 IPC_BEGIN_MESSAGE_MAP_EX(ResourceDispatcherHost, message, *message_was_ok) 315 IPC_BEGIN_MESSAGE_MAP_EX(ResourceDispatcherHost, message, *message_was_ok)
315 IPC_MESSAGE_HANDLER(ViewHostMsg_RequestResource, OnRequestResource) 316 IPC_MESSAGE_HANDLER(ResourceHostMsg_RequestResource, OnRequestResource)
316 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_SyncLoad, OnSyncLoad) 317 IPC_MESSAGE_HANDLER_DELAY_REPLY(ResourceHostMsg_SyncLoad, OnSyncLoad)
317 IPC_MESSAGE_HANDLER(ViewHostMsg_ReleaseDownloadedFile, 318 IPC_MESSAGE_HANDLER(ResourceHostMsg_ReleaseDownloadedFile,
318 OnReleaseDownloadedFile) 319 OnReleaseDownloadedFile)
319 IPC_MESSAGE_HANDLER(ViewHostMsg_DataReceived_ACK, OnDataReceivedACK) 320 IPC_MESSAGE_HANDLER(ResourceHostMsg_DataReceived_ACK, OnDataReceivedACK)
320 IPC_MESSAGE_HANDLER(ViewHostMsg_DataDownloaded_ACK, OnDataDownloadedACK) 321 IPC_MESSAGE_HANDLER(ResourceHostMsg_DataDownloaded_ACK, OnDataDownloadedACK)
321 IPC_MESSAGE_HANDLER(ViewHostMsg_UploadProgress_ACK, OnUploadProgressACK) 322 IPC_MESSAGE_HANDLER(ResourceHostMsg_UploadProgress_ACK, OnUploadProgressACK)
322 IPC_MESSAGE_HANDLER(ViewHostMsg_CancelRequest, OnCancelRequest) 323 IPC_MESSAGE_HANDLER(ResourceHostMsg_CancelRequest, OnCancelRequest)
323 IPC_MESSAGE_HANDLER(ViewHostMsg_FollowRedirect, OnFollowRedirect) 324 IPC_MESSAGE_HANDLER(ResourceHostMsg_FollowRedirect, OnFollowRedirect)
324 IPC_MESSAGE_HANDLER(ViewHostMsg_ClosePage_ACK, OnClosePageACK) 325 IPC_MESSAGE_HANDLER(ViewHostMsg_ClosePage_ACK, OnClosePageACK)
325 IPC_MESSAGE_UNHANDLED(handled = false) 326 IPC_MESSAGE_UNHANDLED(handled = false)
326 IPC_END_MESSAGE_MAP_EX() 327 IPC_END_MESSAGE_MAP_EX()
327 328
328 filter_ = NULL; 329 filter_ = NULL;
329 return handled; 330 return handled;
330 } 331 }
331 332
332 void ResourceDispatcherHost::OnRequestResource( 333 void ResourceDispatcherHost::OnRequestResource(
333 const IPC::Message& message, 334 const IPC::Message& message,
334 int request_id, 335 int request_id,
335 const ViewHostMsg_Resource_Request& request_data) { 336 const ResourceHostMsg_Request& request_data) {
336 BeginRequest(request_id, request_data, NULL, message.routing_id()); 337 BeginRequest(request_id, request_data, NULL, message.routing_id());
337 } 338 }
338 339
339 // Begins a resource request with the given params on behalf of the specified 340 // Begins a resource request with the given params on behalf of the specified
340 // child process. Responses will be dispatched through the given receiver. The 341 // child process. Responses will be dispatched through the given receiver. The
341 // process ID is used to lookup TabContents from routing_id's in the case of a 342 // process ID is used to lookup TabContents from routing_id's in the case of a
342 // request from a renderer. request_context is the cookie/cache context to be 343 // request from a renderer. request_context is the cookie/cache context to be
343 // used for this request. 344 // used for this request.
344 // 345 //
345 // If sync_result is non-null, then a SyncLoad reply will be generated, else 346 // If sync_result is non-null, then a SyncLoad reply will be generated, else
346 // a normal asynchronous set of response messages will be generated. 347 // a normal asynchronous set of response messages will be generated.
347 void ResourceDispatcherHost::OnSyncLoad( 348 void ResourceDispatcherHost::OnSyncLoad(
348 int request_id, 349 int request_id,
349 const ViewHostMsg_Resource_Request& request_data, 350 const ResourceHostMsg_Request& request_data,
350 IPC::Message* sync_result) { 351 IPC::Message* sync_result) {
351 BeginRequest(request_id, request_data, sync_result, 352 BeginRequest(request_id, request_data, sync_result,
352 sync_result->routing_id()); 353 sync_result->routing_id());
353 } 354 }
354 355
355 void ResourceDispatcherHost::BeginRequest( 356 void ResourceDispatcherHost::BeginRequest(
356 int request_id, 357 int request_id,
357 const ViewHostMsg_Resource_Request& request_data, 358 const ResourceHostMsg_Request& request_data,
358 IPC::Message* sync_result, // only valid for sync 359 IPC::Message* sync_result, // only valid for sync
359 int route_id) { 360 int route_id) {
360 ChildProcessInfo::ProcessType process_type = filter_->process_type(); 361 ChildProcessInfo::ProcessType process_type = filter_->process_type();
361 int child_id = filter_->child_id(); 362 int child_id = filter_->child_id();
362 363
363 ChromeURLRequestContext* context = filter_->GetURLRequestContext( 364 ChromeURLRequestContext* context = filter_->GetURLRequestContext(
364 request_data); 365 request_data);
365 366
366 // Might need to resolve the blob references in the upload data. 367 // Might need to resolve the blob references in the upload data.
367 if (request_data.upload_data && context) { 368 if (request_data.upload_data && context) {
368 context->blob_storage_context()->controller()-> 369 context->blob_storage_context()->controller()->
369 ResolveBlobReferencesInUploadData(request_data.upload_data.get()); 370 ResolveBlobReferencesInUploadData(request_data.upload_data.get());
370 } 371 }
371 372
372 if (is_shutdown_ || 373 if (is_shutdown_ ||
373 !ShouldServiceRequest(process_type, child_id, request_data)) { 374 !ShouldServiceRequest(process_type, child_id, request_data)) {
374 net::URLRequestStatus status(net::URLRequestStatus::FAILED, 375 net::URLRequestStatus status(net::URLRequestStatus::FAILED,
375 net::ERR_ABORTED); 376 net::ERR_ABORTED);
376 if (sync_result) { 377 if (sync_result) {
377 SyncLoadResult result; 378 SyncLoadResult result;
378 result.status = status; 379 result.status = status;
379 ViewHostMsg_SyncLoad::WriteReplyParams(sync_result, result); 380 ResourceHostMsg_SyncLoad::WriteReplyParams(sync_result, result);
380 filter_->Send(sync_result); 381 filter_->Send(sync_result);
381 } else { 382 } else {
382 // Tell the renderer that this request was disallowed. 383 // Tell the renderer that this request was disallowed.
383 filter_->Send(new ViewMsg_Resource_RequestComplete( 384 filter_->Send(new ResourceMsg_RequestComplete(
384 route_id, 385 route_id,
385 request_id, 386 request_id,
386 status, 387 status,
387 std::string(), // No security info needed, connection was not 388 std::string(), // No security info needed, connection was not
388 base::Time())); // established. 389 base::Time())); // established.
389 } 390 }
390 return; 391 return;
391 } 392 }
392 393
393 // Ensure the Chrome plugins are loaded, as they may intercept network 394 // Ensure the Chrome plugins are loaded, as they may intercept network
(...skipping 1532 matching lines...) Expand 10 before | Expand all | Expand 10 after
1926 return is_prefetch_enabled_; 1927 return is_prefetch_enabled_;
1927 } 1928 }
1928 1929
1929 // static 1930 // static
1930 void ResourceDispatcherHost::set_is_prefetch_enabled(bool value) { 1931 void ResourceDispatcherHost::set_is_prefetch_enabled(bool value) {
1931 is_prefetch_enabled_ = value; 1932 is_prefetch_enabled_ = value;
1932 } 1933 }
1933 1934
1934 // static 1935 // static
1935 bool ResourceDispatcherHost::is_prefetch_enabled_ = false; 1936 bool ResourceDispatcherHost::is_prefetch_enabled_ = false;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698