OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_FTP_FTP_NETWORK_TRANSACTION_H_ | 5 #ifndef NET_FTP_FTP_NETWORK_TRANSACTION_H_ |
6 #define NET_FTP_FTP_NETWORK_TRANSACTION_H_ | 6 #define NET_FTP_FTP_NETWORK_TRANSACTION_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
(...skipping 13 matching lines...) Expand all Loading... |
24 class ClientSocket; | 24 class ClientSocket; |
25 class ClientSocketFactory; | 25 class ClientSocketFactory; |
26 class FtpNetworkSession; | 26 class FtpNetworkSession; |
27 | 27 |
28 class FtpNetworkTransaction : public FtpTransaction { | 28 class FtpNetworkTransaction : public FtpTransaction { |
29 public: | 29 public: |
30 FtpNetworkTransaction(FtpNetworkSession* session, | 30 FtpNetworkTransaction(FtpNetworkSession* session, |
31 ClientSocketFactory* socket_factory); | 31 ClientSocketFactory* socket_factory); |
32 virtual ~FtpNetworkTransaction(); | 32 virtual ~FtpNetworkTransaction(); |
33 | 33 |
| 34 virtual int Stop(int error); |
| 35 virtual int RestartIgnoringLastError(CompletionCallback* callback); |
| 36 |
34 // FtpTransaction methods: | 37 // FtpTransaction methods: |
35 virtual int Start(const FtpRequestInfo* request_info, | 38 virtual int Start(const FtpRequestInfo* request_info, |
36 CompletionCallback* callback, | 39 CompletionCallback* callback, |
37 const BoundNetLog& net_log); | 40 const BoundNetLog& net_log); |
38 virtual int Stop(int error); | |
39 virtual int RestartWithAuth(const string16& username, | 41 virtual int RestartWithAuth(const string16& username, |
40 const string16& password, | 42 const string16& password, |
41 CompletionCallback* callback); | 43 CompletionCallback* callback); |
42 virtual int RestartIgnoringLastError(CompletionCallback* callback); | |
43 virtual int Read(IOBuffer* buf, int buf_len, CompletionCallback* callback); | 44 virtual int Read(IOBuffer* buf, int buf_len, CompletionCallback* callback); |
44 virtual const FtpResponseInfo* GetResponseInfo() const; | 45 virtual const FtpResponseInfo* GetResponseInfo() const; |
45 virtual LoadState GetLoadState() const; | 46 virtual LoadState GetLoadState() const; |
46 virtual uint64 GetUploadProgress() const; | 47 virtual uint64 GetUploadProgress() const; |
47 | 48 |
48 private: | 49 private: |
49 enum Command { | 50 enum Command { |
50 COMMAND_NONE, | 51 COMMAND_NONE, |
51 COMMAND_USER, | 52 COMMAND_USER, |
52 COMMAND_PASS, | 53 COMMAND_PASS, |
(...skipping 27 matching lines...) Expand all Loading... |
80 | 81 |
81 // In FTP we need to issue different commands depending on whether a resource | 82 // In FTP we need to issue different commands depending on whether a resource |
82 // is a file or directory. If we don't know that, we're going to autodetect | 83 // is a file or directory. If we don't know that, we're going to autodetect |
83 // it. | 84 // it. |
84 enum ResourceType { | 85 enum ResourceType { |
85 RESOURCE_TYPE_UNKNOWN, | 86 RESOURCE_TYPE_UNKNOWN, |
86 RESOURCE_TYPE_FILE, | 87 RESOURCE_TYPE_FILE, |
87 RESOURCE_TYPE_DIRECTORY, | 88 RESOURCE_TYPE_DIRECTORY, |
88 }; | 89 }; |
89 | 90 |
| 91 enum State { |
| 92 // Control connection states: |
| 93 STATE_CTRL_RESOLVE_HOST, |
| 94 STATE_CTRL_RESOLVE_HOST_COMPLETE, |
| 95 STATE_CTRL_CONNECT, |
| 96 STATE_CTRL_CONNECT_COMPLETE, |
| 97 STATE_CTRL_READ, |
| 98 STATE_CTRL_READ_COMPLETE, |
| 99 STATE_CTRL_WRITE, |
| 100 STATE_CTRL_WRITE_COMPLETE, |
| 101 STATE_CTRL_WRITE_USER, |
| 102 STATE_CTRL_WRITE_PASS, |
| 103 STATE_CTRL_WRITE_SYST, |
| 104 STATE_CTRL_WRITE_TYPE, |
| 105 STATE_CTRL_WRITE_EPSV, |
| 106 STATE_CTRL_WRITE_PASV, |
| 107 STATE_CTRL_WRITE_PWD, |
| 108 STATE_CTRL_WRITE_RETR, |
| 109 STATE_CTRL_WRITE_SIZE, |
| 110 STATE_CTRL_WRITE_CWD, |
| 111 STATE_CTRL_WRITE_LIST, |
| 112 STATE_CTRL_WRITE_QUIT, |
| 113 // Data connection states: |
| 114 STATE_DATA_CONNECT, |
| 115 STATE_DATA_CONNECT_COMPLETE, |
| 116 STATE_DATA_READ, |
| 117 STATE_DATA_READ_COMPLETE, |
| 118 STATE_NONE |
| 119 }; |
| 120 |
90 // Resets the members of the transaction so it can be restarted. | 121 // Resets the members of the transaction so it can be restarted. |
91 void ResetStateForRestart(); | 122 void ResetStateForRestart(); |
92 | 123 |
93 void DoCallback(int result); | 124 void DoCallback(int result); |
94 void OnIOComplete(int result); | 125 void OnIOComplete(int result); |
95 | 126 |
96 // Executes correct ProcessResponse + command_name function based on last | 127 // Executes correct ProcessResponse + command_name function based on last |
97 // issued command. Returns error code. | 128 // issued command. Returns error code. |
98 int ProcessCtrlResponse(); | 129 int ProcessCtrlResponse(); |
99 | 130 |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 // with any trailing slash removed. | 235 // with any trailing slash removed. |
205 std::string current_remote_directory_; | 236 std::string current_remote_directory_; |
206 | 237 |
207 int data_connection_port_; | 238 int data_connection_port_; |
208 | 239 |
209 ClientSocketFactory* socket_factory_; | 240 ClientSocketFactory* socket_factory_; |
210 | 241 |
211 scoped_ptr<ClientSocket> ctrl_socket_; | 242 scoped_ptr<ClientSocket> ctrl_socket_; |
212 scoped_ptr<ClientSocket> data_socket_; | 243 scoped_ptr<ClientSocket> data_socket_; |
213 | 244 |
214 enum State { | |
215 // Control connection states: | |
216 STATE_CTRL_RESOLVE_HOST, | |
217 STATE_CTRL_RESOLVE_HOST_COMPLETE, | |
218 STATE_CTRL_CONNECT, | |
219 STATE_CTRL_CONNECT_COMPLETE, | |
220 STATE_CTRL_READ, | |
221 STATE_CTRL_READ_COMPLETE, | |
222 STATE_CTRL_WRITE, | |
223 STATE_CTRL_WRITE_COMPLETE, | |
224 STATE_CTRL_WRITE_USER, | |
225 STATE_CTRL_WRITE_PASS, | |
226 STATE_CTRL_WRITE_SYST, | |
227 STATE_CTRL_WRITE_TYPE, | |
228 STATE_CTRL_WRITE_EPSV, | |
229 STATE_CTRL_WRITE_PASV, | |
230 STATE_CTRL_WRITE_PWD, | |
231 STATE_CTRL_WRITE_RETR, | |
232 STATE_CTRL_WRITE_SIZE, | |
233 STATE_CTRL_WRITE_CWD, | |
234 STATE_CTRL_WRITE_LIST, | |
235 STATE_CTRL_WRITE_QUIT, | |
236 // Data connection states: | |
237 STATE_DATA_CONNECT, | |
238 STATE_DATA_CONNECT_COMPLETE, | |
239 STATE_DATA_READ, | |
240 STATE_DATA_READ_COMPLETE, | |
241 STATE_NONE | |
242 }; | |
243 State next_state_; | 245 State next_state_; |
244 }; | 246 }; |
245 | 247 |
246 } // namespace net | 248 } // namespace net |
247 | 249 |
248 #endif // NET_FTP_FTP_NETWORK_TRANSACTION_H_ | 250 #endif // NET_FTP_FTP_NETWORK_TRANSACTION_H_ |
OLD | NEW |