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

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, 7 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"
45 #include "net/base/request_priority.h" 46 #include "net/base/request_priority.h"
(...skipping 27 matching lines...) Expand all
73 class ResourceMessageFilter; 74 class ResourceMessageFilter;
74 class ResourceRequestInfoImpl; 75 class ResourceRequestInfoImpl;
75 class SaveFileManager; 76 class SaveFileManager;
76 class ServiceWorkerNavigationHandleCore; 77 class ServiceWorkerNavigationHandleCore;
77 class WebContentsImpl; 78 class WebContentsImpl;
78 struct CommonNavigationParams; 79 struct CommonNavigationParams;
79 struct DownloadSaveInfo; 80 struct DownloadSaveInfo;
80 struct NavigationRequestInfo; 81 struct NavigationRequestInfo;
81 struct Referrer; 82 struct Referrer;
82 struct ResourceRequest; 83 struct ResourceRequest;
84 struct ResourceRequestCompletionStatus;
85 struct ResourceResponseHead;
83 86
84 // This class is responsible for notifying the IO thread (specifically, the 87 // This class is responsible for notifying the IO thread (specifically, the
85 // ResourceDispatcherHostImpl) of frame events. It has an interace for callers 88 // ResourceDispatcherHostImpl) of frame events. It has an interace for callers
86 // to use and also sends notifications on WebContentsObserver events. All 89 // 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 90 // methods (static or class) will be called from the UI thread and post to the
88 // IO thread. 91 // IO thread.
89 // TODO(csharrison): Add methods tracking visibility and audio changes, to 92 // TODO(csharrison): Add methods tracking visibility and audio changes, to
90 // propogate to the ResourceScheduler. 93 // propogate to the ResourceScheduler.
91 class LoaderIOThreadNotifier : public WebContentsObserver { 94 class LoaderIOThreadNotifier : public WebContentsObserver {
92 public: 95 public:
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 void BeginNavigationRequest( 314 void BeginNavigationRequest(
312 ResourceContext* resource_context, 315 ResourceContext* resource_context,
313 const NavigationRequestInfo& info, 316 const NavigationRequestInfo& info,
314 NavigationURLLoaderImplCore* loader, 317 NavigationURLLoaderImplCore* loader,
315 ServiceWorkerNavigationHandleCore* service_worker_handle_core); 318 ServiceWorkerNavigationHandleCore* service_worker_handle_core);
316 319
317 // Turns on stale-while-revalidate support, regardless of command-line flags 320 // Turns on stale-while-revalidate support, regardless of command-line flags
318 // or experiment status. For unit tests only. 321 // or experiment status. For unit tests only.
319 void EnableStaleWhileRevalidateForTesting(); 322 void EnableStaleWhileRevalidateForTesting();
320 323
324 // These functions are used when loading with mojo.
325 // Stores a URLLoader and a URLLoaderClient in |this| object in order to use
326 // them in the next OnRequestResource call.
327 void SetMojoLoaderAndClientForNextLoadRequest(
kinuko 2016/05/20 15:56:46 Would it possible / make sense to merge this metho
yhirano 2016/05/23 11:29:37 Removed.
328 std::unique_ptr<mojom::URLLoader> loader,
329 mojom::URLLoaderClientPtr client);
330 // Sends |message| with mojo if it is possible and returns whether the message
331 // is sent.
332 bool SendWithMojoIfPossible(const IPC::Message& message,
333 ResourceMessageFilter* filter);
334 // Add an uninitiated (i.e., resource loading is not yet started) loader in
335 // order to keep it alive.
336 void AddUninitiatedURLLoader(int child_id,
337 std::unique_ptr<mojom::URLLoader> loader);
338 // Returns an uninitiated URL loader whose raw pointer equals to |loader|.
339 std::unique_ptr<mojom::URLLoader> TakeUninitiatedURLLoader(
340 mojom::URLLoader* loader);
341
321 private: 342 private:
322 friend class LoaderIOThreadNotifier; 343 friend class LoaderIOThreadNotifier;
323 friend class ResourceDispatcherHostTest; 344 friend class ResourceDispatcherHostTest;
345 class MojoHelper;
324 346
325 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest, 347 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest,
326 TestBlockedRequestsProcessDies); 348 TestBlockedRequestsProcessDies);
327 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest, 349 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest,
328 CalculateApproximateMemoryCost); 350 CalculateApproximateMemoryCost);
329 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest, 351 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest,
330 DetachableResourceTimesOut); 352 DetachableResourceTimesOut);
331 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest, 353 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest,
332 TestProcessCancelDetachableTimesOut); 354 TestProcessCancelDetachableTimesOut);
333 FRIEND_TEST_ALL_PREFIXES(SitePerProcessIgnoreCertErrorsBrowserTest, 355 FRIEND_TEST_ALL_PREFIXES(SitePerProcessIgnoreCertErrorsBrowserTest,
(...skipping 30 matching lines...) Expand all
364 386
365 // An init helper that runs on the IO thread. 387 // An init helper that runs on the IO thread.
366 void OnInit(); 388 void OnInit();
367 389
368 // A shutdown helper that runs on the IO thread. 390 // A shutdown helper that runs on the IO thread.
369 void OnShutdown(); 391 void OnShutdown();
370 392
371 void OnRenderFrameDeleted(const GlobalFrameRoutingId& global_routing_id); 393 void OnRenderFrameDeleted(const GlobalFrameRoutingId& global_routing_id);
372 394
373 // Helper function for regular and download requests. 395 // Helper function for regular and download requests.
374 void BeginRequestInternal(std::unique_ptr<net::URLRequest> request, 396 void BeginRequestInternal(
375 std::unique_ptr<ResourceHandler> handler); 397 std::unique_ptr<net::URLRequest> request,
398 std::unique_ptr<ResourceHandler> handler,
399 std::unique_ptr<mojom::URLLoader> url_loader = nullptr,
400 mojom::URLLoaderClientPtr client = nullptr);
376 401
377 void StartLoading(ResourceRequestInfoImpl* info, 402 void StartLoading(ResourceRequestInfoImpl* info,
378 std::unique_ptr<ResourceLoader> loader); 403 std::unique_ptr<ResourceLoader> loader);
379 404
380 // We keep track of how much memory each request needs and how many requests 405 // We keep track of how much memory each request needs and how many requests
381 // are issued by each renderer. These are known as OustandingRequestStats. 406 // are issued by each renderer. These are known as OustandingRequestStats.
382 // Memory limits apply to all requests sent to us by the renderers. There is a 407 // Memory limits apply to all requests sent to us by the renderers. There is a
383 // limit for each renderer. File descriptor limits apply to requests that are 408 // limit for each renderer. File descriptor limits apply to requests that are
384 // receiving their body. These are known as in-flight requests. There is a 409 // receiving their body. These are known as in-flight requests. There is a
385 // global limit that applies for the browser process. Each render is allowed 410 // global limit that applies for the browser process. Each render is allowed
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 // transferred from one process to another. 501 // transferred from one process to another.
477 void UpdateRequestForTransfer(int child_id, 502 void UpdateRequestForTransfer(int child_id,
478 int route_id, 503 int route_id,
479 int request_id, 504 int request_id,
480 const ResourceRequest& request_data, 505 const ResourceRequest& request_data,
481 LoaderMap::iterator iter); 506 LoaderMap::iterator iter);
482 507
483 void BeginRequest(int request_id, 508 void BeginRequest(int request_id,
484 const ResourceRequest& request_data, 509 const ResourceRequest& request_data,
485 IPC::Message* sync_result, // only valid for sync 510 IPC::Message* sync_result, // only valid for sync
486 int route_id); // only valid for async 511 int route_id, // only valid for async
512 std::unique_ptr<mojom::URLLoader> url_loader = nullptr,
513 mojom::URLLoaderClientPtr client = nullptr);
487 514
488 // Creates a ResourceHandler to be used by BeginRequest() for normal resource 515 // Creates a ResourceHandler to be used by BeginRequest() for normal resource
489 // loading. 516 // loading.
490 std::unique_ptr<ResourceHandler> CreateResourceHandler( 517 std::unique_ptr<ResourceHandler> CreateResourceHandler(
491 net::URLRequest* request, 518 net::URLRequest* request,
492 const ResourceRequest& request_data, 519 const ResourceRequest& request_data,
493 IPC::Message* sync_result, 520 IPC::Message* sync_result,
494 int route_id, 521 int route_id,
495 int process_type, 522 int process_type,
496 int child_id, 523 int child_id,
497 ResourceContext* resource_context); 524 ResourceContext* resource_context,
525 bool using_mojo);
498 526
499 // Wraps |handler| in the standard resource handlers for normal resource 527 // Wraps |handler| in the standard resource handlers for normal resource
500 // loading and navigation requests. This adds MimeTypeResourceHandler and 528 // loading and navigation requests. This adds MimeTypeResourceHandler and
501 // ResourceThrottles. 529 // ResourceThrottles.
502 std::unique_ptr<ResourceHandler> AddStandardHandlers( 530 std::unique_ptr<ResourceHandler> AddStandardHandlers(
503 net::URLRequest* request, 531 net::URLRequest* request,
504 ResourceType resource_type, 532 ResourceType resource_type,
505 ResourceContext* resource_context, 533 ResourceContext* resource_context,
506 AppCacheService* appcache_service, 534 AppCacheService* appcache_service,
507 int child_id, 535 int child_id,
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
656 typedef std::map<GlobalRequestID, 684 typedef std::map<GlobalRequestID,
657 base::ObserverList<ResourceMessageDelegate>*> DelegateMap; 685 base::ObserverList<ResourceMessageDelegate>*> DelegateMap;
658 DelegateMap delegate_map_; 686 DelegateMap delegate_map_;
659 687
660 std::unique_ptr<ResourceScheduler> scheduler_; 688 std::unique_ptr<ResourceScheduler> scheduler_;
661 689
662 // Allows tests to use a mock CertStore. If set, the CertStore must 690 // Allows tests to use a mock CertStore. If set, the CertStore must
663 // outlive this ResourceDispatcherHostImpl. 691 // outlive this ResourceDispatcherHostImpl.
664 CertStore* cert_store_for_testing_; 692 CertStore* cert_store_for_testing_;
665 693
694 std::unique_ptr<MojoHelper> mojo_helper_;
695
666 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcherHostImpl); 696 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcherHostImpl);
667 }; 697 };
668 698
669 } // namespace content 699 } // namespace content
670 700
671 #endif // CONTENT_BROWSER_LOADER_RESOURCE_DISPATCHER_HOST_IMPL_H_ 701 #endif // CONTENT_BROWSER_LOADER_RESOURCE_DISPATCHER_HOST_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698