| 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 | 53 |
| 54 namespace storage { | 54 namespace storage { |
| 55 class ShareableFileReference; | 55 class ShareableFileReference; |
| 56 } | 56 } |
| 57 | 57 |
| 58 namespace content { | 58 namespace content { |
| 59 class AppCacheService; | 59 class AppCacheService; |
| 60 class AsyncRevalidationManager; | 60 class AsyncRevalidationManager; |
| 61 class CertStore; | 61 class CertStore; |
| 62 class FrameTree; | 62 class FrameTree; |
| 63 class LoaderDelegate; |
| 63 class NavigationURLLoaderImplCore; | 64 class NavigationURLLoaderImplCore; |
| 64 class RenderFrameHostImpl; | 65 class RenderFrameHostImpl; |
| 65 class ResourceContext; | 66 class ResourceContext; |
| 66 class ResourceDispatcherHostDelegate; | 67 class ResourceDispatcherHostDelegate; |
| 67 class ResourceMessageDelegate; | 68 class ResourceMessageDelegate; |
| 68 class ResourceMessageFilter; | 69 class ResourceMessageFilter; |
| 69 class ResourceRequestInfoImpl; | 70 class ResourceRequestInfoImpl; |
| 70 class SaveFileManager; | 71 class SaveFileManager; |
| 71 class ServiceWorkerNavigationHandleCore; | 72 class ServiceWorkerNavigationHandleCore; |
| 72 class WebContentsImpl; | 73 class WebContentsImpl; |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 void BeginNavigationRequest( | 300 void BeginNavigationRequest( |
| 300 ResourceContext* resource_context, | 301 ResourceContext* resource_context, |
| 301 const NavigationRequestInfo& info, | 302 const NavigationRequestInfo& info, |
| 302 NavigationURLLoaderImplCore* loader, | 303 NavigationURLLoaderImplCore* loader, |
| 303 ServiceWorkerNavigationHandleCore* service_worker_handle_core); | 304 ServiceWorkerNavigationHandleCore* service_worker_handle_core); |
| 304 | 305 |
| 305 // Turns on stale-while-revalidate support, regardless of command-line flags | 306 // Turns on stale-while-revalidate support, regardless of command-line flags |
| 306 // or experiment status. For unit tests only. | 307 // or experiment status. For unit tests only. |
| 307 void EnableStaleWhileRevalidateForTesting(); | 308 void EnableStaleWhileRevalidateForTesting(); |
| 308 | 309 |
| 310 void SetLoaderDelegate(LoaderDelegate* loader_delegate); |
| 311 |
| 309 private: | 312 private: |
| 310 friend class LoaderIOThreadNotifier; | 313 friend class LoaderIOThreadNotifier; |
| 311 friend class ResourceDispatcherHostTest; | 314 friend class ResourceDispatcherHostTest; |
| 312 | 315 |
| 313 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest, | 316 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest, |
| 314 TestBlockedRequestsProcessDies); | 317 TestBlockedRequestsProcessDies); |
| 315 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest, | 318 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest, |
| 316 CalculateApproximateMemoryCost); | 319 CalculateApproximateMemoryCost); |
| 317 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest, | 320 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest, |
| 318 DetachableResourceTimesOut); | 321 DetachableResourceTimesOut); |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 431 // listed in the order in which they usually occur during the lifetime of a | 434 // listed in the order in which they usually occur during the lifetime of a |
| 432 // request, so states with larger numeric values are generally further along | 435 // request, so states with larger numeric values are generally further along |
| 433 // toward completion. | 436 // toward completion. |
| 434 // | 437 // |
| 435 // For example, by this measure "tranferring data" is a more interesting state | 438 // For example, by this measure "tranferring data" is a more interesting state |
| 436 // than "resolving host" because when transferring data something is being | 439 // than "resolving host" because when transferring data something is being |
| 437 // done that corresponds to changes that the user might observe, whereas | 440 // done that corresponds to changes that the user might observe, whereas |
| 438 // waiting for a host name to resolve implies being stuck. | 441 // waiting for a host name to resolve implies being stuck. |
| 439 static bool LoadInfoIsMoreInteresting(const LoadInfo& a, const LoadInfo& b); | 442 static bool LoadInfoIsMoreInteresting(const LoadInfo& a, const LoadInfo& b); |
| 440 | 443 |
| 441 // Used to marshal calls to LoadStateChanged from the IO to UI threads. All | |
| 442 // are done as a single callback to avoid spamming the UI thread. | |
| 443 static void UpdateLoadInfoOnUIThread(std::unique_ptr<LoadInfoMap> info_map); | |
| 444 | |
| 445 // Gets the most interesting LoadInfo for each GlobalRoutingID. | 444 // Gets the most interesting LoadInfo for each GlobalRoutingID. |
| 446 std::unique_ptr<LoadInfoMap> GetLoadInfoForAllRoutes(); | 445 std::unique_ptr<LoadInfoMap> GetLoadInfoForAllRoutes(); |
| 447 | 446 |
| 448 // Checks all pending requests and updates the load info if necessary. | 447 // Checks all pending requests and updates the load info if necessary. |
| 449 void UpdateLoadInfo(); | 448 void UpdateLoadInfo(); |
| 450 | 449 |
| 451 // Resumes or cancels (if |cancel_requests| is true) any blocked requests. | 450 // Resumes or cancels (if |cancel_requests| is true) any blocked requests. |
| 452 void ProcessBlockedRequestsForRoute( | 451 void ProcessBlockedRequestsForRoute( |
| 453 const GlobalFrameRoutingId& global_routing_id, | 452 const GlobalFrameRoutingId& global_routing_id, |
| 454 bool cancel_requests); | 453 bool cancel_requests); |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 626 // flag to requests occurring soon after a gesture to indicate they | 625 // flag to requests occurring soon after a gesture to indicate they |
| 627 // may be because of explicit user action. | 626 // may be because of explicit user action. |
| 628 base::TimeTicks last_user_gesture_time_; | 627 base::TimeTicks last_user_gesture_time_; |
| 629 | 628 |
| 630 // Used during IPC message dispatching so that the handlers can get a pointer | 629 // Used during IPC message dispatching so that the handlers can get a pointer |
| 631 // to the source of the message. | 630 // to the source of the message. |
| 632 ResourceMessageFilter* filter_; | 631 ResourceMessageFilter* filter_; |
| 633 | 632 |
| 634 ResourceDispatcherHostDelegate* delegate_; | 633 ResourceDispatcherHostDelegate* delegate_; |
| 635 | 634 |
| 635 LoaderDelegate* loader_delegate_; |
| 636 |
| 636 bool allow_cross_origin_auth_prompt_; | 637 bool allow_cross_origin_auth_prompt_; |
| 637 | 638 |
| 638 // AsyncRevalidationManager is non-NULL if and only if | 639 // AsyncRevalidationManager is non-NULL if and only if |
| 639 // stale-while-revalidate is enabled. | 640 // stale-while-revalidate is enabled. |
| 640 std::unique_ptr<AsyncRevalidationManager> async_revalidation_manager_; | 641 std::unique_ptr<AsyncRevalidationManager> async_revalidation_manager_; |
| 641 | 642 |
| 642 typedef std::map<GlobalRequestID, | 643 typedef std::map<GlobalRequestID, |
| 643 base::ObserverList<ResourceMessageDelegate>*> DelegateMap; | 644 base::ObserverList<ResourceMessageDelegate>*> DelegateMap; |
| 644 DelegateMap delegate_map_; | 645 DelegateMap delegate_map_; |
| 645 | 646 |
| 646 std::unique_ptr<ResourceScheduler> scheduler_; | 647 std::unique_ptr<ResourceScheduler> scheduler_; |
| 647 | 648 |
| 648 // Allows tests to use a mock CertStore. If set, the CertStore must | 649 // Allows tests to use a mock CertStore. If set, the CertStore must |
| 649 // outlive this ResourceDispatcherHostImpl. | 650 // outlive this ResourceDispatcherHostImpl. |
| 650 CertStore* cert_store_for_testing_; | 651 CertStore* cert_store_for_testing_; |
| 651 | 652 |
| 652 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcherHostImpl); | 653 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcherHostImpl); |
| 653 }; | 654 }; |
| 654 | 655 |
| 655 } // namespace content | 656 } // namespace content |
| 656 | 657 |
| 657 #endif // CONTENT_BROWSER_LOADER_RESOURCE_DISPATCHER_HOST_IMPL_H_ | 658 #endif // CONTENT_BROWSER_LOADER_RESOURCE_DISPATCHER_HOST_IMPL_H_ |
| OLD | NEW |