OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef NET_FTP_FTP_TRANSACTION_H_ | |
6 #define NET_FTP_FTP_TRANSACTION_H_ | |
7 | |
8 #include "net/base/completion_callback.h" | |
9 #include "net/base/io_buffer.h" | |
10 #include "net/base/load_states.h" | |
11 #include "net/base/net_export.h" | |
12 | |
13 namespace net { | |
14 | |
15 class AuthCredentials; | |
16 class FtpResponseInfo; | |
17 class FtpRequestInfo; | |
18 class BoundNetLog; | |
19 | |
20 // Represents a single FTP transaction. | |
21 class NET_EXPORT_PRIVATE FtpTransaction { | |
22 public: | |
23 // Stops any pending IO and destroys the transaction object. | |
24 virtual ~FtpTransaction() {} | |
25 | |
26 // Starts the FTP transaction (i.e., sends the FTP request). | |
27 // | |
28 // Returns OK if the transaction could be started synchronously, which means | |
29 // that the request was served from the cache (only supported for directory | |
30 // listings). ERR_IO_PENDING is returned to indicate that the | |
31 // CompletionCallback will be notified once response info is available or if | |
32 // an IO error occurs. Any other return value indicates that the transaction | |
33 // could not be started. | |
34 // | |
35 // Regardless of the return value, the caller is expected to keep the | |
36 // request_info object alive until Destroy is called on the transaction. | |
37 // | |
38 // NOTE: The transaction is not responsible for deleting the callback object. | |
39 // | |
40 // Profiling information for the request is saved to |net_log| if non-NULL. | |
41 virtual int Start(const FtpRequestInfo* request_info, | |
42 const CompletionCallback& callback, | |
43 const BoundNetLog& net_log) = 0; | |
44 | |
45 // Restarts the FTP transaction with authentication credentials. | |
46 virtual int RestartWithAuth(const AuthCredentials& credentials, | |
47 const CompletionCallback& callback) = 0; | |
48 | |
49 // Once response info is available for the transaction, response data may be | |
50 // read by calling this method. | |
51 // | |
52 // Response data is copied into the given buffer and the number of bytes | |
53 // copied is returned. ERR_IO_PENDING is returned if response data is not | |
54 // yet available. The CompletionCallback is notified when the data copy | |
55 // completes, and it is passed the number of bytes that were successfully | |
56 // copied. Or, if a read error occurs, the CompletionCallback is notified of | |
57 // the error. Any other negative return value indicates that the transaction | |
58 // could not be read. | |
59 // | |
60 // NOTE: The transaction is not responsible for deleting the callback object. | |
61 // | |
62 virtual int Read(IOBuffer* buf, | |
63 int buf_len, | |
64 const CompletionCallback& callback) = 0; | |
65 | |
66 // Returns the response info for this transaction or NULL if the response | |
67 // info is not available. | |
68 virtual const FtpResponseInfo* GetResponseInfo() const = 0; | |
69 | |
70 // Returns the load state for this transaction. | |
71 virtual LoadState GetLoadState() const = 0; | |
72 | |
73 // Returns the upload progress in bytes. If there is no upload data, | |
74 // zero will be returned. | |
75 virtual uint64 GetUploadProgress() const = 0; | |
76 }; | |
77 | |
78 } // namespace net | |
79 | |
80 #endif // NET_FTP_FTP_TRANSACTION_H_ | |
OLD | NEW |