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

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: fix Created 4 years, 4 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 13 matching lines...) Expand all
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/download/save_types.h" 28 #include "content/browser/download/save_types.h"
29 #include "content/browser/loader/global_routing_id.h" 29 #include "content/browser/loader/global_routing_id.h"
30 #include "content/browser/loader/resource_loader.h" 30 #include "content/browser/loader/resource_loader.h"
31 #include "content/browser/loader/resource_loader_delegate.h" 31 #include "content/browser/loader/resource_loader_delegate.h"
32 #include "content/browser/loader/resource_scheduler.h" 32 #include "content/browser/loader/resource_scheduler.h"
33 #include "content/common/content_export.h" 33 #include "content/common/content_export.h"
34 #include "content/common/url_loader.mojom.h"
34 #include "content/public/browser/global_request_id.h" 35 #include "content/public/browser/global_request_id.h"
35 #include "content/public/browser/resource_dispatcher_host.h" 36 #include "content/public/browser/resource_dispatcher_host.h"
36 #include "content/public/common/request_context_type.h" 37 #include "content/public/common/request_context_type.h"
37 #include "content/public/common/resource_type.h" 38 #include "content/public/common/resource_type.h"
38 #include "ipc/ipc_message.h" 39 #include "ipc/ipc_message.h"
40 #include "mojo/public/cpp/system/data_pipe.h"
39 #include "net/base/request_priority.h" 41 #include "net/base/request_priority.h"
40 #include "net/cookies/canonical_cookie.h" 42 #include "net/cookies/canonical_cookie.h"
41 #include "net/url_request/url_request.h" 43 #include "net/url_request/url_request.h"
42 44
43 class ResourceHandler; 45 class ResourceHandler;
44 46
45 namespace base { 47 namespace base {
46 class FilePath; 48 class FilePath;
47 } 49 }
48 50
(...skipping 18 matching lines...) Expand all
67 class ResourceMessageFilter; 69 class ResourceMessageFilter;
68 class ResourceRequestInfoImpl; 70 class ResourceRequestInfoImpl;
69 class SaveFileManager; 71 class SaveFileManager;
70 class ServiceWorkerNavigationHandleCore; 72 class ServiceWorkerNavigationHandleCore;
71 struct CommonNavigationParams; 73 struct CommonNavigationParams;
72 struct DownloadSaveInfo; 74 struct DownloadSaveInfo;
73 struct NavigationRequestInfo; 75 struct NavigationRequestInfo;
74 struct Referrer; 76 struct Referrer;
75 struct ResourceRequest; 77 struct ResourceRequest;
76 78
79 namespace mojom {
80 class URLLoader;
81 } // namespace mojom
82
77 class CONTENT_EXPORT ResourceDispatcherHostImpl 83 class CONTENT_EXPORT ResourceDispatcherHostImpl
78 : public ResourceDispatcherHost, 84 : public ResourceDispatcherHost,
79 public ResourceLoaderDelegate { 85 public ResourceLoaderDelegate {
80 public: 86 public:
81 ResourceDispatcherHostImpl(); 87 ResourceDispatcherHostImpl();
82 ~ResourceDispatcherHostImpl() override; 88 ~ResourceDispatcherHostImpl() override;
83 89
84 // Returns the current ResourceDispatcherHostImpl. May return NULL if it 90 // Returns the current ResourceDispatcherHostImpl. May return NULL if it
85 // hasn't been created yet. 91 // hasn't been created yet.
86 static ResourceDispatcherHostImpl* Get(); 92 static ResourceDispatcherHostImpl* Get();
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 // using its shared memory buffer. Frees up that file descriptor to be used 281 // using its shared memory buffer. Frees up that file descriptor to be used
276 // elsewhere. 282 // elsewhere.
277 void FinishedWithResourcesForRequest(net::URLRequest* request); 283 void FinishedWithResourcesForRequest(net::URLRequest* request);
278 284
279 // PlzNavigate: Begins a request for NavigationURLLoader. |loader| is the 285 // PlzNavigate: Begins a request for NavigationURLLoader. |loader| is the
280 // loader to attach to the leaf resource handler. 286 // loader to attach to the leaf resource handler.
281 void BeginNavigationRequest(ResourceContext* resource_context, 287 void BeginNavigationRequest(ResourceContext* resource_context,
282 const NavigationRequestInfo& info, 288 const NavigationRequestInfo& info,
283 NavigationURLLoaderImplCore* loader); 289 NavigationURLLoaderImplCore* loader);
284 290
291 int num_in_flight_requests_for_testing() const {
292 return num_in_flight_requests_;
293 }
294
285 // Turns on stale-while-revalidate support, regardless of command-line flags 295 // Turns on stale-while-revalidate support, regardless of command-line flags
286 // or experiment status. For unit tests only. 296 // or experiment status. For unit tests only.
287 void EnableStaleWhileRevalidateForTesting(); 297 void EnableStaleWhileRevalidateForTesting();
288 298
289 // Sets the LoaderDelegate, which must outlive this object. Ownership is not 299 // Sets the LoaderDelegate, which must outlive this object. Ownership is not
290 // transferred. The LoaderDelegate should be interacted with on the IO thread. 300 // transferred. The LoaderDelegate should be interacted with on the IO thread.
291 void SetLoaderDelegate(LoaderDelegate* loader_delegate); 301 void SetLoaderDelegate(LoaderDelegate* loader_delegate);
292 302
293 void OnRenderFrameDeleted(const GlobalFrameRoutingId& global_routing_id); 303 void OnRenderFrameDeleted(const GlobalFrameRoutingId& global_routing_id);
294 304
305 // Called when loading a request with mojo.
306 void OnRequestResourceWithMojo(
307 int routing_id,
308 int request_id,
309 const ResourceRequest& request,
310 mojo::InterfaceRequest<mojom::URLLoader> mojo_request,
311 mojom::URLLoaderClientPtr url_loader_client,
312 ResourceMessageFilter* filter);
313
295 private: 314 private:
296 friend class ResourceDispatcherHostTest; 315 friend class ResourceDispatcherHostTest;
297 316
298 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest, 317 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest,
299 TestBlockedRequestsProcessDies); 318 TestBlockedRequestsProcessDies);
300 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest, 319 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest,
301 CalculateApproximateMemoryCost); 320 CalculateApproximateMemoryCost);
302 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest, 321 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest,
303 DetachableResourceTimesOut); 322 DetachableResourceTimesOut);
304 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest, 323 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest,
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 void UpdateLoadInfo(); 447 void UpdateLoadInfo();
429 448
430 // Resumes or cancels (if |cancel_requests| is true) any blocked requests. 449 // Resumes or cancels (if |cancel_requests| is true) any blocked requests.
431 void ProcessBlockedRequestsForRoute( 450 void ProcessBlockedRequestsForRoute(
432 const GlobalFrameRoutingId& global_routing_id, 451 const GlobalFrameRoutingId& global_routing_id,
433 bool cancel_requests); 452 bool cancel_requests);
434 453
435 void OnRequestResource(int routing_id, 454 void OnRequestResource(int routing_id,
436 int request_id, 455 int request_id,
437 const ResourceRequest& request_data); 456 const ResourceRequest& request_data);
457
458 void OnRequestResourceInternal(
459 int routing_id,
460 int request_id,
461 const ResourceRequest& request_data,
462 mojo::InterfaceRequest<mojom::URLLoader> mojo_request,
463 mojom::URLLoaderClientPtr url_loader_client);
464
438 void OnSyncLoad(int request_id, 465 void OnSyncLoad(int request_id,
439 const ResourceRequest& request_data, 466 const ResourceRequest& request_data,
440 IPC::Message* sync_result); 467 IPC::Message* sync_result);
441 468
442 bool IsRequestIDInUse(const GlobalRequestID& id) const; 469 bool IsRequestIDInUse(const GlobalRequestID& id) const;
443 470
444 // Update the ResourceRequestInfo and internal maps when a request is 471 // Update the ResourceRequestInfo and internal maps when a request is
445 // transferred from one process to another. 472 // transferred from one process to another.
446 void UpdateRequestForTransfer(int child_id, 473 void UpdateRequestForTransfer(int child_id,
447 int route_id, 474 int route_id,
448 int request_id, 475 int request_id,
449 const ResourceRequest& request_data, 476 const ResourceRequest& request_data,
450 LoaderMap::iterator iter); 477 LoaderMap::iterator iter);
451 478
452 void BeginRequest(int request_id, 479 void BeginRequest(int request_id,
453 const ResourceRequest& request_data, 480 const ResourceRequest& request_data,
454 IPC::Message* sync_result, // only valid for sync 481 IPC::Message* sync_result, // only valid for sync
455 int route_id); // only valid for async 482 int route_id, // only valid for async
483 mojo::InterfaceRequest<mojom::URLLoader> mojo_request,
484 mojom::URLLoaderClientPtr url_loader_client);
456 485
457 // Creates a ResourceHandler to be used by BeginRequest() for normal resource 486 // Creates a ResourceHandler to be used by BeginRequest() for normal resource
458 // loading. 487 // loading.
459 std::unique_ptr<ResourceHandler> CreateResourceHandler( 488 std::unique_ptr<ResourceHandler> CreateResourceHandler(
460 net::URLRequest* request, 489 net::URLRequest* request,
461 const ResourceRequest& request_data, 490 const ResourceRequest& request_data,
462 IPC::Message* sync_result, 491 IPC::Message* sync_result,
463 int route_id, 492 int route_id,
464 int process_type, 493 int process_type,
465 int child_id, 494 int child_id,
466 ResourceContext* resource_context); 495 ResourceContext* resource_context,
496 mojo::InterfaceRequest<mojom::URLLoader> mojo_request,
497 mojom::URLLoaderClientPtr url_loader_client);
467 498
468 // Wraps |handler| in the standard resource handlers for normal resource 499 // Wraps |handler| in the standard resource handlers for normal resource
469 // loading and navigation requests. This adds MimeTypeResourceHandler and 500 // loading and navigation requests. This adds MimeTypeResourceHandler and
470 // ResourceThrottles. 501 // ResourceThrottles.
471 std::unique_ptr<ResourceHandler> AddStandardHandlers( 502 std::unique_ptr<ResourceHandler> AddStandardHandlers(
472 net::URLRequest* request, 503 net::URLRequest* request,
473 ResourceType resource_type, 504 ResourceType resource_type,
474 ResourceContext* resource_context, 505 ResourceContext* resource_context,
475 RequestContextType fetch_request_context_type, 506 RequestContextType fetch_request_context_type,
476 AppCacheService* appcache_service, 507 AppCacheService* appcache_service,
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
630 // Allows tests to use a mock CertStore. If set, the CertStore must 661 // Allows tests to use a mock CertStore. If set, the CertStore must
631 // outlive this ResourceDispatcherHostImpl. 662 // outlive this ResourceDispatcherHostImpl.
632 CertStore* cert_store_for_testing_; 663 CertStore* cert_store_for_testing_;
633 664
634 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcherHostImpl); 665 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcherHostImpl);
635 }; 666 };
636 667
637 } // namespace content 668 } // namespace content
638 669
639 #endif // CONTENT_BROWSER_LOADER_RESOURCE_DISPATCHER_HOST_IMPL_H_ 670 #endif // CONTENT_BROWSER_LOADER_RESOURCE_DISPATCHER_HOST_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698