| 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/macros.h" | 10 #include "base/macros.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 // 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 |
| 33 // chain of ResourceHandlers, and is the ResourceController for its handler. | 33 // chain of ResourceHandlers, and is the ResourceController for its handler. |
| 34 class CONTENT_EXPORT ResourceLoader : public net::URLRequest::Delegate, | 34 class CONTENT_EXPORT ResourceLoader : public net::URLRequest::Delegate, |
| 35 public SSLErrorHandler::Delegate, | 35 public SSLErrorHandler::Delegate, |
| 36 public SSLClientAuthHandler::Delegate, | 36 public SSLClientAuthHandler::Delegate, |
| 37 public ResourceController { | 37 public ResourceController { |
| 38 public: | 38 public: |
| 39 static void GetSSLStatusForRequest(const GURL& url, | 39 static void GetSSLStatusForRequest(const GURL& url, |
| 40 const net::SSLInfo& ssl_info, | 40 const net::SSLInfo& ssl_info, |
| 41 int child_id, | 41 int child_id, |
| 42 CertStore* cert_store, | |
| 43 SSLStatus* ssl_status); | 42 SSLStatus* ssl_status); |
| 44 | 43 |
| 45 ResourceLoader(std::unique_ptr<net::URLRequest> request, | 44 ResourceLoader(std::unique_ptr<net::URLRequest> request, |
| 46 std::unique_ptr<ResourceHandler> handler, | 45 std::unique_ptr<ResourceHandler> handler, |
| 47 CertStore* cert_store, | |
| 48 ResourceLoaderDelegate* delegate); | 46 ResourceLoaderDelegate* delegate); |
| 49 ~ResourceLoader() override; | 47 ~ResourceLoader() override; |
| 50 | 48 |
| 51 void StartRequest(); | 49 void StartRequest(); |
| 52 void CancelRequest(bool from_renderer); | 50 void CancelRequest(bool from_renderer); |
| 53 | 51 |
| 54 bool is_transferring() const { return is_transferring_; } | 52 bool is_transferring() const { return is_transferring_; } |
| 55 void MarkAsTransferring(const scoped_refptr<ResourceResponse>& response); | 53 void MarkAsTransferring(const scoped_refptr<ResourceResponse>& response); |
| 56 void CompleteTransfer(); | 54 void CompleteTransfer(); |
| 57 | 55 |
| 58 net::URLRequest* request() { return request_.get(); } | 56 net::URLRequest* request() { return request_.get(); } |
| 59 ResourceRequestInfoImpl* GetRequestInfo(); | 57 ResourceRequestInfoImpl* GetRequestInfo(); |
| 60 | 58 |
| 61 void ClearLoginDelegate(); | 59 void ClearLoginDelegate(); |
| 62 | 60 |
| 63 // Returns a pointer to the ResourceResponse for a request that is | |
| 64 // being transferred to a new consumer. The response is valid between | |
| 65 // the time that the request is marked as transferring via | |
| 66 // MarkAsTransferring() and the time that the transfer is completed | |
| 67 // via CompleteTransfer(). | |
| 68 ResourceResponse* transferring_response() { | |
| 69 return transferring_response_.get(); | |
| 70 } | |
| 71 | |
| 72 private: | 61 private: |
| 73 // net::URLRequest::Delegate implementation: | 62 // net::URLRequest::Delegate implementation: |
| 74 void OnReceivedRedirect(net::URLRequest* request, | 63 void OnReceivedRedirect(net::URLRequest* request, |
| 75 const net::RedirectInfo& redirect_info, | 64 const net::RedirectInfo& redirect_info, |
| 76 bool* defer) override; | 65 bool* defer) override; |
| 77 void OnAuthRequired(net::URLRequest* request, | 66 void OnAuthRequired(net::URLRequest* request, |
| 78 net::AuthChallengeInfo* info) override; | 67 net::AuthChallengeInfo* info) override; |
| 79 void OnCertificateRequested(net::URLRequest* request, | 68 void OnCertificateRequested(net::URLRequest* request, |
| 80 net::SSLCertRequestInfo* info) override; | 69 net::SSLCertRequestInfo* info) override; |
| 81 void OnSSLCertificateError(net::URLRequest* request, | 70 void OnSSLCertificateError(net::URLRequest* request, |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 scoped_refptr<ResourceDispatcherHostLoginDelegate> login_delegate_; | 130 scoped_refptr<ResourceDispatcherHostLoginDelegate> login_delegate_; |
| 142 std::unique_ptr<SSLClientAuthHandler> ssl_client_auth_handler_; | 131 std::unique_ptr<SSLClientAuthHandler> ssl_client_auth_handler_; |
| 143 | 132 |
| 144 base::TimeTicks read_deferral_start_time_; | 133 base::TimeTicks read_deferral_start_time_; |
| 145 | 134 |
| 146 // 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 |
| 147 // 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 |
| 148 // which point we'll receive a new ResourceHandler. | 137 // which point we'll receive a new ResourceHandler. |
| 149 bool is_transferring_; | 138 bool is_transferring_; |
| 150 | 139 |
| 151 // Holds the ResourceResponse for a request that is being transferred | |
| 152 // to a new consumer. This member is populated when the request is | |
| 153 // marked as transferring via MarkAsTransferring(), and it is cleared | |
| 154 // when the transfer is completed via CompleteTransfer(). | |
| 155 scoped_refptr<ResourceResponse> transferring_response_; | |
| 156 | |
| 157 // Instrumentation add to investigate http://crbug.com/503306. | 140 // Instrumentation add to investigate http://crbug.com/503306. |
| 158 // TODO(mmenke): Remove once bug is fixed. | 141 // TODO(mmenke): Remove once bug is fixed. |
| 159 int times_cancelled_before_request_start_; | 142 int times_cancelled_before_request_start_; |
| 160 bool started_request_; | 143 bool started_request_; |
| 161 int times_cancelled_after_request_start_; | 144 int times_cancelled_after_request_start_; |
| 162 | 145 |
| 163 // Allows tests to use a mock CertStore. The CertStore must outlive | |
| 164 // the ResourceLoader. | |
| 165 CertStore* cert_store_; | |
| 166 | |
| 167 base::WeakPtrFactory<ResourceLoader> weak_ptr_factory_; | 146 base::WeakPtrFactory<ResourceLoader> weak_ptr_factory_; |
| 168 | 147 |
| 169 DISALLOW_COPY_AND_ASSIGN(ResourceLoader); | 148 DISALLOW_COPY_AND_ASSIGN(ResourceLoader); |
| 170 }; | 149 }; |
| 171 | 150 |
| 172 } // namespace content | 151 } // namespace content |
| 173 | 152 |
| 174 #endif // CONTENT_BROWSER_LOADER_RESOURCE_LOADER_H_ | 153 #endif // CONTENT_BROWSER_LOADER_RESOURCE_LOADER_H_ |
| OLD | NEW |