| 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 // The security origin of the frame making this request. |
| 119 // over HTTPS. | 121 std::string frame_origin; |
| 120 bool mixed_content; | 122 |
| 123 // The security origin of the main frame that contains the frame making |
| 124 // this request. |
| 125 std::string main_frame_origin; |
| 121 | 126 |
| 122 ResourceType::Type resource_type; | 127 ResourceType::Type resource_type; |
| 123 | 128 |
| 124 // Whether the content for this request should be filtered (on the renderer | 129 // 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 | 130 // side) to make it more secure: images are stamped, frame content is |
| 126 // replaced with an error message and all other resources are entirely | 131 // replaced with an error message and all other resources are entirely |
| 127 // filtered out. | 132 // filtered out. |
| 128 FilterPolicy::Type filter_policy; | 133 FilterPolicy::Type filter_policy; |
| 129 | 134 |
| 130 net::LoadState last_load_state; | 135 net::LoadState last_load_state; |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 363 FRIEND_TEST(ResourceDispatcherHostTest, TestBlockedRequestsProcessDies); | 368 FRIEND_TEST(ResourceDispatcherHostTest, TestBlockedRequestsProcessDies); |
| 364 FRIEND_TEST(ResourceDispatcherHostTest, | 369 FRIEND_TEST(ResourceDispatcherHostTest, |
| 365 IncrementOutstandingRequestsMemoryCost); | 370 IncrementOutstandingRequestsMemoryCost); |
| 366 FRIEND_TEST(ResourceDispatcherHostTest, | 371 FRIEND_TEST(ResourceDispatcherHostTest, |
| 367 CalculateApproximateMemoryCost); | 372 CalculateApproximateMemoryCost); |
| 368 | 373 |
| 369 class ShutdownTask; | 374 class ShutdownTask; |
| 370 | 375 |
| 371 friend class ShutdownTask; | 376 friend class ShutdownTask; |
| 372 | 377 |
| 378 // TODO(abarth): We don't need this struct any more. Let's get rid of it. |
| 373 struct BlockedRequest { | 379 struct BlockedRequest { |
| 374 BlockedRequest(URLRequest* url_request, bool mixed_content) | 380 explicit BlockedRequest(URLRequest* url_request) |
| 375 : url_request(url_request), | 381 : url_request(url_request) { |
| 376 mixed_content(mixed_content) { | |
| 377 } | 382 } |
| 378 URLRequest* url_request; | 383 URLRequest* url_request; |
| 379 bool mixed_content; | |
| 380 }; | 384 }; |
| 381 | 385 |
| 382 // A shutdown helper that runs on the IO thread. | 386 // A shutdown helper that runs on the IO thread. |
| 383 void OnShutdown(); | 387 void OnShutdown(); |
| 384 | 388 |
| 385 // Returns true if the request is paused. | 389 // Returns true if the request is paused. |
| 386 bool PauseRequestIfNeeded(ExtraRequestInfo* info); | 390 bool PauseRequestIfNeeded(ExtraRequestInfo* info); |
| 387 | 391 |
| 388 // Resumes the given request by calling OnResponseStarted or OnReadCompleted. | 392 // Resumes the given request by calling OnResponseStarted or OnReadCompleted. |
| 389 void ResumeRequest(const GlobalRequestID& request_id); | 393 void ResumeRequest(const GlobalRequestID& request_id); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 404 | 408 |
| 405 // Cancels the given request if it still exists. We ignore cancels from the | 409 // 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 | 410 // renderer in the event of a download. If |allow_delete| is true and no IO |
| 407 // is pending, the request is removed and deleted. | 411 // is pending, the request is removed and deleted. |
| 408 void CancelRequest(int process_id, | 412 void CancelRequest(int process_id, |
| 409 int request_id, | 413 int request_id, |
| 410 bool from_renderer, | 414 bool from_renderer, |
| 411 bool allow_delete); | 415 bool allow_delete); |
| 412 | 416 |
| 413 // Helper function for regular and download requests. | 417 // Helper function for regular and download requests. |
| 414 void BeginRequestInternal(URLRequest* request, bool mixed_content); | 418 void BeginRequestInternal(URLRequest* request); |
| 415 | 419 |
| 416 // Updates the "cost" of outstanding requests for |process_id|. | 420 // Updates the "cost" of outstanding requests for |process_id|. |
| 417 // The "cost" approximates how many bytes are consumed by all the in-memory | 421 // The "cost" approximates how many bytes are consumed by all the in-memory |
| 418 // data structures supporting this request (URLRequest object, | 422 // data structures supporting this request (URLRequest object, |
| 419 // HttpNetworkTransaction, etc...). | 423 // HttpNetworkTransaction, etc...). |
| 420 // The value of |cost| is added to the running total, and the resulting | 424 // The value of |cost| is added to the running total, and the resulting |
| 421 // sum is returned. | 425 // sum is returned. |
| 422 int IncrementOutstandingRequestsMemoryCost(int cost, | 426 int IncrementOutstandingRequestsMemoryCost(int cost, |
| 423 int process_id); | 427 int process_id); |
| 424 | 428 |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 525 // individual requests is given by CalculateApproximateMemoryCost). | 529 // individual requests is given by CalculateApproximateMemoryCost). |
| 526 // The total number of outstanding requests is roughly: | 530 // The total number of outstanding requests is roughly: |
| 527 // (max_outstanding_requests_cost_per_process_ / | 531 // (max_outstanding_requests_cost_per_process_ / |
| 528 // kAvgBytesPerOutstandingRequest) | 532 // kAvgBytesPerOutstandingRequest) |
| 529 int max_outstanding_requests_cost_per_process_; | 533 int max_outstanding_requests_cost_per_process_; |
| 530 | 534 |
| 531 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcherHost); | 535 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcherHost); |
| 532 }; | 536 }; |
| 533 | 537 |
| 534 #endif // CHROME_BROWSER_RENDERER_HOST_RESOURCE_DISPATCHER_HOST_H_ | 538 #endif // CHROME_BROWSER_RENDERER_HOST_RESOURCE_DISPATCHER_HOST_H_ |
| OLD | NEW |