| 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 "base/gtest_prod_util.h" |
| 8 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| 10 #include "content/browser/loader/resource_handler.h" | 11 #include "content/browser/loader/resource_handler.h" |
| 11 #include "content/browser/ssl/ssl_error_handler.h" | 12 #include "content/browser/ssl/ssl_error_handler.h" |
| 13 #include "content/common/content_export.h" |
| 12 #include "content/public/browser/resource_controller.h" | 14 #include "content/public/browser/resource_controller.h" |
| 13 #include "net/url_request/url_request.h" | 15 #include "net/url_request/url_request.h" |
| 14 | 16 |
| 17 namespace net { |
| 18 class ClientCertStore; |
| 19 } |
| 20 |
| 15 namespace content { | 21 namespace content { |
| 16 class ResourceDispatcherHostLoginDelegate; | 22 class ResourceDispatcherHostLoginDelegate; |
| 17 class ResourceLoaderDelegate; | 23 class ResourceLoaderDelegate; |
| 18 class ResourceRequestInfoImpl; | 24 class ResourceRequestInfoImpl; |
| 19 class SSLClientAuthHandler; | 25 class SSLClientAuthHandler; |
| 20 | 26 |
| 21 // This class is responsible for driving the URLRequest (i.e., calling Start, | 27 // This class is responsible for driving the URLRequest (i.e., calling Start, |
| 22 // Read, and servicing events). It has a ResourceHandler, which is typically a | 28 // Read, and servicing events). It has a ResourceHandler, which is typically a |
| 23 // chain of ResourceHandlers, and is the ResourceController for its handler. | 29 // chain of ResourceHandlers, and is the ResourceController for its handler. |
| 24 class ResourceLoader : public net::URLRequest::Delegate, | 30 class CONTENT_EXPORT ResourceLoader : public net::URLRequest::Delegate, |
| 25 public SSLErrorHandler::Delegate, | 31 public SSLErrorHandler::Delegate, |
| 26 public ResourceController { | 32 public ResourceController { |
| 27 public: | 33 public: |
| 28 ResourceLoader(scoped_ptr<net::URLRequest> request, | 34 ResourceLoader(scoped_ptr<net::URLRequest> request, |
| 29 scoped_ptr<ResourceHandler> handler, | 35 scoped_ptr<ResourceHandler> handler, |
| 30 ResourceLoaderDelegate* delegate); | 36 ResourceLoaderDelegate* delegate); |
| 31 virtual ~ResourceLoader(); | 37 virtual ~ResourceLoader(); |
| 32 | 38 |
| 33 void StartRequest(); | 39 void StartRequest(); |
| 34 void CancelRequest(bool from_renderer); | 40 void CancelRequest(bool from_renderer); |
| 35 | 41 |
| 36 void ReportUploadProgress(); | 42 void ReportUploadProgress(); |
| 37 | 43 |
| 38 bool is_transferring() const { return is_transferring_; } | 44 bool is_transferring() const { return is_transferring_; } |
| 39 void MarkAsTransferring(); | 45 void MarkAsTransferring(); |
| 40 void WillCompleteTransfer(); | 46 void WillCompleteTransfer(); |
| 41 void CompleteTransfer(scoped_ptr<ResourceHandler> new_handler); | 47 void CompleteTransfer(scoped_ptr<ResourceHandler> new_handler); |
| 42 | 48 |
| 43 net::URLRequest* request() { return request_.get(); } | 49 net::URLRequest* request() { return request_.get(); } |
| 44 ResourceRequestInfoImpl* GetRequestInfo(); | 50 ResourceRequestInfoImpl* GetRequestInfo(); |
| 45 | 51 |
| 46 void ClearLoginDelegate(); | 52 void ClearLoginDelegate(); |
| 47 void ClearSSLClientAuthHandler(); | 53 void ClearSSLClientAuthHandler(); |
| 48 | 54 |
| 49 // IPC message handlers: | 55 // IPC message handlers: |
| 50 void OnUploadProgressACK(); | 56 void OnUploadProgressACK(); |
| 51 | 57 |
| 52 private: | 58 private: |
| 59 FRIEND_TEST_ALL_PREFIXES(ResourceLoaderTest, ClientCertStoreLookup); |
| 60 |
| 61 ResourceLoader(scoped_ptr<net::URLRequest> request, |
| 62 scoped_ptr<ResourceHandler> handler, |
| 63 ResourceLoaderDelegate* delegate, |
| 64 scoped_ptr<net::ClientCertStore> client_cert_store); |
| 65 |
| 66 // Initialization logic shared between the public and private constructor. |
| 67 void Init(scoped_ptr<net::URLRequest> request, |
| 68 scoped_ptr<ResourceHandler> handler, |
| 69 ResourceLoaderDelegate* delegate, |
| 70 scoped_ptr<net::ClientCertStore> client_cert_store); |
| 71 |
| 53 // net::URLRequest::Delegate implementation: | 72 // net::URLRequest::Delegate implementation: |
| 54 virtual void OnReceivedRedirect(net::URLRequest* request, | 73 virtual void OnReceivedRedirect(net::URLRequest* request, |
| 55 const GURL& new_url, | 74 const GURL& new_url, |
| 56 bool* defer) OVERRIDE; | 75 bool* defer) OVERRIDE; |
| 57 virtual void OnAuthRequired(net::URLRequest* request, | 76 virtual void OnAuthRequired(net::URLRequest* request, |
| 58 net::AuthChallengeInfo* info) OVERRIDE; | 77 net::AuthChallengeInfo* info) OVERRIDE; |
| 59 virtual void OnCertificateRequested(net::URLRequest* request, | 78 virtual void OnCertificateRequested(net::URLRequest* request, |
| 60 net::SSLCertRequestInfo* info) OVERRIDE; | 79 net::SSLCertRequestInfo* info) OVERRIDE; |
| 61 virtual void OnSSLCertificateError(net::URLRequest* request, | 80 virtual void OnSSLCertificateError(net::URLRequest* request, |
| 62 const net::SSLInfo& info, | 81 const net::SSLInfo& info, |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 | 126 |
| 108 uint64 last_upload_position_; | 127 uint64 last_upload_position_; |
| 109 bool waiting_for_upload_progress_ack_; | 128 bool waiting_for_upload_progress_ack_; |
| 110 base::TimeTicks last_upload_ticks_; | 129 base::TimeTicks last_upload_ticks_; |
| 111 | 130 |
| 112 // Indicates that we are in a state of being transferred to a new downstream | 131 // Indicates that we are in a state of being transferred to a new downstream |
| 113 // consumer. We are waiting for a notification to complete the transfer, at | 132 // consumer. We are waiting for a notification to complete the transfer, at |
| 114 // which point we'll receive a new ResourceHandler. | 133 // which point we'll receive a new ResourceHandler. |
| 115 bool is_transferring_; | 134 bool is_transferring_; |
| 116 | 135 |
| 136 scoped_ptr<net::ClientCertStore> client_cert_store_; |
| 137 |
| 117 base::WeakPtrFactory<ResourceLoader> weak_ptr_factory_; | 138 base::WeakPtrFactory<ResourceLoader> weak_ptr_factory_; |
| 118 | 139 |
| 119 DISALLOW_COPY_AND_ASSIGN(ResourceLoader); | 140 DISALLOW_COPY_AND_ASSIGN(ResourceLoader); |
| 120 }; | 141 }; |
| 121 | 142 |
| 122 } // namespace content | 143 } // namespace content |
| 123 | 144 |
| 124 #endif // CONTENT_BROWSER_LOADER_RESOURCE_LOADER_H_ | 145 #endif // CONTENT_BROWSER_LOADER_RESOURCE_LOADER_H_ |
| OLD | NEW |