Chromium Code Reviews| 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 #ifndef CONTENT_BROWSER_LOADER_RESOURCE_LOADER_H_ | 5 #ifndef CONTENT_BROWSER_LOADER_RESOURCE_LOADER_H_ |
| 6 #define CONTENT_BROWSER_LOADER_RESOURCE_LOADER_H_ | 6 #define CONTENT_BROWSER_LOADER_RESOURCE_LOADER_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/callback_forward.h" | 10 #include "base/callback_forward.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
| 14 #include "content/browser/ssl/ssl_client_auth_handler.h" | 14 #include "content/browser/ssl/ssl_client_auth_handler.h" |
| 15 #include "content/browser/ssl/ssl_error_handler.h" | 15 #include "content/browser/ssl/ssl_error_handler.h" |
| 16 #include "content/common/content_export.h" | 16 #include "content/common/content_export.h" |
| 17 #include "content/common/url_loader.mojom.h" | |
| 17 #include "content/public/browser/resource_controller.h" | 18 #include "content/public/browser/resource_controller.h" |
| 18 #include "net/url_request/url_request.h" | 19 #include "net/url_request/url_request.h" |
| 19 | 20 |
| 20 namespace net { | 21 namespace net { |
| 21 class X509Certificate; | 22 class X509Certificate; |
| 22 } | 23 } |
| 23 | 24 |
| 24 namespace content { | 25 namespace content { |
| 25 class ResourceDispatcherHostLoginDelegate; | 26 class ResourceDispatcherHostLoginDelegate; |
| 26 class ResourceHandler; | 27 class ResourceHandler; |
| 27 class ResourceLoaderDelegate; | 28 class ResourceLoaderDelegate; |
| 28 class ResourceRequestInfoImpl; | 29 class ResourceRequestInfoImpl; |
| 29 | 30 |
| 30 // This class is responsible for driving the URLRequest (i.e., calling Start, | 31 // This class is responsible for driving the URLRequest (i.e., calling Start, |
| 31 // Read, and servicing events). It has a ResourceHandler, which is typically a | 32 // Read, and servicing events). It has a ResourceHandler, which is typically a |
| 32 // chain of ResourceHandlers, and is the ResourceController for its handler. | 33 // chain of ResourceHandlers, and is the ResourceController for its handler. |
| 33 class CONTENT_EXPORT ResourceLoader : public net::URLRequest::Delegate, | 34 class CONTENT_EXPORT ResourceLoader : public net::URLRequest::Delegate, |
| 34 public SSLErrorHandler::Delegate, | 35 public SSLErrorHandler::Delegate, |
| 35 public SSLClientAuthHandler::Delegate, | 36 public SSLClientAuthHandler::Delegate, |
| 36 public ResourceController { | 37 public ResourceController { |
| 38 using TransferCallback = | |
| 39 base::Callback<void(mojom::URLLoaderAssociatedRequest, | |
| 40 mojom::URLLoaderClientAssociatedPtr)>; | |
| 41 | |
| 37 public: | 42 public: |
| 38 ResourceLoader(std::unique_ptr<net::URLRequest> request, | 43 ResourceLoader(std::unique_ptr<net::URLRequest> request, |
| 39 std::unique_ptr<ResourceHandler> handler, | 44 std::unique_ptr<ResourceHandler> handler, |
| 40 ResourceLoaderDelegate* delegate); | 45 ResourceLoaderDelegate* delegate); |
| 41 ~ResourceLoader() override; | 46 ~ResourceLoader() override; |
| 42 | 47 |
| 43 void StartRequest(); | 48 void StartRequest(); |
| 44 void CancelRequest(bool from_renderer); | 49 void CancelRequest(bool from_renderer); |
| 45 | 50 |
| 46 bool is_transferring() const { return is_transferring_; } | 51 bool is_transferring() const { return is_transferring_; } |
| 47 void MarkAsTransferring(const base::Closure& on_transfer_complete_callback); | 52 void MarkAsTransferring( |
| 48 void CompleteTransfer(); | 53 const TransferCallback& on_transfer_complete_callback); |
| 54 void CompleteTransfer(mojom::URLLoaderAssociatedRequest, | |
| 55 mojom::URLLoaderClientAssociatedPtr); | |
| 49 | 56 |
| 50 net::URLRequest* request() { return request_.get(); } | 57 net::URLRequest* request() { return request_.get(); } |
| 51 ResourceRequestInfoImpl* GetRequestInfo(); | 58 ResourceRequestInfoImpl* GetRequestInfo(); |
| 52 | 59 |
| 53 void ClearLoginDelegate(); | 60 void ClearLoginDelegate(); |
| 54 | 61 |
| 55 private: | 62 private: |
| 56 // net::URLRequest::Delegate implementation: | 63 // net::URLRequest::Delegate implementation: |
| 57 void OnReceivedRedirect(net::URLRequest* request, | 64 void OnReceivedRedirect(net::URLRequest* request, |
| 58 const net::RedirectInfo& redirect_info, | 65 const net::RedirectInfo& redirect_info, |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 123 scoped_refptr<ResourceDispatcherHostLoginDelegate> login_delegate_; | 130 scoped_refptr<ResourceDispatcherHostLoginDelegate> login_delegate_; |
| 124 std::unique_ptr<SSLClientAuthHandler> ssl_client_auth_handler_; | 131 std::unique_ptr<SSLClientAuthHandler> ssl_client_auth_handler_; |
| 125 | 132 |
| 126 base::TimeTicks read_deferral_start_time_; | 133 base::TimeTicks read_deferral_start_time_; |
| 127 | 134 |
| 128 // Indicates that we are in a state of being transferred to a new downstream | 135 // Indicates that we are in a state of being transferred to a new downstream |
| 129 // consumer. We are waiting for a notification to complete the transfer, at | 136 // consumer. We are waiting for a notification to complete the transfer, at |
| 130 // which point we'll receive a new ResourceHandler. | 137 // which point we'll receive a new ResourceHandler. |
| 131 bool is_transferring_; | 138 bool is_transferring_; |
| 132 | 139 |
| 133 // Called when a navigation has finished transfer. | 140 // Called when a navigation has finished transfer. |
|
clamy
2016/11/21 17:55:54
Can you mention that this will update the Navigati
| |
| 134 base::Closure on_transfer_complete_callback_; | 141 TransferCallback on_transfer_complete_callback_; |
| 135 | 142 |
| 136 // Instrumentation add to investigate http://crbug.com/503306. | 143 // Instrumentation add to investigate http://crbug.com/503306. |
| 137 // TODO(mmenke): Remove once bug is fixed. | 144 // TODO(mmenke): Remove once bug is fixed. |
| 138 int times_cancelled_before_request_start_; | 145 int times_cancelled_before_request_start_; |
| 139 bool started_request_; | 146 bool started_request_; |
| 140 int times_cancelled_after_request_start_; | 147 int times_cancelled_after_request_start_; |
| 141 | 148 |
| 142 base::WeakPtrFactory<ResourceLoader> weak_ptr_factory_; | 149 base::WeakPtrFactory<ResourceLoader> weak_ptr_factory_; |
| 143 | 150 |
| 144 DISALLOW_COPY_AND_ASSIGN(ResourceLoader); | 151 DISALLOW_COPY_AND_ASSIGN(ResourceLoader); |
| 145 }; | 152 }; |
| 146 | 153 |
| 147 } // namespace content | 154 } // namespace content |
| 148 | 155 |
| 149 #endif // CONTENT_BROWSER_LOADER_RESOURCE_LOADER_H_ | 156 #endif // CONTENT_BROWSER_LOADER_RESOURCE_LOADER_H_ |
| OLD | NEW |