| 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 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 364 FRIEND_TEST(ResourceDispatcherHostTest, TestBlockedRequestsProcessDies); | 364 FRIEND_TEST(ResourceDispatcherHostTest, TestBlockedRequestsProcessDies); |
| 365 FRIEND_TEST(ResourceDispatcherHostTest, | 365 FRIEND_TEST(ResourceDispatcherHostTest, |
| 366 IncrementOutstandingRequestsMemoryCost); | 366 IncrementOutstandingRequestsMemoryCost); |
| 367 FRIEND_TEST(ResourceDispatcherHostTest, | 367 FRIEND_TEST(ResourceDispatcherHostTest, |
| 368 CalculateApproximateMemoryCost); | 368 CalculateApproximateMemoryCost); |
| 369 | 369 |
| 370 class ShutdownTask; | 370 class ShutdownTask; |
| 371 | 371 |
| 372 friend class ShutdownTask; | 372 friend class ShutdownTask; |
| 373 | 373 |
| 374 // TODO(abarth): We don't need this struct any more. Let's get rid of it. | |
| 375 struct BlockedRequest { | |
| 376 explicit BlockedRequest(URLRequest* url_request) | |
| 377 : url_request(url_request) { | |
| 378 } | |
| 379 URLRequest* url_request; | |
| 380 }; | |
| 381 | |
| 382 // A shutdown helper that runs on the IO thread. | 374 // A shutdown helper that runs on the IO thread. |
| 383 void OnShutdown(); | 375 void OnShutdown(); |
| 384 | 376 |
| 385 // Returns true if the request is paused. | 377 // Returns true if the request is paused. |
| 386 bool PauseRequestIfNeeded(ExtraRequestInfo* info); | 378 bool PauseRequestIfNeeded(ExtraRequestInfo* info); |
| 387 | 379 |
| 388 // Resumes the given request by calling OnResponseStarted or OnReadCompleted. | 380 // Resumes the given request by calling OnResponseStarted or OnReadCompleted. |
| 389 void ResumeRequest(const GlobalRequestID& request_id); | 381 void ResumeRequest(const GlobalRequestID& request_id); |
| 390 | 382 |
| 391 // Reads data from the response using our internal buffer as async IO. | 383 // Reads data from the response using our internal buffer as async IO. |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 520 ObserverList<Observer> observer_list_; | 512 ObserverList<Observer> observer_list_; |
| 521 | 513 |
| 522 PluginService* plugin_service_; | 514 PluginService* plugin_service_; |
| 523 | 515 |
| 524 // For running tasks. | 516 // For running tasks. |
| 525 ScopedRunnableMethodFactory<ResourceDispatcherHost> method_runner_; | 517 ScopedRunnableMethodFactory<ResourceDispatcherHost> method_runner_; |
| 526 | 518 |
| 527 // True if the resource dispatcher host has been shut down. | 519 // True if the resource dispatcher host has been shut down. |
| 528 bool is_shutdown_; | 520 bool is_shutdown_; |
| 529 | 521 |
| 530 typedef std::vector<BlockedRequest> BlockedRequestsList; | 522 typedef std::vector<URLRequest*> BlockedRequestsList; |
| 531 typedef std::pair<int, int> ProcessRouteIDs; | 523 typedef std::pair<int, int> ProcessRouteIDs; |
| 532 typedef std::map<ProcessRouteIDs, BlockedRequestsList*> BlockedRequestMap; | 524 typedef std::map<ProcessRouteIDs, BlockedRequestsList*> BlockedRequestMap; |
| 533 BlockedRequestMap blocked_requests_map_; | 525 BlockedRequestMap blocked_requests_map_; |
| 534 | 526 |
| 535 // Maps the process_ids to the approximate number of bytes | 527 // Maps the process_ids to the approximate number of bytes |
| 536 // being used to service its resource requests. No entry implies 0 cost. | 528 // being used to service its resource requests. No entry implies 0 cost. |
| 537 typedef std::map<int, int> OutstandingRequestsMemoryCostMap; | 529 typedef std::map<int, int> OutstandingRequestsMemoryCostMap; |
| 538 OutstandingRequestsMemoryCostMap outstanding_requests_memory_cost_map_; | 530 OutstandingRequestsMemoryCostMap outstanding_requests_memory_cost_map_; |
| 539 | 531 |
| 540 // |max_outstanding_requests_cost_per_process_| is the upper bound on how | 532 // |max_outstanding_requests_cost_per_process_| is the upper bound on how |
| 541 // many outstanding requests can be issued per child process host. | 533 // many outstanding requests can be issued per child process host. |
| 542 // The constraint is expressed in terms of bytes (where the cost of | 534 // The constraint is expressed in terms of bytes (where the cost of |
| 543 // individual requests is given by CalculateApproximateMemoryCost). | 535 // individual requests is given by CalculateApproximateMemoryCost). |
| 544 // The total number of outstanding requests is roughly: | 536 // The total number of outstanding requests is roughly: |
| 545 // (max_outstanding_requests_cost_per_process_ / | 537 // (max_outstanding_requests_cost_per_process_ / |
| 546 // kAvgBytesPerOutstandingRequest) | 538 // kAvgBytesPerOutstandingRequest) |
| 547 int max_outstanding_requests_cost_per_process_; | 539 int max_outstanding_requests_cost_per_process_; |
| 548 | 540 |
| 549 // Used during IPC message dispatching so that the handlers can get a pointer | 541 // Used during IPC message dispatching so that the handlers can get a pointer |
| 550 // to the source of the message. | 542 // to the source of the message. |
| 551 Receiver* receiver_; | 543 Receiver* receiver_; |
| 552 | 544 |
| 553 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcherHost); | 545 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcherHost); |
| 554 }; | 546 }; |
| 555 | 547 |
| 556 #endif // CHROME_BROWSER_RENDERER_HOST_RESOURCE_DISPATCHER_HOST_H_ | 548 #endif // CHROME_BROWSER_RENDERER_HOST_RESOURCE_DISPATCHER_HOST_H_ |
| OLD | NEW |