diff options
author | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-12-17 23:08:24 +0000 |
---|---|---|
committer | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-12-17 23:08:24 +0000 |
commit | 0da3fea3b104b68f0866634e6616c75f60531506 (patch) | |
tree | d3f28342eb1fa354e4adf2e73ff71e8ed272a785 /net/ftp/ftp_transaction.h | |
parent | 4a77babd4294c77b873e205be3a25e9831a98079 (diff) | |
download | chromium_src-0da3fea3b104b68f0866634e6616c75f60531506.zip chromium_src-0da3fea3b104b68f0866634e6616c75f60531506.tar.gz chromium_src-0da3fea3b104b68f0866634e6616c75f60531506.tar.bz2 |
Add beginnings of a custom FTP implementation. This is built but not used or
tested yet. This is just skeleton code.
R=wtc
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@7179 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/ftp/ftp_transaction.h')
-rw-r--r-- | net/ftp/ftp_transaction.h | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/net/ftp/ftp_transaction.h b/net/ftp/ftp_transaction.h new file mode 100644 index 0000000..90fbf25 --- /dev/null +++ b/net/ftp/ftp_transaction.h @@ -0,0 +1,73 @@ +// Copyright (c) 2008 The Chromium Authors. All rights reserved. Use of this +// source code is governed by a BSD-style license that can be found in the +// LICENSE file. + +#ifndef NET_FTP_FTP_TRANSACTION_H_ +#define NET_FTP_FTP_TRANSACTION_H_ + +#include "net/base/completion_callback.h" +#include "net/base/load_states.h" + +namespace net { + +class FtpRequestInfo; +class FtpResponseInfo; + +// Represents a single FTP transaction. +class FtpTransaction { + public: + // Stops any pending IO and destroys the transaction object. + virtual void Destroy() = 0; + + // Starts the FTP transaction (i.e., sends the FTP request). + // + // Returns OK if the transaction could be started synchronously, which means + // that the request was served from the cache (only supported for directory + // listings). ERR_IO_PENDING is returned to indicate that the + // CompletionCallback will be notified once response info is available or if + // an IO error occurs. Any other return value indicates that the transaction + // could not be started. + // + // Regardless of the return value, the caller is expected to keep the + // request_info object alive until Destroy is called on the transaction. + // + // NOTE: The transaction is not responsible for deleting the callback object. + // + virtual int Start(const FtpRequestInfo* request_info, + CompletionCallback* callback) = 0; + + // Restarts the FTP transaction with authentication credentials. + virtual int RestartWithAuth(const std::wstring& username, + const std::wstring& password, + CompletionCallback* callback) = 0; + + // Once response info is available for the transaction, response data may be + // read by calling this method. + // + // Response data is copied into the given buffer and the number of bytes + // copied is returned. ERR_IO_PENDING is returned if response data is not + // yet available. The CompletionCallback is notified when the data copy + // completes, and it is passed the number of bytes that were successfully + // copied. Or, if a read error occurs, the CompletionCallback is notified of + // the error. Any other negative return value indicates that the transaction + // could not be read. + // + // NOTE: The transaction is not responsible for deleting the callback object. + // + virtual int Read(char* buf, int buf_len, CompletionCallback* callback) = 0; + + // Returns the response info for this transaction or NULL if the response + // info is not available. + virtual const FtpResponseInfo* GetResponseInfo() const = 0; + + // Returns the load state for this transaction. + virtual LoadState GetLoadState() const = 0; + + // Returns the upload progress in bytes. If there is no upload data, + // zero will be returned. This does not include the request headers. + virtual uint64 GetUploadProgress() const = 0; +}; + +} // namespace net + +#endif // NET_FTP_FTP_TRANSACTION_H_ |