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

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

Issue 2390313002: Make SyncLoad result handling pluggable (Closed)
Patch Set: fix Created 4 years, 2 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
« no previous file with comments | « no previous file | content/browser/loader/resource_dispatcher_host_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
11 11
12 #ifndef CONTENT_BROWSER_LOADER_RESOURCE_DISPATCHER_HOST_IMPL_H_ 12 #ifndef CONTENT_BROWSER_LOADER_RESOURCE_DISPATCHER_HOST_IMPL_H_
13 #define CONTENT_BROWSER_LOADER_RESOURCE_DISPATCHER_HOST_IMPL_H_ 13 #define CONTENT_BROWSER_LOADER_RESOURCE_DISPATCHER_HOST_IMPL_H_
14 14
15 #include <stdint.h> 15 #include <stdint.h>
16 16
17 #include <map> 17 #include <map>
18 #include <memory> 18 #include <memory>
19 #include <string> 19 #include <string>
20 #include <vector> 20 #include <vector>
21 21
22 #include "base/callback_forward.h"
22 #include "base/gtest_prod_util.h" 23 #include "base/gtest_prod_util.h"
23 #include "base/macros.h" 24 #include "base/macros.h"
24 #include "base/observer_list.h" 25 #include "base/observer_list.h"
25 #include "base/time/time.h" 26 #include "base/time/time.h"
26 #include "base/timer/timer.h" 27 #include "base/timer/timer.h"
27 #include "content/browser/download/save_types.h" 28 #include "content/browser/download/save_types.h"
28 #include "content/browser/loader/global_routing_id.h" 29 #include "content/browser/loader/global_routing_id.h"
29 #include "content/browser/loader/resource_loader.h" 30 #include "content/browser/loader/resource_loader.h"
30 #include "content/browser/loader/resource_loader_delegate.h" 31 #include "content/browser/loader/resource_loader_delegate.h"
31 #include "content/browser/loader/resource_scheduler.h" 32 #include "content/browser/loader/resource_scheduler.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 class URLLoader; 78 class URLLoader;
78 } // namespace mojom 79 } // namespace mojom
79 80
80 using CreateDownloadHandlerIntercept = 81 using CreateDownloadHandlerIntercept =
81 base::Callback<std::unique_ptr<ResourceHandler>(net::URLRequest*)>; 82 base::Callback<std::unique_ptr<ResourceHandler>(net::URLRequest*)>;
82 83
83 class CONTENT_EXPORT ResourceDispatcherHostImpl 84 class CONTENT_EXPORT ResourceDispatcherHostImpl
84 : public ResourceDispatcherHost, 85 : public ResourceDispatcherHost,
85 public ResourceLoaderDelegate { 86 public ResourceLoaderDelegate {
86 public: 87 public:
88 // Used to handle the result of SyncLoad IPC. |result| is null if it's
89 // unavailable due to an error.
90 using SyncLoadResultCallback =
91 base::Callback<void(const SyncLoadResult* result)>;
92
87 // This constructor should be used if we want downloads to work correctly. 93 // This constructor should be used if we want downloads to work correctly.
88 // TODO(ananta) 94 // TODO(ananta)
89 // Work on moving creation of download handlers out of 95 // Work on moving creation of download handlers out of
90 // ResourceDispatcherHostImpl. 96 // ResourceDispatcherHostImpl.
91 ResourceDispatcherHostImpl( 97 ResourceDispatcherHostImpl(
92 CreateDownloadHandlerIntercept download_handler_intercept); 98 CreateDownloadHandlerIntercept download_handler_intercept);
93 ResourceDispatcherHostImpl(); 99 ResourceDispatcherHostImpl();
94 ~ResourceDispatcherHostImpl() override; 100 ~ResourceDispatcherHostImpl() override;
95 101
96 // Returns the current ResourceDispatcherHostImpl. May return NULL if it 102 // Returns the current ResourceDispatcherHostImpl. May return NULL if it
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 ResourceMessageFilter* filter); 143 ResourceMessageFilter* filter);
138 144
139 // Cancels the given request if it still exists. 145 // Cancels the given request if it still exists.
140 void CancelRequest(int child_id, int request_id); 146 void CancelRequest(int child_id, int request_id);
141 147
142 // Marks the request, with its current |response|, as "parked". This 148 // Marks the request, with its current |response|, as "parked". This
143 // happens if a request is redirected cross-site and needs to be 149 // happens if a request is redirected cross-site and needs to be
144 // resumed by a new process. 150 // resumed by a new process.
145 void MarkAsTransferredNavigation( 151 void MarkAsTransferredNavigation(
146 const GlobalRequestID& id, 152 const GlobalRequestID& id,
147 const scoped_refptr<ResourceResponse>& response); 153 const scoped_refptr<ResourceResponse>& response);
mmenke 2016/10/06 15:16:48 include base/memory/ref_counted.h
tzik 2016/10/06 16:08:54 Done.
148 154
149 // Cancels a request previously marked as being transferred, for use when a 155 // Cancels a request previously marked as being transferred, for use when a
150 // navigation was cancelled. 156 // navigation was cancelled.
151 void CancelTransferringNavigation(const GlobalRequestID& id); 157 void CancelTransferringNavigation(const GlobalRequestID& id);
152 158
153 // Resumes the request without transferring it to a new process. 159 // Resumes the request without transferring it to a new process.
154 void ResumeDeferredNavigation(const GlobalRequestID& id); 160 void ResumeDeferredNavigation(const GlobalRequestID& id);
155 161
156 // Returns the number of pending requests. This is designed for the unittests 162 // Returns the number of pending requests. This is designed for the unittests
157 int pending_requests() const { 163 int pending_requests() const {
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 bool IsRequestIDInUse(const GlobalRequestID& id) const; 531 bool IsRequestIDInUse(const GlobalRequestID& id) const;
526 532
527 // Update the ResourceRequestInfo and internal maps when a request is 533 // Update the ResourceRequestInfo and internal maps when a request is
528 // transferred from one process to another. 534 // transferred from one process to another.
529 void UpdateRequestForTransfer(int child_id, 535 void UpdateRequestForTransfer(int child_id,
530 int route_id, 536 int route_id,
531 int request_id, 537 int request_id,
532 const ResourceRequest& request_data, 538 const ResourceRequest& request_data,
533 LoaderMap::iterator iter); 539 LoaderMap::iterator iter);
534 540
535 void BeginRequest(int request_id, 541 void BeginRequest(
536 const ResourceRequest& request_data, 542 int request_id,
537 IPC::Message* sync_result, // only valid for sync 543 const ResourceRequest& request_data,
538 int route_id, // only valid for async 544 const SyncLoadResultCallback& sync_result_handler, // only valid for sync
539 mojo::InterfaceRequest<mojom::URLLoader> mojo_request, 545 int route_id, // only valid for async
540 mojom::URLLoaderClientPtr url_loader_client); 546 mojo::InterfaceRequest<mojom::URLLoader> mojo_request,
547 mojom::URLLoaderClientPtr url_loader_client);
541 548
542 // There are requests which need decisions to be made like the following: 549 // There are requests which need decisions to be made like the following:
543 // Whether the presence of certain HTTP headers like the Origin header are 550 // Whether the presence of certain HTTP headers like the Origin header are
544 // valid, etc. These requests may need to be aborted based on these 551 // valid, etc. These requests may need to be aborted based on these
545 // decisions which could be time consuming. We allow for these decisions 552 // decisions which could be time consuming. We allow for these decisions
546 // to be made asynchronously. The request proceeds when we hear back from 553 // to be made asynchronously. The request proceeds when we hear back from
547 // the interceptors about whether to continue or not. 554 // the interceptors about whether to continue or not.
548 // The |continue_request| parameter in the function indicates whether the 555 // The |continue_request| parameter in the function indicates whether the
549 // request should be continued or aborted. The |error_code| parameter is set 556 // request should be continued or aborted. The |error_code| parameter is set
550 // if |continue_request| is false. 557 // if |continue_request| is false.
551 void ContinuePendingBeginRequest( 558 void ContinuePendingBeginRequest(
552 int request_id, 559 int request_id,
553 const ResourceRequest& request_data, 560 const ResourceRequest& request_data,
554 IPC::Message* sync_result, // only valid for sync 561 const SyncLoadResultCallback& sync_result_handler, // only valid for sync
555 int route_id, 562 int route_id,
556 const net::HttpRequestHeaders& headers, 563 const net::HttpRequestHeaders& headers,
557 mojo::InterfaceRequest<mojom::URLLoader> mojo_request, 564 mojo::InterfaceRequest<mojom::URLLoader> mojo_request,
558 mojom::URLLoaderClientPtr url_loader_client, 565 mojom::URLLoaderClientPtr url_loader_client,
559 bool continue_request, 566 bool continue_request,
560 int error_code); 567 int error_code);
561 568
562 // Creates a ResourceHandler to be used by BeginRequest() for normal resource 569 // Creates a ResourceHandler to be used by BeginRequest() for normal resource
563 // loading. 570 // loading.
564 std::unique_ptr<ResourceHandler> CreateResourceHandler( 571 std::unique_ptr<ResourceHandler> CreateResourceHandler(
565 net::URLRequest* request, 572 net::URLRequest* request,
566 const ResourceRequest& request_data, 573 const ResourceRequest& request_data,
567 IPC::Message* sync_result, 574 const SyncLoadResultCallback& sync_result_handler,
568 int route_id, 575 int route_id,
569 int process_type, 576 int process_type,
570 int child_id, 577 int child_id,
571 ResourceContext* resource_context, 578 ResourceContext* resource_context,
572 mojo::InterfaceRequest<mojom::URLLoader> mojo_request, 579 mojo::InterfaceRequest<mojom::URLLoader> mojo_request,
573 mojom::URLLoaderClientPtr url_loader_client); 580 mojom::URLLoaderClientPtr url_loader_client);
574 581
575 // Wraps |handler| in the standard resource handlers for normal resource 582 // Wraps |handler| in the standard resource handlers for normal resource
576 // loading and navigation requests. This adds MimeTypeResourceHandler and 583 // loading and navigation requests. This adds MimeTypeResourceHandler and
577 // ResourceThrottles. 584 // ResourceThrottles.
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
749 756
750 // Points to the registered download handler intercept. 757 // Points to the registered download handler intercept.
751 CreateDownloadHandlerIntercept create_download_handler_intercept_; 758 CreateDownloadHandlerIntercept create_download_handler_intercept_;
752 759
753 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcherHostImpl); 760 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcherHostImpl);
754 }; 761 };
755 762
756 } // namespace content 763 } // namespace content
757 764
758 #endif // CONTENT_BROWSER_LOADER_RESOURCE_DISPATCHER_HOST_IMPL_H_ 765 #endif // CONTENT_BROWSER_LOADER_RESOURCE_DISPATCHER_HOST_IMPL_H_
OLDNEW
« no previous file with comments | « no previous file | content/browser/loader/resource_dispatcher_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698