OLD | NEW |
---|---|
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 |
yhirano
2016/10/05 08:49:53
+base/callback.h
tzik
2016/10/06 12:52:03
Done. Added base/callback_forward.h.
| |
22 #include "base/gtest_prod_util.h" | 22 #include "base/gtest_prod_util.h" |
23 #include "base/macros.h" | 23 #include "base/macros.h" |
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/save_types.h" | 27 #include "content/browser/download/save_types.h" |
28 #include "content/browser/loader/global_routing_id.h" | 28 #include "content/browser/loader/global_routing_id.h" |
29 #include "content/browser/loader/resource_loader.h" | 29 #include "content/browser/loader/resource_loader.h" |
30 #include "content/browser/loader/resource_loader_delegate.h" | 30 #include "content/browser/loader/resource_loader_delegate.h" |
31 #include "content/browser/loader/resource_scheduler.h" | 31 #include "content/browser/loader/resource_scheduler.h" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
77 class URLLoader; | 77 class URLLoader; |
78 } // namespace mojom | 78 } // namespace mojom |
79 | 79 |
80 using CreateDownloadHandlerIntercept = | 80 using CreateDownloadHandlerIntercept = |
81 base::Callback<std::unique_ptr<ResourceHandler>(net::URLRequest*)>; | 81 base::Callback<std::unique_ptr<ResourceHandler>(net::URLRequest*)>; |
82 | 82 |
83 class CONTENT_EXPORT ResourceDispatcherHostImpl | 83 class CONTENT_EXPORT ResourceDispatcherHostImpl |
84 : public ResourceDispatcherHost, | 84 : public ResourceDispatcherHost, |
85 public ResourceLoaderDelegate { | 85 public ResourceLoaderDelegate { |
86 public: | 86 public: |
87 using SyncLoadResultCallback = | |
88 base::Callback<void(const SyncLoadResult* result)>; | |
mmenke
2016/10/05 15:21:33
Need to document this.
tzik
2016/10/06 12:52:03
Done.
| |
89 | |
87 // This constructor should be used if we want downloads to work correctly. | 90 // This constructor should be used if we want downloads to work correctly. |
88 // TODO(ananta) | 91 // TODO(ananta) |
89 // Work on moving creation of download handlers out of | 92 // Work on moving creation of download handlers out of |
90 // ResourceDispatcherHostImpl. | 93 // ResourceDispatcherHostImpl. |
91 ResourceDispatcherHostImpl( | 94 ResourceDispatcherHostImpl( |
92 CreateDownloadHandlerIntercept download_handler_intercept); | 95 CreateDownloadHandlerIntercept download_handler_intercept); |
93 ResourceDispatcherHostImpl(); | 96 ResourceDispatcherHostImpl(); |
94 ~ResourceDispatcherHostImpl() override; | 97 ~ResourceDispatcherHostImpl() override; |
95 | 98 |
96 // Returns the current ResourceDispatcherHostImpl. May return NULL if it | 99 // Returns the current ResourceDispatcherHostImpl. May return NULL if it |
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
525 bool IsRequestIDInUse(const GlobalRequestID& id) const; | 528 bool IsRequestIDInUse(const GlobalRequestID& id) const; |
526 | 529 |
527 // Update the ResourceRequestInfo and internal maps when a request is | 530 // Update the ResourceRequestInfo and internal maps when a request is |
528 // transferred from one process to another. | 531 // transferred from one process to another. |
529 void UpdateRequestForTransfer(int child_id, | 532 void UpdateRequestForTransfer(int child_id, |
530 int route_id, | 533 int route_id, |
531 int request_id, | 534 int request_id, |
532 const ResourceRequest& request_data, | 535 const ResourceRequest& request_data, |
533 LoaderMap::iterator iter); | 536 LoaderMap::iterator iter); |
534 | 537 |
535 void BeginRequest(int request_id, | 538 void BeginRequest( |
536 const ResourceRequest& request_data, | 539 int request_id, |
537 IPC::Message* sync_result, // only valid for sync | 540 const ResourceRequest& request_data, |
538 int route_id, // only valid for async | 541 const SyncLoadResultCallback& sync_result_handler, // only valid for sync |
539 mojo::InterfaceRequest<mojom::URLLoader> mojo_request, | 542 int route_id, // only valid for async |
540 mojom::URLLoaderClientPtr url_loader_client); | 543 mojo::InterfaceRequest<mojom::URLLoader> mojo_request, |
544 mojom::URLLoaderClientPtr url_loader_client); | |
541 | 545 |
542 // There are requests which need decisions to be made like the following: | 546 // 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 | 547 // 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 | 548 // valid, etc. These requests may need to be aborted based on these |
545 // decisions which could be time consuming. We allow for these decisions | 549 // decisions which could be time consuming. We allow for these decisions |
546 // to be made asynchronously. The request proceeds when we hear back from | 550 // to be made asynchronously. The request proceeds when we hear back from |
547 // the interceptors about whether to continue or not. | 551 // the interceptors about whether to continue or not. |
548 // The |continue_request| parameter in the function indicates whether the | 552 // The |continue_request| parameter in the function indicates whether the |
549 // request should be continued or aborted. The |error_code| parameter is set | 553 // request should be continued or aborted. The |error_code| parameter is set |
550 // if |continue_request| is false. | 554 // if |continue_request| is false. |
551 void ContinuePendingBeginRequest( | 555 void ContinuePendingBeginRequest( |
552 int request_id, | 556 int request_id, |
553 const ResourceRequest& request_data, | 557 const ResourceRequest& request_data, |
554 IPC::Message* sync_result, // only valid for sync | 558 const SyncLoadResultCallback& sync_result_handler, // only valid for sync |
555 int route_id, | 559 int route_id, |
556 const net::HttpRequestHeaders& headers, | 560 const net::HttpRequestHeaders& headers, |
557 mojo::InterfaceRequest<mojom::URLLoader> mojo_request, | 561 mojo::InterfaceRequest<mojom::URLLoader> mojo_request, |
558 mojom::URLLoaderClientPtr url_loader_client, | 562 mojom::URLLoaderClientPtr url_loader_client, |
559 bool continue_request, | 563 bool continue_request, |
560 int error_code); | 564 int error_code); |
561 | 565 |
562 // Creates a ResourceHandler to be used by BeginRequest() for normal resource | 566 // Creates a ResourceHandler to be used by BeginRequest() for normal resource |
563 // loading. | 567 // loading. |
564 std::unique_ptr<ResourceHandler> CreateResourceHandler( | 568 std::unique_ptr<ResourceHandler> CreateResourceHandler( |
565 net::URLRequest* request, | 569 net::URLRequest* request, |
566 const ResourceRequest& request_data, | 570 const ResourceRequest& request_data, |
567 IPC::Message* sync_result, | 571 const SyncLoadResultCallback& sync_result_handler, |
568 int route_id, | 572 int route_id, |
569 int process_type, | 573 int process_type, |
570 int child_id, | 574 int child_id, |
571 ResourceContext* resource_context, | 575 ResourceContext* resource_context, |
572 mojo::InterfaceRequest<mojom::URLLoader> mojo_request, | 576 mojo::InterfaceRequest<mojom::URLLoader> mojo_request, |
573 mojom::URLLoaderClientPtr url_loader_client); | 577 mojom::URLLoaderClientPtr url_loader_client); |
574 | 578 |
575 // Wraps |handler| in the standard resource handlers for normal resource | 579 // Wraps |handler| in the standard resource handlers for normal resource |
576 // loading and navigation requests. This adds MimeTypeResourceHandler and | 580 // loading and navigation requests. This adds MimeTypeResourceHandler and |
577 // ResourceThrottles. | 581 // ResourceThrottles. |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
749 | 753 |
750 // Points to the registered download handler intercept. | 754 // Points to the registered download handler intercept. |
751 CreateDownloadHandlerIntercept create_download_handler_intercept_; | 755 CreateDownloadHandlerIntercept create_download_handler_intercept_; |
752 | 756 |
753 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcherHostImpl); | 757 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcherHostImpl); |
754 }; | 758 }; |
755 | 759 |
756 } // namespace content | 760 } // namespace content |
757 | 761 |
758 #endif // CONTENT_BROWSER_LOADER_RESOURCE_DISPATCHER_HOST_IMPL_H_ | 762 #endif // CONTENT_BROWSER_LOADER_RESOURCE_DISPATCHER_HOST_IMPL_H_ |
OLD | NEW |