Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(336)

Side by Side Diff: content/browser/loader/resource_dispatcher_host_impl.h

Issue 1970693002: Use mojo for Chrome Loading, Part 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 15 matching lines...) Expand all
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_scheduler.h" 33 #include "content/browser/loader/resource_scheduler.h"
34 #include "content/common/content_export.h" 34 #include "content/common/content_export.h"
35 #include "content/common/resource_request_body.h" 35 #include "content/common/resource_request_body.h"
36 #include "content/common/url_loader.mojom.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"
43 #include "content/public/common/resource_type.h" 44 #include "content/public/common/resource_type.h"
44 #include "ipc/ipc_message.h" 45 #include "ipc/ipc_message.h"
46 #include "mojo/public/cpp/system/data_pipe.h"
45 #include "net/base/request_priority.h" 47 #include "net/base/request_priority.h"
46 #include "net/cookies/canonical_cookie.h" 48 #include "net/cookies/canonical_cookie.h"
47 #include "net/url_request/url_request.h" 49 #include "net/url_request/url_request.h"
48 50
49 class ResourceHandler; 51 class ResourceHandler;
50 52
51 namespace base { 53 namespace base {
52 class FilePath; 54 class FilePath;
53 } 55 }
54 56
(...skipping 19 matching lines...) Expand all
74 class ResourceRequestInfoImpl; 76 class ResourceRequestInfoImpl;
75 class SaveFileManager; 77 class SaveFileManager;
76 class ServiceWorkerNavigationHandleCore; 78 class ServiceWorkerNavigationHandleCore;
77 class WebContentsImpl; 79 class WebContentsImpl;
78 struct CommonNavigationParams; 80 struct CommonNavigationParams;
79 struct DownloadSaveInfo; 81 struct DownloadSaveInfo;
80 struct NavigationRequestInfo; 82 struct NavigationRequestInfo;
81 struct Referrer; 83 struct Referrer;
82 struct ResourceRequest; 84 struct ResourceRequest;
83 85
86 namespace mojom {
87 class URLLoader;
88 } // namespace mojom
89
84 // This class is responsible for notifying the IO thread (specifically, the 90 // This class is responsible for notifying the IO thread (specifically, the
85 // ResourceDispatcherHostImpl) of frame events. It has an interace for callers 91 // ResourceDispatcherHostImpl) of frame events. It has an interace for callers
86 // to use and also sends notifications on WebContentsObserver events. All 92 // to use and also sends notifications on WebContentsObserver events. All
87 // methods (static or class) will be called from the UI thread and post to the 93 // methods (static or class) will be called from the UI thread and post to the
88 // IO thread. 94 // IO thread.
89 // TODO(csharrison): Add methods tracking visibility and audio changes, to 95 // TODO(csharrison): Add methods tracking visibility and audio changes, to
90 // propogate to the ResourceScheduler. 96 // propogate to the ResourceScheduler.
91 class LoaderIOThreadNotifier : public WebContentsObserver { 97 class LoaderIOThreadNotifier : public WebContentsObserver {
92 public: 98 public:
93 explicit LoaderIOThreadNotifier(WebContents* web_contents); 99 explicit LoaderIOThreadNotifier(WebContents* web_contents);
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 void BeginNavigationRequest( 317 void BeginNavigationRequest(
312 ResourceContext* resource_context, 318 ResourceContext* resource_context,
313 const NavigationRequestInfo& info, 319 const NavigationRequestInfo& info,
314 NavigationURLLoaderImplCore* loader, 320 NavigationURLLoaderImplCore* loader,
315 ServiceWorkerNavigationHandleCore* service_worker_handle_core); 321 ServiceWorkerNavigationHandleCore* service_worker_handle_core);
316 322
317 // Turns on stale-while-revalidate support, regardless of command-line flags 323 // Turns on stale-while-revalidate support, regardless of command-line flags
318 // or experiment status. For unit tests only. 324 // or experiment status. For unit tests only.
319 void EnableStaleWhileRevalidateForTesting(); 325 void EnableStaleWhileRevalidateForTesting();
320 326
327 // These functions are used when loading with mojo.
328 // Called when loading a request with mojo.
329 void OnRequestResourceWithMojo(int routing_id,
330 int request_id,
331 const ResourceRequest& request,
332 std::unique_ptr<mojom::URLLoader> url_loader,
333 mojom::URLLoaderClientPtr url_loader_client,
334 ResourceMessageFilter* filter);
335
321 private: 336 private:
322 friend class LoaderIOThreadNotifier; 337 friend class LoaderIOThreadNotifier;
323 friend class ResourceDispatcherHostTest; 338 friend class ResourceDispatcherHostTest;
339 class MojoHelper;
kinuko 2016/06/14 08:45:29 no longer needed
yhirano 2016/07/12 10:49:11 Done.
324 340
325 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest, 341 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest,
326 TestBlockedRequestsProcessDies); 342 TestBlockedRequestsProcessDies);
327 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest, 343 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest,
328 CalculateApproximateMemoryCost); 344 CalculateApproximateMemoryCost);
329 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest, 345 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest,
330 DetachableResourceTimesOut); 346 DetachableResourceTimesOut);
331 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest, 347 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest,
332 TestProcessCancelDetachableTimesOut); 348 TestProcessCancelDetachableTimesOut);
333 FRIEND_TEST_ALL_PREFIXES(SitePerProcessIgnoreCertErrorsBrowserTest, 349 FRIEND_TEST_ALL_PREFIXES(SitePerProcessIgnoreCertErrorsBrowserTest,
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 void UpdateLoadInfo(); 475 void UpdateLoadInfo();
460 476
461 // Resumes or cancels (if |cancel_requests| is true) any blocked requests. 477 // Resumes or cancels (if |cancel_requests| is true) any blocked requests.
462 void ProcessBlockedRequestsForRoute( 478 void ProcessBlockedRequestsForRoute(
463 const GlobalFrameRoutingId& global_routing_id, 479 const GlobalFrameRoutingId& global_routing_id,
464 bool cancel_requests); 480 bool cancel_requests);
465 481
466 void OnRequestResource(int routing_id, 482 void OnRequestResource(int routing_id,
467 int request_id, 483 int request_id,
468 const ResourceRequest& request_data); 484 const ResourceRequest& request_data);
485
486 void OnRequestResourceInternal(int routing_id,
487 int request_id,
488 const ResourceRequest& request_data,
489 std::unique_ptr<mojom::URLLoader> url_loader,
490 mojom::URLLoaderClientPtr url_loader_client);
491
469 void OnSyncLoad(int request_id, 492 void OnSyncLoad(int request_id,
470 const ResourceRequest& request_data, 493 const ResourceRequest& request_data,
471 IPC::Message* sync_result); 494 IPC::Message* sync_result);
472 495
473 bool IsRequestIDInUse(const GlobalRequestID& id) const; 496 bool IsRequestIDInUse(const GlobalRequestID& id) const;
474 497
475 // Update the ResourceRequestInfo and internal maps when a request is 498 // Update the ResourceRequestInfo and internal maps when a request is
476 // transferred from one process to another. 499 // transferred from one process to another.
477 void UpdateRequestForTransfer(int child_id, 500 void UpdateRequestForTransfer(int child_id,
478 int route_id, 501 int route_id,
479 int request_id, 502 int request_id,
480 const ResourceRequest& request_data, 503 const ResourceRequest& request_data,
481 LoaderMap::iterator iter); 504 LoaderMap::iterator iter);
482 505
483 void BeginRequest(int request_id, 506 void BeginRequest(int request_id,
484 const ResourceRequest& request_data, 507 const ResourceRequest& request_data,
485 IPC::Message* sync_result, // only valid for sync 508 IPC::Message* sync_result, // only valid for sync
486 int route_id); // only valid for async 509 int route_id, // only valid for async
510 std::unique_ptr<mojom::URLLoader> url_loader,
511 mojom::URLLoaderClientPtr url_loader_client);
487 512
488 // Creates a ResourceHandler to be used by BeginRequest() for normal resource 513 // Creates a ResourceHandler to be used by BeginRequest() for normal resource
489 // loading. 514 // loading.
490 std::unique_ptr<ResourceHandler> CreateResourceHandler( 515 std::unique_ptr<ResourceHandler> CreateResourceHandler(
491 net::URLRequest* request, 516 net::URLRequest* request,
492 const ResourceRequest& request_data, 517 const ResourceRequest& request_data,
493 IPC::Message* sync_result, 518 IPC::Message* sync_result,
494 int route_id, 519 int route_id,
495 int process_type, 520 int process_type,
496 int child_id, 521 int child_id,
497 ResourceContext* resource_context); 522 ResourceContext* resource_context,
523 std::unique_ptr<mojom::URLLoader> url_loader,
524 mojom::URLLoaderClientPtr url_loader_client);
498 525
499 // Wraps |handler| in the standard resource handlers for normal resource 526 // Wraps |handler| in the standard resource handlers for normal resource
500 // loading and navigation requests. This adds MimeTypeResourceHandler and 527 // loading and navigation requests. This adds MimeTypeResourceHandler and
501 // ResourceThrottles. 528 // ResourceThrottles.
502 std::unique_ptr<ResourceHandler> AddStandardHandlers( 529 std::unique_ptr<ResourceHandler> AddStandardHandlers(
503 net::URLRequest* request, 530 net::URLRequest* request,
504 ResourceType resource_type, 531 ResourceType resource_type,
505 ResourceContext* resource_context, 532 ResourceContext* resource_context,
506 AppCacheService* appcache_service, 533 AppCacheService* appcache_service,
507 int child_id, 534 int child_id,
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
662 // Allows tests to use a mock CertStore. If set, the CertStore must 689 // Allows tests to use a mock CertStore. If set, the CertStore must
663 // outlive this ResourceDispatcherHostImpl. 690 // outlive this ResourceDispatcherHostImpl.
664 CertStore* cert_store_for_testing_; 691 CertStore* cert_store_for_testing_;
665 692
666 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcherHostImpl); 693 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcherHostImpl);
667 }; 694 };
668 695
669 } // namespace content 696 } // namespace content
670 697
671 #endif // CONTENT_BROWSER_LOADER_RESOURCE_DISPATCHER_HOST_IMPL_H_ 698 #endif // CONTENT_BROWSER_LOADER_RESOURCE_DISPATCHER_HOST_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698