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 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
335 | 336 |
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 CONTENT_EXPORT LoadInfo { |
347 LoadInfo(); | |
348 LoadInfo(const LoadInfo& info); | |
349 ~LoadInfo(); | |
350 | |
346 GURL url; | 351 GURL url; |
347 net::LoadStateWithParam load_state; | 352 net::LoadStateWithParam load_state; |
348 uint64_t upload_position; | 353 uint64_t upload_position; |
349 uint64_t upload_size; | 354 uint64_t upload_size; |
355 | |
356 // Associates the load with a web contents. | |
357 ResourceRequestInfo::WebContentsGetter web_contents_getter; | |
350 }; | 358 }; |
351 | 359 |
352 // Map from ProcessID+RouteID pair to the "most interesting" LoadState. | 360 // Map from ProcessID+FrameRouteID pair to the "most interesting" LoadState. |
353 typedef std::map<GlobalRoutingID, LoadInfo> LoadInfoMap; | 361 typedef std::map<GlobalFrameRoutingId, LoadInfo> LoadInfoMap; |
354 | 362 |
355 // ResourceLoaderDelegate implementation: | 363 // ResourceLoaderDelegate implementation: |
356 ResourceDispatcherHostLoginDelegate* CreateLoginDelegate( | 364 ResourceDispatcherHostLoginDelegate* CreateLoginDelegate( |
357 ResourceLoader* loader, | 365 ResourceLoader* loader, |
358 net::AuthChallengeInfo* auth_info) override; | 366 net::AuthChallengeInfo* auth_info) override; |
359 bool HandleExternalProtocol(ResourceLoader* loader, const GURL& url) override; | 367 bool HandleExternalProtocol(ResourceLoader* loader, const GURL& url) override; |
360 void DidStartRequest(ResourceLoader* loader) override; | 368 void DidStartRequest(ResourceLoader* loader) override; |
361 void DidReceiveRedirect(ResourceLoader* loader, const GURL& new_url) override; | 369 void DidReceiveRedirect(ResourceLoader* loader, const GURL& new_url) override; |
362 void DidReceiveResponse(ResourceLoader* loader) override; | 370 void DidReceiveResponse(ResourceLoader* loader) override; |
363 void DidFinishLoading(ResourceLoader* loader) override; | 371 void DidFinishLoading(ResourceLoader* loader) override; |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
442 // request, so states with larger numeric values are generally further along | 450 // request, so states with larger numeric values are generally further along |
443 // toward completion. | 451 // toward completion. |
444 // | 452 // |
445 // For example, by this measure "tranferring data" is a more interesting state | 453 // For example, by this measure "tranferring data" is a more interesting state |
446 // than "resolving host" because when transferring data something is being | 454 // than "resolving host" because when transferring data something is being |
447 // done that corresponds to changes that the user might observe, whereas | 455 // done that corresponds to changes that the user might observe, whereas |
448 // waiting for a host name to resolve implies being stuck. | 456 // waiting for a host name to resolve implies being stuck. |
449 static bool LoadInfoIsMoreInteresting(const LoadInfo& a, const LoadInfo& b); | 457 static bool LoadInfoIsMoreInteresting(const LoadInfo& a, const LoadInfo& b); |
450 | 458 |
451 // Used to marshal calls to LoadStateChanged from the IO to UI threads. All | 459 // 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. | 460 // are done as a single callback to avoid spamming the UI thread. Note that |
461 // GetLoadInfoForAllRoutes de-dupes based on frame, but not based on tab. | |
462 // Thus, logic here also constructs a map and finds the most interesting load | |
463 // state per WebContents. | |
464 // static | |
nasko
2016/06/02 22:04:21
No need for "// static" line here.
Charlie Harrison
2016/06/06 15:39:53
Done.
| |
453 static void UpdateLoadInfoOnUIThread(std::unique_ptr<LoadInfoMap> info_map); | 465 static void UpdateLoadInfoOnUIThread(std::unique_ptr<LoadInfoMap> info_map); |
454 | 466 |
455 // Gets the most interesting LoadInfo for each GlobalRoutingID. | 467 // Gets the most interesting LoadInfo for each GlobalFrameRoutingID. |
456 std::unique_ptr<LoadInfoMap> GetLoadInfoForAllRoutes(); | 468 std::unique_ptr<LoadInfoMap> GetLoadInfoForAllRoutes(); |
457 | 469 |
458 // Checks all pending requests and updates the load info if necessary. | 470 // Checks all pending requests and updates the load info if necessary. |
459 void UpdateLoadInfo(); | 471 void UpdateLoadInfo(); |
460 | 472 |
461 // Resumes or cancels (if |cancel_requests| is true) any blocked requests. | 473 // Resumes or cancels (if |cancel_requests| is true) any blocked requests. |
462 void ProcessBlockedRequestsForRoute( | 474 void ProcessBlockedRequestsForRoute( |
463 const GlobalFrameRoutingId& global_routing_id, | 475 const GlobalFrameRoutingId& global_routing_id, |
464 bool cancel_requests); | 476 bool cancel_requests); |
465 | 477 |
(...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 | 674 // Allows tests to use a mock CertStore. If set, the CertStore must |
663 // outlive this ResourceDispatcherHostImpl. | 675 // outlive this ResourceDispatcherHostImpl. |
664 CertStore* cert_store_for_testing_; | 676 CertStore* cert_store_for_testing_; |
665 | 677 |
666 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcherHostImpl); | 678 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcherHostImpl); |
667 }; | 679 }; |
668 | 680 |
669 } // namespace content | 681 } // namespace content |
670 | 682 |
671 #endif // CONTENT_BROWSER_LOADER_RESOURCE_DISPATCHER_HOST_IMPL_H_ | 683 #endif // CONTENT_BROWSER_LOADER_RESOURCE_DISPATCHER_HOST_IMPL_H_ |
OLD | NEW |