| 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 |
| 11 | 11 |
| 12 #ifndef CONTENT_BROWSER_LOADER_RESOURCE_DISPATCHER_HOST_IMPL_H_ | 12 #ifndef CONTENT_BROWSER_LOADER_RESOURCE_DISPATCHER_HOST_IMPL_H_ |
| 13 #define CONTENT_BROWSER_LOADER_RESOURCE_DISPATCHER_HOST_IMPL_H_ | 13 #define CONTENT_BROWSER_LOADER_RESOURCE_DISPATCHER_HOST_IMPL_H_ |
| 14 | 14 |
| 15 #include <map> | 15 #include <map> |
| 16 #include <set> | 16 #include <set> |
| 17 #include <string> | 17 #include <string> |
| 18 #include <vector> | 18 #include <vector> |
| 19 | 19 |
| 20 #include "base/basictypes.h" | 20 #include "base/basictypes.h" |
| 21 #include "base/gtest_prod_util.h" | 21 #include "base/gtest_prod_util.h" |
| 22 #include "base/memory/linked_ptr.h" | 22 #include "base/memory/linked_ptr.h" |
| 23 #include "base/memory/scoped_ptr.h" | 23 #include "base/memory/scoped_ptr.h" |
| 24 #include "base/observer_list.h" | 24 #include "base/observer_list.h" |
| 25 #include "base/time/time.h" | 25 #include "base/time/time.h" |
| 26 #include "base/timer/timer.h" | 26 #include "base/timer/timer.h" |
| 27 #include "content/browser/download/download_resource_handler.h" | 27 #include "content/browser/download/download_resource_handler.h" |
| 28 #include "content/browser/loader/async_revalidation_manager.h" |
| 28 #include "content/browser/loader/global_routing_id.h" | 29 #include "content/browser/loader/global_routing_id.h" |
| 29 #include "content/browser/loader/resource_loader.h" | 30 #include "content/browser/loader/resource_loader.h" |
| 30 #include "content/browser/loader/resource_loader_delegate.h" | 31 #include "content/browser/loader/resource_loader_delegate.h" |
| 31 #include "content/browser/loader/resource_scheduler.h" | 32 #include "content/browser/loader/resource_scheduler.h" |
| 32 #include "content/common/content_export.h" | 33 #include "content/common/content_export.h" |
| 33 #include "content/common/resource_request_body.h" | 34 #include "content/common/resource_request_body.h" |
| 34 #include "content/public/browser/child_process_data.h" | 35 #include "content/public/browser/child_process_data.h" |
| 35 #include "content/public/browser/download_item.h" | 36 #include "content/public/browser/download_item.h" |
| 36 #include "content/public/browser/download_url_parameters.h" | 37 #include "content/public/browser/download_url_parameters.h" |
| 37 #include "content/public/browser/global_request_id.h" | 38 #include "content/public/browser/global_request_id.h" |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 // elsewhere. | 270 // elsewhere. |
| 270 void FinishedWithResourcesForRequest(net::URLRequest* request); | 271 void FinishedWithResourcesForRequest(net::URLRequest* request); |
| 271 | 272 |
| 272 // PlzNavigate: Begins a request for NavigationURLLoader. |loader| is the | 273 // PlzNavigate: Begins a request for NavigationURLLoader. |loader| is the |
| 273 // loader to attach to the leaf resource handler. | 274 // loader to attach to the leaf resource handler. |
| 274 void BeginNavigationRequest(ResourceContext* resource_context, | 275 void BeginNavigationRequest(ResourceContext* resource_context, |
| 275 int frame_tree_node_id, | 276 int frame_tree_node_id, |
| 276 const NavigationRequestInfo& info, | 277 const NavigationRequestInfo& info, |
| 277 NavigationURLLoaderImplCore* loader); | 278 NavigationURLLoaderImplCore* loader); |
| 278 | 279 |
| 280 // Turns on stale-while-revalidate support, regardless of command-line flags |
| 281 // or experiment status. For unit tests only. |
| 282 void EnableStaleWhileRevalidateForTesting(); |
| 283 |
| 279 private: | 284 private: |
| 280 friend class ResourceDispatcherHostTest; | 285 friend class ResourceDispatcherHostTest; |
| 281 | 286 |
| 282 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest, | 287 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest, |
| 283 TestBlockedRequestsProcessDies); | 288 TestBlockedRequestsProcessDies); |
| 284 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest, | 289 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest, |
| 285 CalculateApproximateMemoryCost); | 290 CalculateApproximateMemoryCost); |
| 286 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest, | 291 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest, |
| 287 DetachableResourceTimesOut); | 292 DetachableResourceTimesOut); |
| 288 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest, | 293 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest, |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 578 base::TimeTicks last_user_gesture_time_; | 583 base::TimeTicks last_user_gesture_time_; |
| 579 | 584 |
| 580 // Used during IPC message dispatching so that the handlers can get a pointer | 585 // Used during IPC message dispatching so that the handlers can get a pointer |
| 581 // to the source of the message. | 586 // to the source of the message. |
| 582 ResourceMessageFilter* filter_; | 587 ResourceMessageFilter* filter_; |
| 583 | 588 |
| 584 ResourceDispatcherHostDelegate* delegate_; | 589 ResourceDispatcherHostDelegate* delegate_; |
| 585 | 590 |
| 586 bool allow_cross_origin_auth_prompt_; | 591 bool allow_cross_origin_auth_prompt_; |
| 587 | 592 |
| 593 // AsyncRevalidationManager is non-NULL if and only if |
| 594 // stale-while-revalidate is enabled. |
| 595 scoped_ptr<AsyncRevalidationManager> async_revalidation_manager_; |
| 596 |
| 588 // http://crbug.com/90971 - Assists in tracking down use-after-frees on | 597 // http://crbug.com/90971 - Assists in tracking down use-after-frees on |
| 589 // shutdown. | 598 // shutdown. |
| 590 std::set<const ResourceContext*> active_resource_contexts_; | 599 std::set<const ResourceContext*> active_resource_contexts_; |
| 591 | 600 |
| 592 typedef std::map<GlobalRequestID, | 601 typedef std::map<GlobalRequestID, |
| 593 base::ObserverList<ResourceMessageDelegate>*> DelegateMap; | 602 base::ObserverList<ResourceMessageDelegate>*> DelegateMap; |
| 594 DelegateMap delegate_map_; | 603 DelegateMap delegate_map_; |
| 595 | 604 |
| 596 scoped_ptr<ResourceScheduler> scheduler_; | 605 scoped_ptr<ResourceScheduler> scheduler_; |
| 597 | 606 |
| 598 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcherHostImpl); | 607 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcherHostImpl); |
| 599 }; | 608 }; |
| 600 | 609 |
| 601 } // namespace content | 610 } // namespace content |
| 602 | 611 |
| 603 #endif // CONTENT_BROWSER_LOADER_RESOURCE_DISPATCHER_HOST_IMPL_H_ | 612 #endif // CONTENT_BROWSER_LOADER_RESOURCE_DISPATCHER_HOST_IMPL_H_ |
| OLD | NEW |