| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 fowards the messages from the | 7 // dispatches them to URLRequests. It then fowards 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 // Holds the data we would like to associate with each request | 54 // Holds the data we would like to associate with each request |
| 55 class ExtraRequestInfo : public URLRequest::UserData { | 55 class ExtraRequestInfo : public URLRequest::UserData { |
| 56 friend class ResourceDispatcherHost; | 56 friend class ResourceDispatcherHost; |
| 57 public: | 57 public: |
| 58 ExtraRequestInfo(ResourceHandler* handler, | 58 ExtraRequestInfo(ResourceHandler* handler, |
| 59 ChildProcessInfo::ProcessType process_type, | 59 ChildProcessInfo::ProcessType process_type, |
| 60 int process_id, | 60 int process_id, |
| 61 int route_id, | 61 int route_id, |
| 62 int request_id, | 62 int request_id, |
| 63 bool mixed_content, | 63 std::string frame_origin, |
| 64 std::string main_frame_origin, |
| 64 ResourceType::Type resource_type, | 65 ResourceType::Type resource_type, |
| 65 uint64 upload_size) | 66 uint64 upload_size) |
| 66 : resource_handler(handler), | 67 : resource_handler(handler), |
| 67 cross_site_handler(NULL), | 68 cross_site_handler(NULL), |
| 68 login_handler(NULL), | 69 login_handler(NULL), |
| 69 process_type(process_type), | 70 process_type(process_type), |
| 70 process_id(process_id), | 71 process_id(process_id), |
| 71 route_id(route_id), | 72 route_id(route_id), |
| 72 request_id(request_id), | 73 request_id(request_id), |
| 73 pending_data_count(0), | 74 pending_data_count(0), |
| 74 is_download(false), | 75 is_download(false), |
| 75 pause_count(0), | 76 pause_count(0), |
| 76 mixed_content(mixed_content), | 77 frame_origin(frame_origin), |
| 78 main_frame_origin(main_frame_origin), |
| 77 resource_type(resource_type), | 79 resource_type(resource_type), |
| 78 filter_policy(FilterPolicy::DONT_FILTER), | 80 filter_policy(FilterPolicy::DONT_FILTER), |
| 79 last_load_state(net::LOAD_STATE_IDLE), | 81 last_load_state(net::LOAD_STATE_IDLE), |
| 80 upload_size(upload_size), | 82 upload_size(upload_size), |
| 81 last_upload_position(0), | 83 last_upload_position(0), |
| 82 waiting_for_upload_progress_ack(false), | 84 waiting_for_upload_progress_ack(false), |
| 83 memory_cost(0), | 85 memory_cost(0), |
| 84 is_paused(false), | 86 is_paused(false), |
| 85 has_started_reading(false), | 87 has_started_reading(false), |
| 86 paused_read_bytes(0) { | 88 paused_read_bytes(0) { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 108 | 110 |
| 109 // Downloads allowed only as a top level request. | 111 // Downloads allowed only as a top level request. |
| 110 bool allow_download; | 112 bool allow_download; |
| 111 | 113 |
| 112 // Whether this is a download. | 114 // Whether this is a download. |
| 113 bool is_download; | 115 bool is_download; |
| 114 | 116 |
| 115 // The number of clients that have called pause on this request. | 117 // The number of clients that have called pause on this request. |
| 116 int pause_count; | 118 int pause_count; |
| 117 | 119 |
| 118 // Whether this request is served over HTTP and the main page was served | 120 std::string frame_origin; |
| 119 // over HTTPS. | 121 |
| 120 bool mixed_content; | 122 std::string main_frame_origin; |
| 121 | 123 |
| 122 ResourceType::Type resource_type; | 124 ResourceType::Type resource_type; |
| 123 | 125 |
| 124 // Whether the content for this request should be filtered (on the renderer | 126 // Whether the content for this request should be filtered (on the renderer |
| 125 // side) to make it more secure: images are stamped, frame content is | 127 // side) to make it more secure: images are stamped, frame content is |
| 126 // replaced with an error message and all other resources are entirely | 128 // replaced with an error message and all other resources are entirely |
| 127 // filtered out. | 129 // filtered out. |
| 128 FilterPolicy::Type filter_policy; | 130 FilterPolicy::Type filter_policy; |
| 129 | 131 |
| 130 net::LoadState last_load_state; | 132 net::LoadState last_load_state; |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 364 FRIEND_TEST(ResourceDispatcherHostTest, | 366 FRIEND_TEST(ResourceDispatcherHostTest, |
| 365 IncrementOutstandingRequestsMemoryCost); | 367 IncrementOutstandingRequestsMemoryCost); |
| 366 FRIEND_TEST(ResourceDispatcherHostTest, | 368 FRIEND_TEST(ResourceDispatcherHostTest, |
| 367 CalculateApproximateMemoryCost); | 369 CalculateApproximateMemoryCost); |
| 368 | 370 |
| 369 class ShutdownTask; | 371 class ShutdownTask; |
| 370 | 372 |
| 371 friend class ShutdownTask; | 373 friend class ShutdownTask; |
| 372 | 374 |
| 373 struct BlockedRequest { | 375 struct BlockedRequest { |
| 374 BlockedRequest(URLRequest* url_request, bool mixed_content) | 376 BlockedRequest(URLRequest* url_request) |
| 375 : url_request(url_request), | 377 : url_request(url_request) { |
| 376 mixed_content(mixed_content) { | |
| 377 } | 378 } |
| 378 URLRequest* url_request; | 379 URLRequest* url_request; |
| 379 bool mixed_content; | |
| 380 }; | 380 }; |
| 381 | 381 |
| 382 // A shutdown helper that runs on the IO thread. | 382 // A shutdown helper that runs on the IO thread. |
| 383 void OnShutdown(); | 383 void OnShutdown(); |
| 384 | 384 |
| 385 // Returns true if the request is paused. | 385 // Returns true if the request is paused. |
| 386 bool PauseRequestIfNeeded(ExtraRequestInfo* info); | 386 bool PauseRequestIfNeeded(ExtraRequestInfo* info); |
| 387 | 387 |
| 388 // Resumes the given request by calling OnResponseStarted or OnReadCompleted. | 388 // Resumes the given request by calling OnResponseStarted or OnReadCompleted. |
| 389 void ResumeRequest(const GlobalRequestID& request_id); | 389 void ResumeRequest(const GlobalRequestID& request_id); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 404 | 404 |
| 405 // Cancels the given request if it still exists. We ignore cancels from the | 405 // Cancels the given request if it still exists. We ignore cancels from the |
| 406 // renderer in the event of a download. If |allow_delete| is true and no IO | 406 // renderer in the event of a download. If |allow_delete| is true and no IO |
| 407 // is pending, the request is removed and deleted. | 407 // is pending, the request is removed and deleted. |
| 408 void CancelRequest(int process_id, | 408 void CancelRequest(int process_id, |
| 409 int request_id, | 409 int request_id, |
| 410 bool from_renderer, | 410 bool from_renderer, |
| 411 bool allow_delete); | 411 bool allow_delete); |
| 412 | 412 |
| 413 // Helper function for regular and download requests. | 413 // Helper function for regular and download requests. |
| 414 void BeginRequestInternal(URLRequest* request, bool mixed_content); | 414 void BeginRequestInternal(URLRequest* request); |
| 415 | 415 |
| 416 // Updates the "cost" of outstanding requests for |process_id|. | 416 // Updates the "cost" of outstanding requests for |process_id|. |
| 417 // The "cost" approximates how many bytes are consumed by all the in-memory | 417 // The "cost" approximates how many bytes are consumed by all the in-memory |
| 418 // data structures supporting this request (URLRequest object, | 418 // data structures supporting this request (URLRequest object, |
| 419 // HttpNetworkTransaction, etc...). | 419 // HttpNetworkTransaction, etc...). |
| 420 // The value of |cost| is added to the running total, and the resulting | 420 // The value of |cost| is added to the running total, and the resulting |
| 421 // sum is returned. | 421 // sum is returned. |
| 422 int IncrementOutstandingRequestsMemoryCost(int cost, | 422 int IncrementOutstandingRequestsMemoryCost(int cost, |
| 423 int process_id); | 423 int process_id); |
| 424 | 424 |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 525 // individual requests is given by CalculateApproximateMemoryCost). | 525 // individual requests is given by CalculateApproximateMemoryCost). |
| 526 // The total number of outstanding requests is roughly: | 526 // The total number of outstanding requests is roughly: |
| 527 // (max_outstanding_requests_cost_per_process_ / | 527 // (max_outstanding_requests_cost_per_process_ / |
| 528 // kAvgBytesPerOutstandingRequest) | 528 // kAvgBytesPerOutstandingRequest) |
| 529 int max_outstanding_requests_cost_per_process_; | 529 int max_outstanding_requests_cost_per_process_; |
| 530 | 530 |
| 531 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcherHost); | 531 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcherHost); |
| 532 }; | 532 }; |
| 533 | 533 |
| 534 #endif // CHROME_BROWSER_RENDERER_HOST_RESOURCE_DISPATCHER_HOST_H_ | 534 #endif // CHROME_BROWSER_RENDERER_HOST_RESOURCE_DISPATCHER_HOST_H_ |
| OLD | NEW |