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 12 matching lines...) Expand all Loading... |
23 #include "base/gtest_prod_util.h" | 23 #include "base/gtest_prod_util.h" |
24 #include "base/macros.h" | 24 #include "base/macros.h" |
25 #include "base/observer_list.h" | 25 #include "base/observer_list.h" |
26 #include "base/time/time.h" | 26 #include "base/time/time.h" |
27 #include "base/timer/timer.h" | 27 #include "base/timer/timer.h" |
28 #include "content/browser/download/download_resource_handler.h" | 28 #include "content/browser/download/download_resource_handler.h" |
29 #include "content/browser/download/save_types.h" | 29 #include "content/browser/download/save_types.h" |
30 #include "content/browser/loader/global_routing_id.h" | 30 #include "content/browser/loader/global_routing_id.h" |
31 #include "content/browser/loader/resource_loader.h" | 31 #include "content/browser/loader/resource_loader.h" |
32 #include "content/browser/loader/resource_loader_delegate.h" | 32 #include "content/browser/loader/resource_loader_delegate.h" |
| 33 #include "content/browser/loader/resource_request_info_impl.h" |
33 #include "content/browser/loader/resource_scheduler.h" | 34 #include "content/browser/loader/resource_scheduler.h" |
34 #include "content/common/content_export.h" | 35 #include "content/common/content_export.h" |
35 #include "content/common/resource_request_body.h" | 36 #include "content/common/resource_request_body.h" |
36 #include "content/public/browser/child_process_data.h" | 37 #include "content/public/browser/child_process_data.h" |
37 #include "content/public/browser/download_item.h" | 38 #include "content/public/browser/download_item.h" |
38 #include "content/public/browser/download_url_parameters.h" | 39 #include "content/public/browser/download_url_parameters.h" |
39 #include "content/public/browser/global_request_id.h" | 40 #include "content/public/browser/global_request_id.h" |
40 #include "content/public/browser/notification_types.h" | 41 #include "content/public/browser/notification_types.h" |
41 #include "content/public/browser/resource_dispatcher_host.h" | 42 #include "content/public/browser/resource_dispatcher_host.h" |
42 #include "content/public/browser/web_contents_observer.h" | 43 #include "content/public/browser/web_contents_observer.h" |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 struct OustandingRequestsStats { | 337 struct OustandingRequestsStats { |
337 int memory_cost; | 338 int memory_cost; |
338 int num_requests; | 339 int num_requests; |
339 }; | 340 }; |
340 | 341 |
341 friend class ShutdownTask; | 342 friend class ShutdownTask; |
342 friend class ResourceMessageDelegate; | 343 friend class ResourceMessageDelegate; |
343 | 344 |
344 // Information about status of a ResourceLoader. | 345 // Information about status of a ResourceLoader. |
345 struct LoadInfo { | 346 struct LoadInfo { |
| 347 LoadInfo(); |
| 348 ~LoadInfo(); |
| 349 LoadInfo(const LoadInfo& info); |
346 GURL url; | 350 GURL url; |
347 net::LoadStateWithParam load_state; | 351 net::LoadStateWithParam load_state; |
348 uint64_t upload_position; | 352 uint64_t upload_position; |
349 uint64_t upload_size; | 353 uint64_t upload_size; |
| 354 // Associates the load with a web contents. |
| 355 ResourceRequestInfo::WebContentsGetter web_contents_getter; |
350 }; | 356 }; |
351 | 357 |
352 // Map from ProcessID+RouteID pair to the "most interesting" LoadState. | 358 // Map from ProcessID+FrameRouteID pair to the "most interesting" LoadState. |
353 typedef std::map<GlobalRoutingID, LoadInfo> LoadInfoMap; | 359 typedef std::map<GlobalFrameRoutingId, LoadInfo> LoadInfoMap; |
354 | 360 |
355 // ResourceLoaderDelegate implementation: | 361 // ResourceLoaderDelegate implementation: |
356 ResourceDispatcherHostLoginDelegate* CreateLoginDelegate( | 362 ResourceDispatcherHostLoginDelegate* CreateLoginDelegate( |
357 ResourceLoader* loader, | 363 ResourceLoader* loader, |
358 net::AuthChallengeInfo* auth_info) override; | 364 net::AuthChallengeInfo* auth_info) override; |
359 bool HandleExternalProtocol(ResourceLoader* loader, const GURL& url) override; | 365 bool HandleExternalProtocol(ResourceLoader* loader, const GURL& url) override; |
360 void DidStartRequest(ResourceLoader* loader) override; | 366 void DidStartRequest(ResourceLoader* loader) override; |
361 void DidReceiveRedirect(ResourceLoader* loader, const GURL& new_url) override; | 367 void DidReceiveRedirect(ResourceLoader* loader, const GURL& new_url) override; |
362 void DidReceiveResponse(ResourceLoader* loader) override; | 368 void DidReceiveResponse(ResourceLoader* loader) override; |
363 void DidFinishLoading(ResourceLoader* loader) override; | 369 void DidFinishLoading(ResourceLoader* loader) override; |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
445 // For example, by this measure "tranferring data" is a more interesting state | 451 // For example, by this measure "tranferring data" is a more interesting state |
446 // than "resolving host" because when transferring data something is being | 452 // than "resolving host" because when transferring data something is being |
447 // done that corresponds to changes that the user might observe, whereas | 453 // done that corresponds to changes that the user might observe, whereas |
448 // waiting for a host name to resolve implies being stuck. | 454 // waiting for a host name to resolve implies being stuck. |
449 static bool LoadInfoIsMoreInteresting(const LoadInfo& a, const LoadInfo& b); | 455 static bool LoadInfoIsMoreInteresting(const LoadInfo& a, const LoadInfo& b); |
450 | 456 |
451 // Used to marshal calls to LoadStateChanged from the IO to UI threads. All | 457 // Used to marshal calls to LoadStateChanged from the IO to UI threads. All |
452 // are done as a single callback to avoid spamming the UI thread. | 458 // are done as a single callback to avoid spamming the UI thread. |
453 static void UpdateLoadInfoOnUIThread(std::unique_ptr<LoadInfoMap> info_map); | 459 static void UpdateLoadInfoOnUIThread(std::unique_ptr<LoadInfoMap> info_map); |
454 | 460 |
455 // Gets the most interesting LoadInfo for each GlobalRoutingID. | 461 // Gets the most interesting LoadInfo for each GlobalFrameRoutingID. |
456 std::unique_ptr<LoadInfoMap> GetLoadInfoForAllRoutes(); | 462 std::unique_ptr<LoadInfoMap> GetLoadInfoForAllRoutes(); |
457 | 463 |
458 // Checks all pending requests and updates the load info if necessary. | 464 // Checks all pending requests and updates the load info if necessary. |
459 void UpdateLoadInfo(); | 465 void UpdateLoadInfo(); |
460 | 466 |
461 // Resumes or cancels (if |cancel_requests| is true) any blocked requests. | 467 // Resumes or cancels (if |cancel_requests| is true) any blocked requests. |
462 void ProcessBlockedRequestsForRoute( | 468 void ProcessBlockedRequestsForRoute( |
463 const GlobalFrameRoutingId& global_routing_id, | 469 const GlobalFrameRoutingId& global_routing_id, |
464 bool cancel_requests); | 470 bool cancel_requests); |
465 | 471 |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
662 // Allows tests to use a mock CertStore. If set, the CertStore must | 668 // Allows tests to use a mock CertStore. If set, the CertStore must |
663 // outlive this ResourceDispatcherHostImpl. | 669 // outlive this ResourceDispatcherHostImpl. |
664 CertStore* cert_store_for_testing_; | 670 CertStore* cert_store_for_testing_; |
665 | 671 |
666 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcherHostImpl); | 672 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcherHostImpl); |
667 }; | 673 }; |
668 | 674 |
669 } // namespace content | 675 } // namespace content |
670 | 676 |
671 #endif // CONTENT_BROWSER_LOADER_RESOURCE_DISPATCHER_HOST_IMPL_H_ | 677 #endif // CONTENT_BROWSER_LOADER_RESOURCE_DISPATCHER_HOST_IMPL_H_ |
OLD | NEW |