OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/string16.h" | 11 #include "base/string16.h" |
12 #include "base/task.h" | 12 #include "base/task.h" |
13 #include "net/base/auth.h" | 13 #include "net/base/auth.h" |
14 #include "net/base/completion_callback.h" | 14 #include "net/base/completion_callback.h" |
15 #include "net/ftp/ftp_request_info.h" | 15 #include "net/ftp/ftp_request_info.h" |
16 #include "net/ftp/ftp_transaction.h" | 16 #include "net/ftp/ftp_transaction.h" |
17 #include "net/url_request/url_request_job.h" | 17 #include "net/url_request/url_request_job.h" |
18 | 18 |
19 namespace net { | 19 namespace net { |
20 | 20 |
21 class URLRequestContext; | 21 class URLRequestContext; |
22 | 22 |
23 // A URLRequestJob subclass that is built on top of FtpTransaction. It | 23 // A URLRequestJob subclass that is built on top of FtpTransaction. It |
24 // provides an implementation for FTP. | 24 // provides an implementation for FTP. |
25 class URLRequestFtpJob : public URLRequestJob { | 25 class URLRequestFtpJob : public URLRequestJob { |
26 public: | 26 public: |
27 | |
28 explicit URLRequestFtpJob(URLRequest* request); | 27 explicit URLRequestFtpJob(URLRequest* request); |
29 | 28 |
30 static URLRequestJob* Factory(URLRequest* request, | 29 static URLRequestJob* Factory(URLRequest* request, |
31 const std::string& scheme); | 30 const std::string& scheme); |
32 | 31 |
33 // Overridden from URLRequestJob: | 32 // Overridden from URLRequestJob: |
34 virtual bool GetMimeType(std::string* mime_type) const; | 33 virtual bool GetMimeType(std::string* mime_type) const; |
35 | 34 |
36 private: | 35 private: |
37 virtual ~URLRequestFtpJob(); | 36 virtual ~URLRequestFtpJob(); |
38 | 37 |
| 38 void StartTransaction(); |
| 39 |
| 40 void OnStartCompleted(int result); |
| 41 void OnReadCompleted(int result); |
| 42 |
| 43 void RestartTransactionWithAuth(); |
| 44 |
| 45 void LogFtpServerType(char server_type); |
| 46 |
39 // Overridden from URLRequestJob: | 47 // Overridden from URLRequestJob: |
40 virtual void Start(); | 48 virtual void Start(); |
41 virtual void Kill(); | 49 virtual void Kill(); |
42 virtual LoadState GetLoadState() const; | 50 virtual LoadState GetLoadState() const; |
43 virtual bool NeedsAuth(); | 51 virtual bool NeedsAuth(); |
44 virtual void GetAuthChallengeInfo( | 52 virtual void GetAuthChallengeInfo( |
45 scoped_refptr<AuthChallengeInfo>* auth_info); | 53 scoped_refptr<AuthChallengeInfo>* auth_info); |
46 virtual void SetAuth(const string16& username, | 54 virtual void SetAuth(const string16& username, |
47 const string16& password); | 55 const string16& password); |
48 virtual void CancelAuth(); | 56 virtual void CancelAuth(); |
49 | 57 |
50 // TODO(ibrar): Yet to give another look at this function. | 58 // TODO(ibrar): Yet to give another look at this function. |
51 virtual uint64 GetUploadProgress() const; | 59 virtual uint64 GetUploadProgress() const; |
52 virtual bool ReadRawData(IOBuffer* buf, int buf_size, int *bytes_read); | 60 virtual bool ReadRawData(IOBuffer* buf, int buf_size, int *bytes_read); |
53 | 61 |
54 void StartTransaction(); | |
55 | |
56 void OnStartCompleted(int result); | |
57 void OnReadCompleted(int result); | |
58 | |
59 void RestartTransactionWithAuth(); | |
60 | |
61 void LogFtpServerType(char server_type); | |
62 | |
63 FtpRequestInfo request_info_; | 62 FtpRequestInfo request_info_; |
64 scoped_ptr<FtpTransaction> transaction_; | 63 scoped_ptr<FtpTransaction> transaction_; |
65 | 64 |
66 CompletionCallbackImpl<URLRequestFtpJob> start_callback_; | 65 CompletionCallbackImpl<URLRequestFtpJob> start_callback_; |
67 CompletionCallbackImpl<URLRequestFtpJob> read_callback_; | 66 CompletionCallbackImpl<URLRequestFtpJob> read_callback_; |
68 | 67 |
69 bool read_in_progress_; | 68 bool read_in_progress_; |
70 | 69 |
71 scoped_refptr<AuthData> server_auth_; | 70 scoped_refptr<AuthData> server_auth_; |
72 | 71 |
73 // Keep a reference to the url request context to be sure it's not deleted | 72 // Keep a reference to the url request context to be sure it's not deleted |
74 // before us. | 73 // before us. |
75 scoped_refptr<URLRequestContext> context_; | 74 scoped_refptr<URLRequestContext> context_; |
76 | 75 |
77 ScopedRunnableMethodFactory<URLRequestFtpJob> method_factory_; | 76 ScopedRunnableMethodFactory<URLRequestFtpJob> method_factory_; |
78 | 77 |
79 DISALLOW_COPY_AND_ASSIGN(URLRequestFtpJob); | 78 DISALLOW_COPY_AND_ASSIGN(URLRequestFtpJob); |
80 }; | 79 }; |
81 | 80 |
82 } // namespace net | 81 } // namespace net |
83 | 82 |
84 #endif // NET_URL_REQUEST_URL_REQUEST_FTP_JOB_H_ | 83 #endif // NET_URL_REQUEST_URL_REQUEST_FTP_JOB_H_ |
OLD | NEW |