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

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

Issue 2222723002: Avoid calling into the ContentBrowserClient interface from ResourceDispatcherHostImpl to determine … (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix compile failures 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 15 matching lines...) Expand all
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/public/browser/global_request_id.h" 34 #include "content/public/browser/global_request_id.h"
35 #include "content/public/browser/resource_dispatcher_host.h" 35 #include "content/public/browser/resource_dispatcher_host.h"
36 #include "content/public/browser/resource_dispatcher_host_interceptor.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"
39 #include "net/base/request_priority.h" 40 #include "net/base/request_priority.h"
40 #include "net/cookies/canonical_cookie.h" 41 #include "net/cookies/canonical_cookie.h"
41 #include "net/url_request/url_request.h" 42 #include "net/url_request/url_request.h"
42 43
43 class ResourceHandler; 44 class ResourceHandler;
44 45
45 namespace base { 46 namespace base {
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 RenderFrameHost* root_frame_host); 101 RenderFrameHost* root_frame_host);
101 102
102 // Cancels any blocked request for the frame and its subframes. 103 // Cancels any blocked request for the frame and its subframes.
103 static void CancelBlockedRequestsForFrameFromUI( 104 static void CancelBlockedRequestsForFrameFromUI(
104 RenderFrameHostImpl* root_frame_host); 105 RenderFrameHostImpl* root_frame_host);
105 106
106 // ResourceDispatcherHost implementation: 107 // ResourceDispatcherHost implementation:
107 void SetDelegate(ResourceDispatcherHostDelegate* delegate) override; 108 void SetDelegate(ResourceDispatcherHostDelegate* delegate) override;
108 void SetAllowCrossOriginAuthPrompt(bool value) override; 109 void SetAllowCrossOriginAuthPrompt(bool value) override;
109 void ClearLoginDelegateForRequest(net::URLRequest* request) override; 110 void ClearLoginDelegateForRequest(net::URLRequest* request) override;
111 void RegisterInterceptor(
112 const std::string& http_header,
113 const std::string& starts_with,
114 ResourceDispatcherHostInterceptor* interceptor) override;
115 void UnregisterInterceptor(
116 const std::string& http_header,
117 ResourceDispatcherHostInterceptor* interceptor) override;
110 118
111 // Puts the resource dispatcher host in an inactive state (unable to begin 119 // Puts the resource dispatcher host in an inactive state (unable to begin
112 // new requests). Cancels all pending requests. 120 // new requests). Cancels all pending requests.
113 void Shutdown(); 121 void Shutdown();
114 122
115 // Force cancels any pending requests for the given |context|. This is 123 // Force cancels any pending requests for the given |context|. This is
116 // necessary to ensure that before |context| goes away, all requests 124 // necessary to ensure that before |context| goes away, all requests
117 // for it are dead. 125 // for it are dead.
118 void CancelRequestsForContext(ResourceContext* context); 126 void CancelRequestsForContext(ResourceContext* context);
119 127
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 struct LoadInfo { 326 struct LoadInfo {
319 GURL url; 327 GURL url;
320 net::LoadStateWithParam load_state; 328 net::LoadStateWithParam load_state;
321 uint64_t upload_position; 329 uint64_t upload_position;
322 uint64_t upload_size; 330 uint64_t upload_size;
323 }; 331 };
324 332
325 // Map from ProcessID+RouteID pair to the "most interesting" LoadState. 333 // Map from ProcessID+RouteID pair to the "most interesting" LoadState.
326 typedef std::map<GlobalRoutingID, LoadInfo> LoadInfoMap; 334 typedef std::map<GlobalRoutingID, LoadInfo> LoadInfoMap;
327 335
336 // Information about a HTTP header interceptor.
337 struct HeaderInterceptorInfo {
338 // Structure is sufficiently complicated to require the constructor
339 // destructor definitions in the cc file.
340 HeaderInterceptorInfo();
341 ~HeaderInterceptorInfo();
342 HeaderInterceptorInfo(const HeaderInterceptorInfo& other);
343
344 // Used to prefix match the value of the http header.
345 std::string starts_with;
346 // The interceptor.
347 ResourceDispatcherHostInterceptor* interceptor;
348 };
349
350 // Map from HTTP header to its information HeaderInterceptorInfo.
351 typedef std::map<std::string, HeaderInterceptorInfo> HeaderInterceptorMap;
352
328 // ResourceLoaderDelegate implementation: 353 // ResourceLoaderDelegate implementation:
329 ResourceDispatcherHostLoginDelegate* CreateLoginDelegate( 354 ResourceDispatcherHostLoginDelegate* CreateLoginDelegate(
330 ResourceLoader* loader, 355 ResourceLoader* loader,
331 net::AuthChallengeInfo* auth_info) override; 356 net::AuthChallengeInfo* auth_info) override;
332 bool HandleExternalProtocol(ResourceLoader* loader, const GURL& url) override; 357 bool HandleExternalProtocol(ResourceLoader* loader, const GURL& url) override;
333 void DidStartRequest(ResourceLoader* loader) override; 358 void DidStartRequest(ResourceLoader* loader) override;
334 void DidReceiveRedirect(ResourceLoader* loader, const GURL& new_url) override; 359 void DidReceiveRedirect(ResourceLoader* loader, const GURL& new_url) override;
335 void DidReceiveResponse(ResourceLoader* loader) override; 360 void DidReceiveResponse(ResourceLoader* loader) override;
336 void DidFinishLoading(ResourceLoader* loader) override; 361 void DidFinishLoading(ResourceLoader* loader) override;
337 std::unique_ptr<net::ClientCertStore> CreateClientCertStore( 362 std::unique_ptr<net::ClientCertStore> CreateClientCertStore(
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 int route_id, 472 int route_id,
448 int request_id, 473 int request_id,
449 const ResourceRequest& request_data, 474 const ResourceRequest& request_data,
450 LoaderMap::iterator iter); 475 LoaderMap::iterator iter);
451 476
452 void BeginRequest(int request_id, 477 void BeginRequest(int request_id,
453 const ResourceRequest& request_data, 478 const ResourceRequest& request_data,
454 IPC::Message* sync_result, // only valid for sync 479 IPC::Message* sync_result, // only valid for sync
455 int route_id); // only valid for async 480 int route_id); // only valid for async
456 481
482 // There are requests which need decisions to be made like the following:
483 // Whether the presence of certain HTTP headers like the Origin header are
484 // valid, etc. These requests may need to be aborted based on these
485 // decisions which could be time consuming. We allow for these decisions
486 // to be made asynchronously. The request proceeds when we hear back from
487 // the interceptors about whether to continue or not.
488 // The |continue_request| parameter in the function indicates whether the
489 // request should be continued or aborted. The |error_code| parameter is set
490 // if |continue_request| is false.
491 void ContinuePendingBeginRequest(
492 int request_id,
493 const ResourceRequest& request_data,
494 IPC::Message* sync_result, // only valid for sync
495 int route_id,
496 const net::HttpRequestHeaders& headers,
497 bool continue_request,
498 int error_code);
499
457 // Creates a ResourceHandler to be used by BeginRequest() for normal resource 500 // Creates a ResourceHandler to be used by BeginRequest() for normal resource
458 // loading. 501 // loading.
459 std::unique_ptr<ResourceHandler> CreateResourceHandler( 502 std::unique_ptr<ResourceHandler> CreateResourceHandler(
460 net::URLRequest* request, 503 net::URLRequest* request,
461 const ResourceRequest& request_data, 504 const ResourceRequest& request_data,
462 IPC::Message* sync_result, 505 IPC::Message* sync_result,
463 int route_id, 506 int route_id,
464 int process_type, 507 int process_type,
465 int child_id, 508 int child_id,
466 ResourceContext* resource_context); 509 ResourceContext* resource_context);
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 // The certificate on a ResourceResponse is associated with a 573 // The certificate on a ResourceResponse is associated with a
531 // particular renderer process. As a transfer to a new process 574 // particular renderer process. As a transfer to a new process
532 // completes, the stored certificate has to be updated to reflect the 575 // completes, the stored certificate has to be updated to reflect the
533 // new renderer process. 576 // new renderer process.
534 void UpdateResponseCertificateForTransfer(ResourceResponse* response, 577 void UpdateResponseCertificateForTransfer(ResourceResponse* response,
535 const net::SSLInfo& ssl_info, 578 const net::SSLInfo& ssl_info,
536 int child_id); 579 int child_id);
537 580
538 CertStore* GetCertStore(); 581 CertStore* GetCertStore();
539 582
583 // This enum holds values which indicate how we want to proceed with a
584 // request that is about to be started.
585 enum BeginRequestStatus {
586 CONTINUE = 0, // Continue with the request.
587 ABORT = 1, // Abort.
588 PENDING = 2, // Wait for the decision to come back.
589 LAST_SERVICE_REQUEST_STATUS = PENDING,
590 };
591
592 // Consults the RendererSecurity policy to determine whether the
593 // ResourceDispatcherHostImpl should service this request. A request might
594 // be disallowed if the renderer is not authorized to retrieve the request
595 // URL or if the renderer is attempting to upload an unauthorized file.
596 BeginRequestStatus ShouldServiceRequest(
597 int process_type,
598 int child_id,
599 const ResourceRequest& request_data,
600 const net::HttpRequestHeaders& headers,
601 ResourceMessageFilter* filter,
602 ResourceContext* resource_context,
603 ResourceDispatcherHostInterceptor::OnHeaderProcessedCallback callback);
604
540 LoaderMap pending_loaders_; 605 LoaderMap pending_loaders_;
541 606
542 // Collection of temp files downloaded for child processes via 607 // Collection of temp files downloaded for child processes via
543 // the download_to_file mechanism. We avoid deleting them until 608 // the download_to_file mechanism. We avoid deleting them until
544 // the client no longer needs them. 609 // the client no longer needs them.
545 typedef std::map<int, scoped_refptr<storage::ShareableFileReference> > 610 typedef std::map<int, scoped_refptr<storage::ShareableFileReference> >
546 DeletableFilesMap; // key is request id 611 DeletableFilesMap; // key is request id
547 typedef std::map<int, DeletableFilesMap> 612 typedef std::map<int, DeletableFilesMap>
548 RegisteredTempFiles; // key is child process id 613 RegisteredTempFiles; // key is child process id
549 RegisteredTempFiles registered_temp_files_; 614 RegisteredTempFiles registered_temp_files_;
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
624 typedef std::map<GlobalRequestID, 689 typedef std::map<GlobalRequestID,
625 base::ObserverList<ResourceMessageDelegate>*> DelegateMap; 690 base::ObserverList<ResourceMessageDelegate>*> DelegateMap;
626 DelegateMap delegate_map_; 691 DelegateMap delegate_map_;
627 692
628 std::unique_ptr<ResourceScheduler> scheduler_; 693 std::unique_ptr<ResourceScheduler> scheduler_;
629 694
630 // Allows tests to use a mock CertStore. If set, the CertStore must 695 // Allows tests to use a mock CertStore. If set, the CertStore must
631 // outlive this ResourceDispatcherHostImpl. 696 // outlive this ResourceDispatcherHostImpl.
632 CertStore* cert_store_for_testing_; 697 CertStore* cert_store_for_testing_;
633 698
699 // Used to invoke an interceptor for the HTTP header.
700 HeaderInterceptorMap http_header_interceptor_map_;
701
634 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcherHostImpl); 702 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcherHostImpl);
635 }; 703 };
636 704
637 } // namespace content 705 } // namespace content
638 706
639 #endif // CONTENT_BROWSER_LOADER_RESOURCE_DISPATCHER_HOST_IMPL_H_ 707 #endif // CONTENT_BROWSER_LOADER_RESOURCE_DISPATCHER_HOST_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698