| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // This is the browser side of the resource dispatcher, it receives requests | 5 // This is the browser side of the resource dispatcher, it receives requests |
| 6 // from the child process (i.e. [Renderer, Plugin, Worker]ProcessHost), and | 6 // from the child process (i.e. [Renderer, Plugin, Worker]ProcessHost), and |
| 7 // dispatches them to URLRequests. It then forwards the messages from the | 7 // dispatches them to URLRequests. It then forwards the messages from the |
| 8 // URLRequests back to the correct process for handling. | 8 // URLRequests back to the correct process for handling. |
| 9 // | 9 // |
| 10 // See http://dev.chromium.org/developers/design-documents/multi-process-resourc
e-loading | 10 // See http://dev.chromium.org/developers/design-documents/multi-process-resourc
e-loading |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 #include "content/public/browser/notification_types.h" | 40 #include "content/public/browser/notification_types.h" |
| 41 #include "content/public/browser/resource_dispatcher_host.h" | 41 #include "content/public/browser/resource_dispatcher_host.h" |
| 42 #include "content/public/browser/web_contents_observer.h" | 42 #include "content/public/browser/web_contents_observer.h" |
| 43 #include "content/public/common/resource_type.h" | 43 #include "content/public/common/resource_type.h" |
| 44 #include "ipc/ipc_message.h" | 44 #include "ipc/ipc_message.h" |
| 45 #include "net/base/request_priority.h" | 45 #include "net/base/request_priority.h" |
| 46 #include "net/cookies/canonical_cookie.h" | 46 #include "net/cookies/canonical_cookie.h" |
| 47 #include "net/url_request/url_request.h" | 47 #include "net/url_request/url_request.h" |
| 48 | 48 |
| 49 class ResourceHandler; | 49 class ResourceHandler; |
| 50 struct ResourceHostMsg_Request; | |
| 51 | 50 |
| 52 namespace base { | 51 namespace base { |
| 53 class FilePath; | 52 class FilePath; |
| 54 } | 53 } |
| 55 | 54 |
| 56 namespace net { | 55 namespace net { |
| 57 class URLRequestJobFactory; | 56 class URLRequestJobFactory; |
| 58 } | 57 } |
| 59 | 58 |
| 60 namespace storage { | 59 namespace storage { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 73 class ResourceMessageDelegate; | 72 class ResourceMessageDelegate; |
| 74 class ResourceMessageFilter; | 73 class ResourceMessageFilter; |
| 75 class ResourceRequestInfoImpl; | 74 class ResourceRequestInfoImpl; |
| 76 class SaveFileManager; | 75 class SaveFileManager; |
| 77 class ServiceWorkerNavigationHandleCore; | 76 class ServiceWorkerNavigationHandleCore; |
| 78 class WebContentsImpl; | 77 class WebContentsImpl; |
| 79 struct CommonNavigationParams; | 78 struct CommonNavigationParams; |
| 80 struct DownloadSaveInfo; | 79 struct DownloadSaveInfo; |
| 81 struct NavigationRequestInfo; | 80 struct NavigationRequestInfo; |
| 82 struct Referrer; | 81 struct Referrer; |
| 82 struct ResourceRequest; |
| 83 | 83 |
| 84 // This class is responsible for notifying the IO thread (specifically, the | 84 // This class is responsible for notifying the IO thread (specifically, the |
| 85 // ResourceDispatcherHostImpl) of frame events. It has an interace for callers | 85 // ResourceDispatcherHostImpl) of frame events. It has an interace for callers |
| 86 // to use and also sends notifications on WebContentsObserver events. All | 86 // to use and also sends notifications on WebContentsObserver events. All |
| 87 // methods (static or class) will be called from the UI thread and post to the | 87 // methods (static or class) will be called from the UI thread and post to the |
| 88 // IO thread. | 88 // IO thread. |
| 89 // TODO(csharrison): Add methods tracking visibility and audio changes, to | 89 // TODO(csharrison): Add methods tracking visibility and audio changes, to |
| 90 // propogate to the ResourceScheduler. | 90 // propogate to the ResourceScheduler. |
| 91 class LoaderIOThreadNotifier : public WebContentsObserver { | 91 class LoaderIOThreadNotifier : public WebContentsObserver { |
| 92 public: | 92 public: |
| (...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 458 // Checks all pending requests and updates the load info if necessary. | 458 // Checks all pending requests and updates the load info if necessary. |
| 459 void UpdateLoadInfo(); | 459 void UpdateLoadInfo(); |
| 460 | 460 |
| 461 // Resumes or cancels (if |cancel_requests| is true) any blocked requests. | 461 // Resumes or cancels (if |cancel_requests| is true) any blocked requests. |
| 462 void ProcessBlockedRequestsForRoute( | 462 void ProcessBlockedRequestsForRoute( |
| 463 const GlobalFrameRoutingId& global_routing_id, | 463 const GlobalFrameRoutingId& global_routing_id, |
| 464 bool cancel_requests); | 464 bool cancel_requests); |
| 465 | 465 |
| 466 void OnRequestResource(int routing_id, | 466 void OnRequestResource(int routing_id, |
| 467 int request_id, | 467 int request_id, |
| 468 const ResourceHostMsg_Request& request_data); | 468 const ResourceRequest& request_data); |
| 469 void OnSyncLoad(int request_id, | 469 void OnSyncLoad(int request_id, |
| 470 const ResourceHostMsg_Request& request_data, | 470 const ResourceRequest& request_data, |
| 471 IPC::Message* sync_result); | 471 IPC::Message* sync_result); |
| 472 | 472 |
| 473 bool IsRequestIDInUse(const GlobalRequestID& id) const; | 473 bool IsRequestIDInUse(const GlobalRequestID& id) const; |
| 474 | 474 |
| 475 // Update the ResourceRequestInfo and internal maps when a request is | 475 // Update the ResourceRequestInfo and internal maps when a request is |
| 476 // transferred from one process to another. | 476 // transferred from one process to another. |
| 477 void UpdateRequestForTransfer(int child_id, | 477 void UpdateRequestForTransfer(int child_id, |
| 478 int route_id, | 478 int route_id, |
| 479 int request_id, | 479 int request_id, |
| 480 const ResourceHostMsg_Request& request_data, | 480 const ResourceRequest& request_data, |
| 481 LoaderMap::iterator iter); | 481 LoaderMap::iterator iter); |
| 482 | 482 |
| 483 void BeginRequest(int request_id, | 483 void BeginRequest(int request_id, |
| 484 const ResourceHostMsg_Request& request_data, | 484 const ResourceRequest& request_data, |
| 485 IPC::Message* sync_result, // only valid for sync | 485 IPC::Message* sync_result, // only valid for sync |
| 486 int route_id); // only valid for async | 486 int route_id); // only valid for async |
| 487 | 487 |
| 488 // Creates a ResourceHandler to be used by BeginRequest() for normal resource | 488 // Creates a ResourceHandler to be used by BeginRequest() for normal resource |
| 489 // loading. | 489 // loading. |
| 490 std::unique_ptr<ResourceHandler> CreateResourceHandler( | 490 std::unique_ptr<ResourceHandler> CreateResourceHandler( |
| 491 net::URLRequest* request, | 491 net::URLRequest* request, |
| 492 const ResourceHostMsg_Request& request_data, | 492 const ResourceRequest& request_data, |
| 493 IPC::Message* sync_result, | 493 IPC::Message* sync_result, |
| 494 int route_id, | 494 int route_id, |
| 495 int process_type, | 495 int process_type, |
| 496 int child_id, | 496 int child_id, |
| 497 ResourceContext* resource_context); | 497 ResourceContext* resource_context); |
| 498 | 498 |
| 499 // Wraps |handler| in the standard resource handlers for normal resource | 499 // Wraps |handler| in the standard resource handlers for normal resource |
| 500 // loading and navigation requests. This adds MimeTypeResourceHandler and | 500 // loading and navigation requests. This adds MimeTypeResourceHandler and |
| 501 // ResourceThrottles. | 501 // ResourceThrottles. |
| 502 std::unique_ptr<ResourceHandler> AddStandardHandlers( | 502 std::unique_ptr<ResourceHandler> AddStandardHandlers( |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 546 ResourceLoader* GetLoader(const GlobalRequestID& id) const; | 546 ResourceLoader* GetLoader(const GlobalRequestID& id) const; |
| 547 ResourceLoader* GetLoader(int child_id, int request_id) const; | 547 ResourceLoader* GetLoader(int child_id, int request_id) const; |
| 548 | 548 |
| 549 // Registers |delegate| to receive resource IPC messages targeted to the | 549 // Registers |delegate| to receive resource IPC messages targeted to the |
| 550 // specified |id|. | 550 // specified |id|. |
| 551 void RegisterResourceMessageDelegate(const GlobalRequestID& id, | 551 void RegisterResourceMessageDelegate(const GlobalRequestID& id, |
| 552 ResourceMessageDelegate* delegate); | 552 ResourceMessageDelegate* delegate); |
| 553 void UnregisterResourceMessageDelegate(const GlobalRequestID& id, | 553 void UnregisterResourceMessageDelegate(const GlobalRequestID& id, |
| 554 ResourceMessageDelegate* delegate); | 554 ResourceMessageDelegate* delegate); |
| 555 | 555 |
| 556 int BuildLoadFlagsForRequest(const ResourceHostMsg_Request& request_data, | 556 int BuildLoadFlagsForRequest(const ResourceRequest& request_data, |
| 557 int child_id, | 557 int child_id, |
| 558 bool is_sync_load); | 558 bool is_sync_load); |
| 559 | 559 |
| 560 // The certificate on a ResourceResponse is associated with a | 560 // The certificate on a ResourceResponse is associated with a |
| 561 // particular renderer process. As a transfer to a new process | 561 // particular renderer process. As a transfer to a new process |
| 562 // completes, the stored certificate has to be updated to reflect the | 562 // completes, the stored certificate has to be updated to reflect the |
| 563 // new renderer process. | 563 // new renderer process. |
| 564 void UpdateResponseCertificateForTransfer(ResourceResponse* response, | 564 void UpdateResponseCertificateForTransfer(ResourceResponse* response, |
| 565 const net::SSLInfo& ssl_info, | 565 const net::SSLInfo& ssl_info, |
| 566 int child_id); | 566 int child_id); |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 662 // Allows tests to use a mock CertStore. If set, the CertStore must | 662 // Allows tests to use a mock CertStore. If set, the CertStore must |
| 663 // outlive this ResourceDispatcherHostImpl. | 663 // outlive this ResourceDispatcherHostImpl. |
| 664 CertStore* cert_store_for_testing_; | 664 CertStore* cert_store_for_testing_; |
| 665 | 665 |
| 666 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcherHostImpl); | 666 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcherHostImpl); |
| 667 }; | 667 }; |
| 668 | 668 |
| 669 } // namespace content | 669 } // namespace content |
| 670 | 670 |
| 671 #endif // CONTENT_BROWSER_LOADER_RESOURCE_DISPATCHER_HOST_IMPL_H_ | 671 #endif // CONTENT_BROWSER_LOADER_RESOURCE_DISPATCHER_HOST_IMPL_H_ |
| OLD | NEW |