| 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 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 506 // WebContents. | 506 // WebContents. |
| 507 static std::unique_ptr<LoadInfoMap> PickMoreInterestingLoadInfos( | 507 static std::unique_ptr<LoadInfoMap> PickMoreInterestingLoadInfos( |
| 508 std::unique_ptr<LoadInfoList> infos); | 508 std::unique_ptr<LoadInfoList> infos); |
| 509 | 509 |
| 510 // Gets all the LoadInfos for each pending request. | 510 // Gets all the LoadInfos for each pending request. |
| 511 std::unique_ptr<LoadInfoList> GetLoadInfoForAllRoutes(); | 511 std::unique_ptr<LoadInfoList> GetLoadInfoForAllRoutes(); |
| 512 | 512 |
| 513 // Checks all pending requests and updates the load info if necessary. | 513 // Checks all pending requests and updates the load info if necessary. |
| 514 void UpdateLoadInfo(); | 514 void UpdateLoadInfo(); |
| 515 | 515 |
| 516 // Records statistics about outstanding requests since the last call, and |
| 517 // reset the stats. |
| 518 void RecordOutstandingRequestsStats(); |
| 519 |
| 516 // Resumes or cancels (if |cancel_requests| is true) any blocked requests. | 520 // Resumes or cancels (if |cancel_requests| is true) any blocked requests. |
| 517 void ProcessBlockedRequestsForRoute( | 521 void ProcessBlockedRequestsForRoute( |
| 518 const GlobalFrameRoutingId& global_routing_id, | 522 const GlobalFrameRoutingId& global_routing_id, |
| 519 bool cancel_requests); | 523 bool cancel_requests); |
| 520 | 524 |
| 521 void OnRequestResource(ResourceRequesterInfo* requester_info, | 525 void OnRequestResource(ResourceRequesterInfo* requester_info, |
| 522 int routing_id, | 526 int routing_id, |
| 523 int request_id, | 527 int request_id, |
| 524 const ResourceRequest& request_data); | 528 const ResourceRequest& request_data); |
| 525 | 529 |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 688 // is not throttled. If the download is to be throttled (Decided by the | 692 // is not throttled. If the download is to be throttled (Decided by the |
| 689 // delegate) the function returns a ThrottlingResourceHandler to handle the | 693 // delegate) the function returns a ThrottlingResourceHandler to handle the |
| 690 // download. | 694 // download. |
| 691 std::unique_ptr<ResourceHandler> HandleDownloadStarted( | 695 std::unique_ptr<ResourceHandler> HandleDownloadStarted( |
| 692 net::URLRequest* request, | 696 net::URLRequest* request, |
| 693 std::unique_ptr<ResourceHandler> handler, | 697 std::unique_ptr<ResourceHandler> handler, |
| 694 bool is_content_initiated, | 698 bool is_content_initiated, |
| 695 bool must_download, | 699 bool must_download, |
| 696 bool is_new_request); | 700 bool is_new_request); |
| 697 | 701 |
| 702 // Returns true if there are two or more processes that are not network |
| 703 // 2-quiet (i.e. have at least three outstanding requests). |
| 704 bool HasRequestsFromMultipleActiveProcesses(); |
| 705 |
| 698 LoaderMap pending_loaders_; | 706 LoaderMap pending_loaders_; |
| 699 | 707 |
| 700 // Collection of temp files downloaded for child processes via | 708 // Collection of temp files downloaded for child processes via |
| 701 // the download_to_file mechanism. We avoid deleting them until | 709 // the download_to_file mechanism. We avoid deleting them until |
| 702 // the client no longer needs them. | 710 // the client no longer needs them. |
| 703 typedef std::map<int, scoped_refptr<storage::ShareableFileReference> > | 711 typedef std::map<int, scoped_refptr<storage::ShareableFileReference> > |
| 704 DeletableFilesMap; // key is request id | 712 DeletableFilesMap; // key is request id |
| 705 typedef std::map<int, DeletableFilesMap> | 713 typedef std::map<int, DeletableFilesMap> |
| 706 RegisteredTempFiles; // key is child process id | 714 RegisteredTempFiles; // key is child process id |
| 707 RegisteredTempFiles registered_temp_files_; | 715 RegisteredTempFiles registered_temp_files_; |
| 708 | 716 |
| 709 // A timer that periodically calls UpdateLoadInfo while pending_loaders_ is | 717 // A timer that periodically calls UpdateLoadInfo while pending_loaders_ is |
| 710 // not empty and at least one RenderViewHost is loading. | 718 // not empty and at least one RenderViewHost is loading. |
| 711 std::unique_ptr<base::RepeatingTimer> update_load_states_timer_; | 719 std::unique_ptr<base::RepeatingTimer> update_load_states_timer_; |
| 712 | 720 |
| 721 // A timer that periodically calls RecordOutstandingRequestsStats. |
| 722 std::unique_ptr<base::RepeatingTimer> |
| 723 record_outstanding_requests_stats_timer_; |
| 724 |
| 713 // Request ID for browser initiated requests. request_ids generated by | 725 // Request ID for browser initiated requests. request_ids generated by |
| 714 // child processes are counted up from 0, while browser created requests | 726 // child processes are counted up from 0, while browser created requests |
| 715 // start at -2 and go down from there. (We need to start at -2 because -1 is | 727 // start at -2 and go down from there. (We need to start at -2 because -1 is |
| 716 // used as a special value all over the resource_dispatcher_host for | 728 // used as a special value all over the resource_dispatcher_host for |
| 717 // uninitialized variables.) This way, we no longer have the unlikely (but | 729 // uninitialized variables.) This way, we no longer have the unlikely (but |
| 718 // observed in the real world!) event where we have two requests with the same | 730 // observed in the real world!) event where we have two requests with the same |
| 719 // request_id_. | 731 // request_id_. |
| 720 int request_id_; | 732 int request_id_; |
| 721 | 733 |
| 722 // True if the resource dispatcher host has been shut down. | 734 // True if the resource dispatcher host has been shut down. |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 756 // (max_outstanding_requests_cost_per_process_ / | 768 // (max_outstanding_requests_cost_per_process_ / |
| 757 // kAvgBytesPerOutstandingRequest) | 769 // kAvgBytesPerOutstandingRequest) |
| 758 int max_outstanding_requests_cost_per_process_; | 770 int max_outstanding_requests_cost_per_process_; |
| 759 | 771 |
| 760 // Largest number of outstanding requests seen so far across all processes. | 772 // Largest number of outstanding requests seen so far across all processes. |
| 761 int largest_outstanding_request_count_seen_; | 773 int largest_outstanding_request_count_seen_; |
| 762 | 774 |
| 763 // Largest number of outstanding requests seen so far in any single process. | 775 // Largest number of outstanding requests seen so far in any single process. |
| 764 int largest_outstanding_request_per_process_count_seen_; | 776 int largest_outstanding_request_per_process_count_seen_; |
| 765 | 777 |
| 778 // Largest number of outstanding requests seen since the last call to |
| 779 // RecordOutstandingRequestsStats. |
| 780 int peak_outstanding_request_count_; |
| 781 |
| 782 // Largest number of outstanding requests seen while there are outstanding |
| 783 // requests from two or more processes, since the last call to |
| 784 // RecordOutstandingRequestsStats. |
| 785 int peak_outstanding_request_count_multitab_ = 0; |
| 786 |
| 766 // Time of the last user gesture. Stored so that we can add a load | 787 // Time of the last user gesture. Stored so that we can add a load |
| 767 // flag to requests occurring soon after a gesture to indicate they | 788 // flag to requests occurring soon after a gesture to indicate they |
| 768 // may be because of explicit user action. | 789 // may be because of explicit user action. |
| 769 base::TimeTicks last_user_gesture_time_; | 790 base::TimeTicks last_user_gesture_time_; |
| 770 | 791 |
| 771 ResourceDispatcherHostDelegate* delegate_; | 792 ResourceDispatcherHostDelegate* delegate_; |
| 772 | 793 |
| 773 LoaderDelegate* loader_delegate_; | 794 LoaderDelegate* loader_delegate_; |
| 774 | 795 |
| 775 bool allow_cross_origin_auth_prompt_; | 796 bool allow_cross_origin_auth_prompt_; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 794 | 815 |
| 795 // Whether experimental web platform features are enabled. | 816 // Whether experimental web platform features are enabled. |
| 796 bool experimental_web_features_enabled_; | 817 bool experimental_web_features_enabled_; |
| 797 | 818 |
| 798 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcherHostImpl); | 819 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcherHostImpl); |
| 799 }; | 820 }; |
| 800 | 821 |
| 801 } // namespace content | 822 } // namespace content |
| 802 | 823 |
| 803 #endif // CONTENT_BROWSER_LOADER_RESOURCE_DISPATCHER_HOST_IMPL_H_ | 824 #endif // CONTENT_BROWSER_LOADER_RESOURCE_DISPATCHER_HOST_IMPL_H_ |
| OLD | NEW |