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

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

Powered by Google App Engine
This is Rietveld 408576698