| 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 NET_URL_REQUEST_URL_REQUEST_FTP_JOB_H_ | 5 #ifndef NET_URL_REQUEST_URL_REQUEST_FTP_JOB_H_ |
| 6 #define NET_URL_REQUEST_URL_REQUEST_FTP_JOB_H_ | 6 #define NET_URL_REQUEST_URL_REQUEST_FTP_JOB_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| 11 #include "net/base/auth.h" | 11 #include "net/base/auth.h" |
| 12 #include "net/base/net_export.h" |
| 12 #include "net/ftp/ftp_request_info.h" | 13 #include "net/ftp/ftp_request_info.h" |
| 13 #include "net/ftp/ftp_transaction.h" | 14 #include "net/ftp/ftp_transaction.h" |
| 14 #include "net/http/http_request_info.h" | 15 #include "net/http/http_request_info.h" |
| 15 #include "net/http/http_transaction.h" | 16 #include "net/http/http_transaction.h" |
| 16 #include "net/proxy/proxy_info.h" | 17 #include "net/proxy/proxy_info.h" |
| 17 #include "net/proxy/proxy_service.h" | 18 #include "net/proxy/proxy_service.h" |
| 18 #include "net/url_request/url_request_job.h" | 19 #include "net/url_request/url_request_job.h" |
| 19 | 20 |
| 20 namespace net { | 21 namespace net { |
| 21 | 22 |
| 22 class NetworkDelegate; | 23 class NetworkDelegate; |
| 23 class FtpTransactionFactory; | 24 class FtpTransactionFactory; |
| 24 class FtpAuthCache; | 25 class FtpAuthCache; |
| 25 | 26 |
| 26 // A URLRequestJob subclass that is built on top of FtpTransaction. It | 27 // A URLRequestJob subclass that is built on top of FtpTransaction. It |
| 27 // provides an implementation for FTP. | 28 // provides an implementation for FTP. |
| 28 class URLRequestFtpJob : public URLRequestJob { | 29 class NET_EXPORT_PRIVATE URLRequestFtpJob : public URLRequestJob { |
| 29 public: | 30 public: |
| 30 URLRequestFtpJob(URLRequest* request, | 31 URLRequestFtpJob(URLRequest* request, |
| 31 NetworkDelegate* network_delegate, | 32 NetworkDelegate* network_delegate, |
| 32 FtpTransactionFactory* ftp_transaction_factory, | 33 FtpTransactionFactory* ftp_transaction_factory, |
| 33 FtpAuthCache* ftp_auth_cache); | 34 FtpAuthCache* ftp_auth_cache); |
| 34 | 35 |
| 35 // TODO(shalev): get rid of this function in favor of FtpProtocolHandler. | 36 // TODO(shalev): get rid of this function in favor of FtpProtocolHandler. |
| 36 static URLRequestJob* Factory(URLRequest* request, | 37 static URLRequestJob* Factory(URLRequest* request, |
| 37 NetworkDelegate* network_delegate, | 38 NetworkDelegate* network_delegate, |
| 38 const std::string& scheme); | 39 const std::string& scheme); |
| 39 | 40 |
| 41 protected: |
| 42 virtual ~URLRequestFtpJob(); |
| 43 |
| 40 // Overridden from URLRequestJob: | 44 // Overridden from URLRequestJob: |
| 41 virtual bool IsSafeRedirect(const GURL& location) OVERRIDE; | 45 virtual bool IsSafeRedirect(const GURL& location) OVERRIDE; |
| 42 virtual bool GetMimeType(std::string* mime_type) const OVERRIDE; | 46 virtual bool GetMimeType(std::string* mime_type) const OVERRIDE; |
| 43 virtual void GetResponseInfo(HttpResponseInfo* info) OVERRIDE; | 47 virtual void GetResponseInfo(HttpResponseInfo* info) OVERRIDE; |
| 44 virtual HostPortPair GetSocketAddress() const OVERRIDE; | 48 virtual HostPortPair GetSocketAddress() const OVERRIDE; |
| 49 virtual void SetPriority(RequestPriority priority) OVERRIDE; |
| 50 virtual void Start() OVERRIDE; |
| 51 virtual void Kill() OVERRIDE; |
| 52 |
| 53 RequestPriority priority() const { return priority_; } |
| 45 | 54 |
| 46 private: | 55 private: |
| 47 virtual ~URLRequestFtpJob(); | |
| 48 | |
| 49 void OnResolveProxyComplete(int result); | 56 void OnResolveProxyComplete(int result); |
| 50 | 57 |
| 51 void StartFtpTransaction(); | 58 void StartFtpTransaction(); |
| 52 void StartHttpTransaction(); | 59 void StartHttpTransaction(); |
| 53 | 60 |
| 54 void OnStartCompleted(int result); | 61 void OnStartCompleted(int result); |
| 55 void OnStartCompletedAsync(int result); | 62 void OnStartCompletedAsync(int result); |
| 56 void OnReadCompleted(int result); | 63 void OnReadCompleted(int result); |
| 57 | 64 |
| 58 void RestartTransactionWithAuth(); | 65 void RestartTransactionWithAuth(); |
| 59 | 66 |
| 60 void LogFtpServerType(char server_type); | 67 void LogFtpServerType(char server_type); |
| 61 | 68 |
| 62 // Overridden from URLRequestJob: | 69 // Overridden from URLRequestJob: |
| 63 virtual void Start() OVERRIDE; | |
| 64 virtual void Kill() OVERRIDE; | |
| 65 virtual LoadState GetLoadState() const OVERRIDE; | 70 virtual LoadState GetLoadState() const OVERRIDE; |
| 66 virtual bool NeedsAuth() OVERRIDE; | 71 virtual bool NeedsAuth() OVERRIDE; |
| 67 virtual void GetAuthChallengeInfo( | 72 virtual void GetAuthChallengeInfo( |
| 68 scoped_refptr<AuthChallengeInfo>* auth_info) OVERRIDE; | 73 scoped_refptr<AuthChallengeInfo>* auth_info) OVERRIDE; |
| 69 virtual void SetAuth(const AuthCredentials& credentials) OVERRIDE; | 74 virtual void SetAuth(const AuthCredentials& credentials) OVERRIDE; |
| 70 virtual void CancelAuth() OVERRIDE; | 75 virtual void CancelAuth() OVERRIDE; |
| 71 | 76 |
| 72 // TODO(ibrar): Yet to give another look at this function. | 77 // TODO(ibrar): Yet to give another look at this function. |
| 73 virtual UploadProgress GetUploadProgress() const OVERRIDE; | 78 virtual UploadProgress GetUploadProgress() const OVERRIDE; |
| 74 virtual bool ReadRawData(IOBuffer* buf, | 79 virtual bool ReadRawData(IOBuffer* buf, |
| 75 int buf_size, | 80 int buf_size, |
| 76 int *bytes_read) OVERRIDE; | 81 int *bytes_read) OVERRIDE; |
| 77 | 82 |
| 83 RequestPriority priority_; |
| 84 |
| 78 ProxyInfo proxy_info_; | 85 ProxyInfo proxy_info_; |
| 79 ProxyService::PacRequest* pac_request_; | 86 ProxyService::PacRequest* pac_request_; |
| 80 | 87 |
| 81 FtpRequestInfo ftp_request_info_; | 88 FtpRequestInfo ftp_request_info_; |
| 82 scoped_ptr<FtpTransaction> ftp_transaction_; | 89 scoped_ptr<FtpTransaction> ftp_transaction_; |
| 83 | 90 |
| 84 HttpRequestInfo http_request_info_; | 91 HttpRequestInfo http_request_info_; |
| 85 scoped_ptr<HttpTransaction> http_transaction_; | 92 scoped_ptr<HttpTransaction> http_transaction_; |
| 86 const HttpResponseInfo* response_info_; | 93 const HttpResponseInfo* response_info_; |
| 87 | 94 |
| 88 bool read_in_progress_; | 95 bool read_in_progress_; |
| 89 | 96 |
| 90 scoped_refptr<AuthData> server_auth_; | 97 scoped_refptr<AuthData> server_auth_; |
| 91 | 98 |
| 92 base::WeakPtrFactory<URLRequestFtpJob> weak_factory_; | 99 base::WeakPtrFactory<URLRequestFtpJob> weak_factory_; |
| 93 | 100 |
| 94 FtpTransactionFactory* ftp_transaction_factory_; | 101 FtpTransactionFactory* ftp_transaction_factory_; |
| 95 FtpAuthCache* ftp_auth_cache_; | 102 FtpAuthCache* ftp_auth_cache_; |
| 96 | 103 |
| 97 DISALLOW_COPY_AND_ASSIGN(URLRequestFtpJob); | 104 DISALLOW_COPY_AND_ASSIGN(URLRequestFtpJob); |
| 98 }; | 105 }; |
| 99 | 106 |
| 100 } // namespace net | 107 } // namespace net |
| 101 | 108 |
| 102 #endif // NET_URL_REQUEST_URL_REQUEST_FTP_JOB_H_ | 109 #endif // NET_URL_REQUEST_URL_REQUEST_FTP_JOB_H_ |
| OLD | NEW |