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

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

Issue 5874002: Create a ResourceMessageFilter to filter resource related IPCs. This gets ri... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "chrome/browser/renderer_host/resource_dispatcher_host.h" 7 #include "chrome/browser/renderer_host/resource_dispatcher_host.h"
8 8
9 #include <vector> 9 #include <vector>
10 10
(...skipping 23 matching lines...) Expand all
34 #include "chrome/browser/renderer_host/async_resource_handler.h" 34 #include "chrome/browser/renderer_host/async_resource_handler.h"
35 #include "chrome/browser/renderer_host/buffered_resource_handler.h" 35 #include "chrome/browser/renderer_host/buffered_resource_handler.h"
36 #include "chrome/browser/renderer_host/cross_site_resource_handler.h" 36 #include "chrome/browser/renderer_host/cross_site_resource_handler.h"
37 #include "chrome/browser/renderer_host/download_resource_handler.h" 37 #include "chrome/browser/renderer_host/download_resource_handler.h"
38 #include "chrome/browser/renderer_host/global_request_id.h" 38 #include "chrome/browser/renderer_host/global_request_id.h"
39 #include "chrome/browser/renderer_host/redirect_to_file_resource_handler.h" 39 #include "chrome/browser/renderer_host/redirect_to_file_resource_handler.h"
40 #include "chrome/browser/renderer_host/render_view_host.h" 40 #include "chrome/browser/renderer_host/render_view_host.h"
41 #include "chrome/browser/renderer_host/render_view_host_delegate.h" 41 #include "chrome/browser/renderer_host/render_view_host_delegate.h"
42 #include "chrome/browser/renderer_host/render_view_host_notification_task.h" 42 #include "chrome/browser/renderer_host/render_view_host_notification_task.h"
43 #include "chrome/browser/renderer_host/resource_dispatcher_host_request_info.h" 43 #include "chrome/browser/renderer_host/resource_dispatcher_host_request_info.h"
44 #include "chrome/browser/renderer_host/resource_message_filter.h"
44 #include "chrome/browser/renderer_host/resource_queue.h" 45 #include "chrome/browser/renderer_host/resource_queue.h"
45 #include "chrome/browser/renderer_host/resource_request_details.h" 46 #include "chrome/browser/renderer_host/resource_request_details.h"
46 #include "chrome/browser/renderer_host/safe_browsing_resource_handler.h" 47 #include "chrome/browser/renderer_host/safe_browsing_resource_handler.h"
47 #include "chrome/browser/renderer_host/save_file_resource_handler.h" 48 #include "chrome/browser/renderer_host/save_file_resource_handler.h"
48 #include "chrome/browser/renderer_host/sync_resource_handler.h" 49 #include "chrome/browser/renderer_host/sync_resource_handler.h"
49 #include "chrome/browser/safe_browsing/safe_browsing_service.h" 50 #include "chrome/browser/safe_browsing/safe_browsing_service.h"
50 #include "chrome/browser/ssl/ssl_client_auth_handler.h" 51 #include "chrome/browser/ssl/ssl_client_auth_handler.h"
51 #include "chrome/browser/ssl/ssl_manager.h" 52 #include "chrome/browser/ssl/ssl_manager.h"
52 #include "chrome/browser/ui/login/login_prompt.h" 53 #include "chrome/browser/ui/login/login_prompt.h"
53 #include "chrome/browser/worker_host/worker_service.h" 54 #include "chrome/browser/worker_host/worker_service.h"
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 std::vector<int> GetAllNetErrorCodes() { 188 std::vector<int> GetAllNetErrorCodes() {
188 std::vector<int> all_error_codes; 189 std::vector<int> all_error_codes;
189 #define NET_ERROR(label, value) all_error_codes.push_back(-(value)); 190 #define NET_ERROR(label, value) all_error_codes.push_back(-(value));
190 #include "net/base/net_error_list.h" 191 #include "net/base/net_error_list.h"
191 #undef NET_ERROR 192 #undef NET_ERROR
192 return all_error_codes; 193 return all_error_codes;
193 } 194 }
194 195
195 } // namespace 196 } // namespace
196 197
197 ResourceDispatcherHost::Receiver::Receiver(ChildProcessInfo::ProcessType type,
198 int child_id)
199 : ChildProcessInfo(type, child_id) {
200 }
201
202 ResourceDispatcherHost::Receiver::~Receiver() {
203 }
204
205 ResourceDispatcherHost::ResourceDispatcherHost() 198 ResourceDispatcherHost::ResourceDispatcherHost()
206 : ALLOW_THIS_IN_INITIALIZER_LIST( 199 : ALLOW_THIS_IN_INITIALIZER_LIST(
207 download_file_manager_(new DownloadFileManager(this))), 200 download_file_manager_(new DownloadFileManager(this))),
208 download_request_limiter_(new DownloadRequestLimiter()), 201 download_request_limiter_(new DownloadRequestLimiter()),
209 ALLOW_THIS_IN_INITIALIZER_LIST( 202 ALLOW_THIS_IN_INITIALIZER_LIST(
210 save_file_manager_(new SaveFileManager(this))), 203 save_file_manager_(new SaveFileManager(this))),
211 user_script_listener_(new UserScriptListener(&resource_queue_)), 204 user_script_listener_(new UserScriptListener(&resource_queue_)),
212 safe_browsing_(SafeBrowsingService::CreateSafeBrowsingService()), 205 safe_browsing_(SafeBrowsingService::CreateSafeBrowsingService()),
213 webkit_thread_(new WebKitThread), 206 webkit_thread_(new WebKitThread),
214 request_id_(-1), 207 request_id_(-1),
215 ALLOW_THIS_IN_INITIALIZER_LIST(method_runner_(this)), 208 ALLOW_THIS_IN_INITIALIZER_LIST(method_runner_(this)),
216 is_shutdown_(false), 209 is_shutdown_(false),
217 max_outstanding_requests_cost_per_process_( 210 max_outstanding_requests_cost_per_process_(
218 kMaxOutstandingRequestsCostPerProcess), 211 kMaxOutstandingRequestsCostPerProcess),
219 receiver_(NULL) { 212 filter_(NULL) {
220 ResourceQueue::DelegateSet resource_queue_delegates; 213 ResourceQueue::DelegateSet resource_queue_delegates;
221 resource_queue_delegates.insert(user_script_listener_.get()); 214 resource_queue_delegates.insert(user_script_listener_.get());
222 resource_queue_.Initialize(resource_queue_delegates); 215 resource_queue_.Initialize(resource_queue_delegates);
223 } 216 }
224 217
225 ResourceDispatcherHost::~ResourceDispatcherHost() { 218 ResourceDispatcherHost::~ResourceDispatcherHost() {
226 AsyncResourceHandler::GlobalCleanup(); 219 AsyncResourceHandler::GlobalCleanup();
227 STLDeleteValues(&pending_requests_); 220 STLDeleteValues(&pending_requests_);
228 221
229 user_script_listener_->ShutdownMainThread(); 222 user_script_listener_->ShutdownMainThread();
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 &ExternalProtocolHandler::LaunchUrl, url, child_id, route_id)); 285 &ExternalProtocolHandler::LaunchUrl, url, child_id, route_id));
293 286
294 handler->OnResponseCompleted(request_id, URLRequestStatus( 287 handler->OnResponseCompleted(request_id, URLRequestStatus(
295 URLRequestStatus::FAILED, 288 URLRequestStatus::FAILED,
296 net::ERR_ABORTED), 289 net::ERR_ABORTED),
297 std::string()); // No security info necessary. 290 std::string()); // No security info necessary.
298 return true; 291 return true;
299 } 292 }
300 293
301 bool ResourceDispatcherHost::OnMessageReceived(const IPC::Message& message, 294 bool ResourceDispatcherHost::OnMessageReceived(const IPC::Message& message,
302 Receiver* receiver, 295 ResourceMessageFilter* filter,
303 bool* message_was_ok) { 296 bool* message_was_ok) {
304 if (!IsResourceDispatcherHostMessage(message)) { 297 filter_ = filter;
305 return false; 298 bool handled = true;
306 }
307
308 *message_was_ok = true;
309 receiver_ = receiver;
310
311 IPC_BEGIN_MESSAGE_MAP_EX(ResourceDispatcherHost, message, *message_was_ok) 299 IPC_BEGIN_MESSAGE_MAP_EX(ResourceDispatcherHost, message, *message_was_ok)
312 IPC_MESSAGE_HANDLER(ViewHostMsg_RequestResource, OnRequestResource) 300 IPC_MESSAGE_HANDLER(ViewHostMsg_RequestResource, OnRequestResource)
313 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_SyncLoad, OnSyncLoad) 301 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_SyncLoad, OnSyncLoad)
314 IPC_MESSAGE_HANDLER(ViewHostMsg_ReleaseDownloadedFile, 302 IPC_MESSAGE_HANDLER(ViewHostMsg_ReleaseDownloadedFile,
315 OnReleaseDownloadedFile) 303 OnReleaseDownloadedFile)
316 IPC_MESSAGE_HANDLER(ViewHostMsg_DataReceived_ACK, OnDataReceivedACK) 304 IPC_MESSAGE_HANDLER(ViewHostMsg_DataReceived_ACK, OnDataReceivedACK)
317 IPC_MESSAGE_HANDLER(ViewHostMsg_DataDownloaded_ACK, OnDataDownloadedACK) 305 IPC_MESSAGE_HANDLER(ViewHostMsg_DataDownloaded_ACK, OnDataDownloadedACK)
318 IPC_MESSAGE_HANDLER(ViewHostMsg_UploadProgress_ACK, OnUploadProgressACK) 306 IPC_MESSAGE_HANDLER(ViewHostMsg_UploadProgress_ACK, OnUploadProgressACK)
319 IPC_MESSAGE_HANDLER(ViewHostMsg_CancelRequest, OnCancelRequest) 307 IPC_MESSAGE_HANDLER(ViewHostMsg_CancelRequest, OnCancelRequest)
320 IPC_MESSAGE_HANDLER(ViewHostMsg_FollowRedirect, OnFollowRedirect) 308 IPC_MESSAGE_HANDLER(ViewHostMsg_FollowRedirect, OnFollowRedirect)
321 IPC_MESSAGE_HANDLER(ViewHostMsg_ClosePage_ACK, OnClosePageACK) 309 IPC_MESSAGE_HANDLER(ViewHostMsg_ClosePage_ACK, OnClosePageACK)
310 IPC_MESSAGE_UNHANDLED(handled = false)
322 IPC_END_MESSAGE_MAP_EX() 311 IPC_END_MESSAGE_MAP_EX()
323 312
324 receiver_ = NULL; 313 filter_ = NULL;
325 314 return handled;
326 return true;
327 } 315 }
328 316
329 void ResourceDispatcherHost::OnRequestResource( 317 void ResourceDispatcherHost::OnRequestResource(
330 const IPC::Message& message, 318 const IPC::Message& message,
331 int request_id, 319 int request_id,
332 const ViewHostMsg_Resource_Request& request_data) { 320 const ViewHostMsg_Resource_Request& request_data) {
333 BeginRequest(request_id, request_data, NULL, message.routing_id()); 321 BeginRequest(request_id, request_data, NULL, message.routing_id());
334 } 322 }
335 323
336 // Begins a resource request with the given params on behalf of the specified 324 // Begins a resource request with the given params on behalf of the specified
(...skipping 10 matching lines...) Expand all
347 IPC::Message* sync_result) { 335 IPC::Message* sync_result) {
348 BeginRequest(request_id, request_data, sync_result, 336 BeginRequest(request_id, request_data, sync_result,
349 sync_result->routing_id()); 337 sync_result->routing_id());
350 } 338 }
351 339
352 void ResourceDispatcherHost::BeginRequest( 340 void ResourceDispatcherHost::BeginRequest(
353 int request_id, 341 int request_id,
354 const ViewHostMsg_Resource_Request& request_data, 342 const ViewHostMsg_Resource_Request& request_data,
355 IPC::Message* sync_result, // only valid for sync 343 IPC::Message* sync_result, // only valid for sync
356 int route_id) { 344 int route_id) {
357 ChildProcessInfo::ProcessType process_type = receiver_->type(); 345 ChildProcessInfo::ProcessType process_type = filter_->process_type();
358 int child_id = receiver_->id(); 346 int child_id = filter_->child_id();
359 ChromeURLRequestContext* context = static_cast<ChromeURLRequestContext*>( 347
360 receiver_->GetRequestContext(request_id, request_data)); 348 ChromeURLRequestContext* context = filter_->GetURLRequestContext(
361 if (!context) { 349 request_id, request_data.resource_type);
362 URLRequestContextGetter* context_getter =
363 Profile::GetDefaultRequestContext();
364 if (context_getter) {
365 context = static_cast<ChromeURLRequestContext*>(
366 context_getter->GetURLRequestContext());
367 }
368 }
369 350
370 // Might need to resolve the blob references in the upload data. 351 // Might need to resolve the blob references in the upload data.
371 if (request_data.upload_data && context) { 352 if (request_data.upload_data && context) {
372 context->blob_storage_context()->controller()-> 353 context->blob_storage_context()->controller()->
373 ResolveBlobReferencesInUploadData(request_data.upload_data.get()); 354 ResolveBlobReferencesInUploadData(request_data.upload_data.get());
374 } 355 }
375 356
376 if (is_shutdown_ || 357 if (is_shutdown_ ||
377 !ShouldServiceRequest(process_type, child_id, request_data)) { 358 !ShouldServiceRequest(process_type, child_id, request_data)) {
378 URLRequestStatus status(URLRequestStatus::FAILED, net::ERR_ABORTED); 359 URLRequestStatus status(URLRequestStatus::FAILED, net::ERR_ABORTED);
379 if (sync_result) { 360 if (sync_result) {
380 SyncLoadResult result; 361 SyncLoadResult result;
381 result.status = status; 362 result.status = status;
382 ViewHostMsg_SyncLoad::WriteReplyParams(sync_result, result); 363 ViewHostMsg_SyncLoad::WriteReplyParams(sync_result, result);
383 receiver_->Send(sync_result); 364 filter_->Send(sync_result);
384 } else { 365 } else {
385 // Tell the renderer that this request was disallowed. 366 // Tell the renderer that this request was disallowed.
386 receiver_->Send(new ViewMsg_Resource_RequestComplete( 367 filter_->Send(new ViewMsg_Resource_RequestComplete(
387 route_id, 368 route_id,
388 request_id, 369 request_id,
389 status, 370 status,
390 std::string(), // No security info needed, connection was not 371 std::string(), // No security info needed, connection was not
391 base::Time())); // established. 372 base::Time())); // established.
392 } 373 }
393 return; 374 return;
394 } 375 }
395 376
396 // Ensure the Chrome plugins are loaded, as they may intercept network 377 // Ensure the Chrome plugins are loaded, as they may intercept network
397 // requests. Does nothing if they are already loaded. 378 // requests. Does nothing if they are already loaded.
398 // TODO(mpcomplete): This takes 200 ms! Investigate parallelizing this by 379 // TODO(mpcomplete): This takes 200 ms! Investigate parallelizing this by
399 // starting the load earlier in a BG thread. 380 // starting the load earlier in a BG thread.
400 PluginService::GetInstance()->LoadChromePlugins(this); 381 PluginService::GetInstance()->LoadChromePlugins(this);
401 382
402 // Construct the event handler. 383 // Construct the event handler.
403 scoped_refptr<ResourceHandler> handler; 384 scoped_refptr<ResourceHandler> handler;
404 if (sync_result) { 385 if (sync_result) {
405 handler = new SyncResourceHandler(receiver_, 386 handler = new SyncResourceHandler(
406 child_id, 387 filter_, request_data.url, sync_result, this);
407 request_data.url,
408 sync_result,
409 this);
410 } else { 388 } else {
411 handler = new AsyncResourceHandler(receiver_, 389 handler = new AsyncResourceHandler(
412 child_id, 390 filter_, route_id, request_data.url, this);
413 route_id,
414 receiver_->handle(),
415 request_data.url,
416 this);
417 } 391 }
418 392
419 // The RedirectToFileResourceHandler depends on being next in the chain. 393 // The RedirectToFileResourceHandler depends on being next in the chain.
420 if (request_data.download_to_file) 394 if (request_data.download_to_file)
421 handler = new RedirectToFileResourceHandler(handler, child_id, this); 395 handler = new RedirectToFileResourceHandler(handler, child_id, this);
422 396
423 if (HandleExternalProtocol(request_id, child_id, route_id, 397 if (HandleExternalProtocol(request_id, child_id, route_id,
424 request_data.url, request_data.resource_type, 398 request_data.url, request_data.resource_type,
425 handler)) { 399 handler)) {
426 return; 400 return;
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 route_id, 458 route_id,
485 this); 459 this);
486 } 460 }
487 461
488 // Insert a buffered event handler before the actual one. 462 // Insert a buffered event handler before the actual one.
489 handler = new BufferedResourceHandler(handler, this, request); 463 handler = new BufferedResourceHandler(handler, this, request);
490 464
491 // Insert safe browsing at the front of the chain, so it gets to decide 465 // Insert safe browsing at the front of the chain, so it gets to decide
492 // on policies first. 466 // on policies first.
493 if (safe_browsing_->enabled()) { 467 if (safe_browsing_->enabled()) {
494 handler = CreateSafeBrowsingResourceHandler(handler, child_id, route_id, 468 handler = CreateSafeBrowsingResourceHandler(handler, route_id,
495 request_data.resource_type); 469 request_data.resource_type);
496 } 470 }
497 471
498 #if defined(OS_CHROMEOS) 472 #if defined(OS_CHROMEOS)
499 // We check offline first, then check safe browsing so that we still can block 473 // We check offline first, then check safe browsing so that we still can block
500 // unsafe site after we remove offline page. 474 // unsafe site after we remove offline page.
501 handler = 475 handler =
502 new OfflineResourceHandler(handler, child_id, route_id, this, request); 476 new OfflineResourceHandler(handler, child_id, route_id, this, request);
503 #endif 477 #endif
504 478
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 // Have the appcache associate its extra info with the request. 511 // Have the appcache associate its extra info with the request.
538 appcache::AppCacheInterceptor::SetExtraRequestInfo( 512 appcache::AppCacheInterceptor::SetExtraRequestInfo(
539 request, context ? context->appcache_service() : NULL, child_id, 513 request, context ? context->appcache_service() : NULL, child_id,
540 request_data.appcache_host_id, request_data.resource_type); 514 request_data.appcache_host_id, request_data.resource_type);
541 515
542 BeginRequestInternal(request); 516 BeginRequestInternal(request);
543 } 517 }
544 518
545 void ResourceDispatcherHost::OnReleaseDownloadedFile(int request_id) { 519 void ResourceDispatcherHost::OnReleaseDownloadedFile(int request_id) {
546 DCHECK(pending_requests_.end() == 520 DCHECK(pending_requests_.end() ==
547 pending_requests_.find(GlobalRequestID(receiver_->id(), request_id))); 521 pending_requests_.find(
548 UnregisterDownloadedTempFile(receiver_->id(), request_id); 522 GlobalRequestID(filter_->child_id(), request_id)));
523 UnregisterDownloadedTempFile(filter_->child_id(), request_id);
549 } 524 }
550 525
551 void ResourceDispatcherHost::OnDataReceivedACK(int request_id) { 526 void ResourceDispatcherHost::OnDataReceivedACK(int request_id) {
552 DataReceivedACK(receiver_->id(), request_id); 527 DataReceivedACK(filter_->child_id(), request_id);
553 } 528 }
554 529
555 void ResourceDispatcherHost::DataReceivedACK(int child_id, 530 void ResourceDispatcherHost::DataReceivedACK(int child_id,
556 int request_id) { 531 int request_id) {
557 PendingRequestList::iterator i = pending_requests_.find( 532 PendingRequestList::iterator i = pending_requests_.find(
558 GlobalRequestID(child_id, request_id)); 533 GlobalRequestID(child_id, request_id));
559 if (i == pending_requests_.end()) 534 if (i == pending_requests_.end())
560 return; 535 return;
561 536
562 ResourceDispatcherHostRequestInfo* info = InfoForRequest(i->second); 537 ResourceDispatcherHostRequestInfo* info = InfoForRequest(i->second);
(...skipping 10 matching lines...) Expand all
573 // Resume the request. 548 // Resume the request.
574 PauseRequest(child_id, request_id, false); 549 PauseRequest(child_id, request_id, false);
575 } 550 }
576 } 551 }
577 552
578 void ResourceDispatcherHost::OnDataDownloadedACK(int request_id) { 553 void ResourceDispatcherHost::OnDataDownloadedACK(int request_id) {
579 // TODO(michaeln): maybe throttle DataDownloaded messages 554 // TODO(michaeln): maybe throttle DataDownloaded messages
580 } 555 }
581 556
582 void ResourceDispatcherHost::RegisterDownloadedTempFile( 557 void ResourceDispatcherHost::RegisterDownloadedTempFile(
583 int receiver_id, int request_id, DeletableFileReference* reference) { 558 int child_id, int request_id, DeletableFileReference* reference) {
584 // Note: receiver_id is the child_id is the render_process_id... 559 registered_temp_files_[child_id][request_id] = reference;
585 registered_temp_files_[receiver_id][request_id] = reference;
586 ChildProcessSecurityPolicy::GetInstance()->GrantReadFile( 560 ChildProcessSecurityPolicy::GetInstance()->GrantReadFile(
587 receiver_id, reference->path()); 561 child_id, reference->path());
588 } 562 }
589 563
590 void ResourceDispatcherHost::UnregisterDownloadedTempFile( 564 void ResourceDispatcherHost::UnregisterDownloadedTempFile(
591 int receiver_id, int request_id) { 565 int child_id, int request_id) {
592 DeletableFilesMap& map = registered_temp_files_[receiver_id]; 566 DeletableFilesMap& map = registered_temp_files_[child_id];
593 DeletableFilesMap::iterator found = map.find(request_id); 567 DeletableFilesMap::iterator found = map.find(request_id);
594 if (found == map.end()) 568 if (found == map.end())
595 return; 569 return;
596 570
597 ChildProcessSecurityPolicy::GetInstance()->RevokeAllPermissionsForFile( 571 ChildProcessSecurityPolicy::GetInstance()->RevokeAllPermissionsForFile(
598 receiver_id, found->second->path()); 572 child_id, found->second->path());
599 map.erase(found); 573 map.erase(found);
600 } 574 }
601 575
602 bool ResourceDispatcherHost::Send(IPC::Message* message) { 576 bool ResourceDispatcherHost::Send(IPC::Message* message) {
603 delete message; 577 delete message;
604 return false; 578 return false;
605 } 579 }
606 580
607 void ResourceDispatcherHost::OnUploadProgressACK(int request_id) { 581 void ResourceDispatcherHost::OnUploadProgressACK(int request_id) {
608 int child_id = receiver_->id(); 582 int child_id = filter_->child_id();
609 PendingRequestList::iterator i = pending_requests_.find( 583 PendingRequestList::iterator i = pending_requests_.find(
610 GlobalRequestID(child_id, request_id)); 584 GlobalRequestID(child_id, request_id));
611 if (i == pending_requests_.end()) 585 if (i == pending_requests_.end())
612 return; 586 return;
613 587
614 ResourceDispatcherHostRequestInfo* info = InfoForRequest(i->second); 588 ResourceDispatcherHostRequestInfo* info = InfoForRequest(i->second);
615 info->set_waiting_for_upload_progress_ack(false); 589 info->set_waiting_for_upload_progress_ack(false);
616 } 590 }
617 591
618 void ResourceDispatcherHost::OnCancelRequest(int request_id) { 592 void ResourceDispatcherHost::OnCancelRequest(int request_id) {
619 CancelRequest(receiver_->id(), request_id, true); 593 CancelRequest(filter_->child_id(), request_id, true);
620 } 594 }
621 595
622 void ResourceDispatcherHost::OnFollowRedirect( 596 void ResourceDispatcherHost::OnFollowRedirect(
623 int request_id, 597 int request_id,
624 bool has_new_first_party_for_cookies, 598 bool has_new_first_party_for_cookies,
625 const GURL& new_first_party_for_cookies) { 599 const GURL& new_first_party_for_cookies) {
626 FollowDeferredRedirect(receiver_->id(), request_id, 600 FollowDeferredRedirect(filter_->child_id(), request_id,
627 has_new_first_party_for_cookies, 601 has_new_first_party_for_cookies,
628 new_first_party_for_cookies); 602 new_first_party_for_cookies);
629 } 603 }
630 604
631 ResourceHandler* ResourceDispatcherHost::CreateSafeBrowsingResourceHandler( 605 ResourceHandler* ResourceDispatcherHost::CreateSafeBrowsingResourceHandler(
632 ResourceHandler* handler, int child_id, int route_id, 606 ResourceHandler* handler, int route_id, ResourceType::Type resource_type) {
633 ResourceType::Type resource_type) { 607 return new SafeBrowsingResourceHandler(
634 return new SafeBrowsingResourceHandler(handler, 608 handler, route_id, resource_type, safe_browsing_, this, filter_);
635 child_id,
636 route_id,
637 resource_type,
638 safe_browsing_,
639 this,
640 receiver_);
641 } 609 }
642 610
643 ResourceDispatcherHostRequestInfo* 611 ResourceDispatcherHostRequestInfo*
644 ResourceDispatcherHost::CreateRequestInfoForBrowserRequest( 612 ResourceDispatcherHost::CreateRequestInfoForBrowserRequest(
645 ResourceHandler* handler, int child_id, int route_id, bool download) { 613 ResourceHandler* handler, int child_id, int route_id, bool download) {
646 return new ResourceDispatcherHostRequestInfo(handler, 614 return new ResourceDispatcherHostRequestInfo(handler,
647 ChildProcessInfo::RENDER_PROCESS, 615 ChildProcessInfo::RENDER_PROCESS,
648 child_id, 616 child_id,
649 route_id, 617 route_id,
650 request_id_, 618 request_id_,
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
715 child_id, 683 child_id,
716 route_id, 684 route_id,
717 request_id_, 685 request_id_,
718 url, 686 url,
719 download_file_manager_.get(), 687 download_file_manager_.get(),
720 request, 688 request,
721 prompt_for_save_location, 689 prompt_for_save_location,
722 save_info)); 690 save_info));
723 691
724 if (safe_browsing_->enabled()) { 692 if (safe_browsing_->enabled()) {
725 handler = CreateSafeBrowsingResourceHandler(handler, child_id, route_id, 693 handler = CreateSafeBrowsingResourceHandler(handler, route_id,
726 ResourceType::MAIN_FRAME); 694 ResourceType::MAIN_FRAME);
727 } 695 }
728 696
729 if (!net::URLRequest::IsHandledURL(url)) { 697 if (!net::URLRequest::IsHandledURL(url)) {
730 VLOG(1) << "Download request for unsupported protocol: " 698 VLOG(1) << "Download request for unsupported protocol: "
731 << url.possibly_invalid_spec(); 699 << url.possibly_invalid_spec();
732 return; 700 return;
733 } 701 }
734 702
735 request->set_method("GET"); 703 request->set_method("GET");
(...skipping 1123 matching lines...) Expand 10 before | Expand all | Expand 10 after
1859 bool ResourceDispatcherHost::IsValidRequest(net::URLRequest* request) { 1827 bool ResourceDispatcherHost::IsValidRequest(net::URLRequest* request) {
1860 if (!request) 1828 if (!request)
1861 return false; 1829 return false;
1862 ResourceDispatcherHostRequestInfo* info = InfoForRequest(request); 1830 ResourceDispatcherHostRequestInfo* info = InfoForRequest(request);
1863 return pending_requests_.find( 1831 return pending_requests_.find(
1864 GlobalRequestID(info->child_id(), info->request_id())) != 1832 GlobalRequestID(info->child_id(), info->request_id())) !=
1865 pending_requests_.end(); 1833 pending_requests_.end();
1866 } 1834 }
1867 1835
1868 // static 1836 // static
1869 bool ResourceDispatcherHost::IsResourceDispatcherHostMessage(
1870 const IPC::Message& message) {
1871 switch (message.type()) {
1872 case ViewHostMsg_RequestResource::ID:
1873 case ViewHostMsg_CancelRequest::ID:
1874 case ViewHostMsg_FollowRedirect::ID:
1875 case ViewHostMsg_ClosePage_ACK::ID:
1876 case ViewHostMsg_ReleaseDownloadedFile::ID:
1877 case ViewHostMsg_DataReceived_ACK::ID:
1878 case ViewHostMsg_DataDownloaded_ACK::ID:
1879 case ViewHostMsg_UploadProgress_ACK::ID:
1880 case ViewHostMsg_SyncLoad::ID:
1881 return true;
1882
1883 default:
1884 break;
1885 }
1886
1887 return false;
1888 }
1889
1890 // static
1891 void ResourceDispatcherHost::ApplyExtensionLocalizationFilter( 1837 void ResourceDispatcherHost::ApplyExtensionLocalizationFilter(
1892 const GURL& url, 1838 const GURL& url,
1893 const ResourceType::Type& resource_type, 1839 const ResourceType::Type& resource_type,
1894 ResourceDispatcherHostRequestInfo* request_info) { 1840 ResourceDispatcherHostRequestInfo* request_info) {
1895 // Apply filter to chrome extension CSS files. 1841 // Apply filter to chrome extension CSS files.
1896 if (url.SchemeIs(chrome::kExtensionScheme) && 1842 if (url.SchemeIs(chrome::kExtensionScheme) &&
1897 resource_type == ResourceType::STYLESHEET) 1843 resource_type == ResourceType::STYLESHEET)
1898 request_info->set_replace_extension_localization_templates(); 1844 request_info->set_replace_extension_localization_templates();
1899 } 1845 }
1900 1846
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
1957 return is_prefetch_enabled_; 1903 return is_prefetch_enabled_;
1958 } 1904 }
1959 1905
1960 // static 1906 // static
1961 void ResourceDispatcherHost::set_is_prefetch_enabled(bool value) { 1907 void ResourceDispatcherHost::set_is_prefetch_enabled(bool value) {
1962 is_prefetch_enabled_ = value; 1908 is_prefetch_enabled_ = value;
1963 } 1909 }
1964 1910
1965 // static 1911 // static
1966 bool ResourceDispatcherHost::is_prefetch_enabled_ = false; 1912 bool ResourceDispatcherHost::is_prefetch_enabled_ = false;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698