Commit 23297923 authored by mbelshe@google.com's avatar mbelshe@google.com

Cleanup the FlipDelegate API a bit in prep for fixing upload.

Document the API for FlipDelegate in flip_session.h.
Remove the method OnCancel, since it was not needed.
Add the method OnBodySent, which is not yet used but will
be.

FlipNetworkTransaction is a FlipDelegate, so the changes
there are just to reflect the new API.

BUG=none
TEST=none
Review URL: http://codereview.chromium.org/339047

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@30380 0039d316-1c4b-4281-b951-d872f2087c98
parent 7da7f343
......@@ -68,6 +68,10 @@ void FlipNetworkTransaction::OnRequestSent(int status) {
DoLoop(status);
}
void FlipNetworkTransaction::OnUploadDataSent(int result) {
NOTIMPLEMENTED();
}
void FlipNetworkTransaction::OnResponseReceived(HttpResponseInfo* response) {
next_state_ = STATE_READ_HEADERS_COMPLETE;
......@@ -104,16 +108,6 @@ void FlipNetworkTransaction::OnClose(int status) {
DoLoop(status);
}
void FlipNetworkTransaction::OnCancel() {
next_state_ = STATE_NONE;
response_complete_ = true;
response_status_ = net::ERR_ABORTED;
flip_request_id_ = 0; // TODO(mbelshe) - do we need this?
// Clear any data in our buffer.
while (response_body_.size())
response_body_.pop_front();
}
int FlipNetworkTransaction::Start(const HttpRequestInfo* request_info,
CompletionCallback* callback,
LoadLog* load_log) {
......
......@@ -44,10 +44,10 @@ class FlipNetworkTransaction : public HttpTransaction, public FlipDelegate {
virtual const HttpRequestInfo* request();
virtual const UploadDataStream* data();
virtual void OnRequestSent(int status);
virtual void OnUploadDataSent(int result);
virtual void OnResponseReceived(HttpResponseInfo* response);
virtual void OnDataReceived(const char* buffer, int bytes);
virtual void OnClose(int status);
virtual void OnCancel();
// HttpTransaction methods:
virtual int Start(const HttpRequestInfo* request_info,
......
......@@ -271,7 +271,7 @@ int FlipSession::CreateStream(FlipDelegate* delegate) {
CreateFlipHeadersFromHttpRequest(delegate->request(), &headers);
flip::FlipControlFlags flags = flip::CONTROL_FLAG_NONE;
if (!delegate->request()->upload_data)
if (!delegate->data())
flags = flip::CONTROL_FLAG_FIN;
// Create a SYN_STREAM packet and add to the output queue.
......
......@@ -31,18 +31,59 @@ class HttpNetworkSession;
class HttpRequestInfo;
class HttpResponseInfo;
// A callback interface for HTTP content retrieved from the Flip stream.
// The FlipDelegate interface is an interface so that the FlipSession
// can interact with the provider of a given Flip stream.
class FlipDelegate {
public:
virtual ~FlipDelegate() {}
// Accessors from the delegate.
// The delegate provides access to the HttpRequestInfo for use by the flip
// session.
virtual const HttpRequestInfo* request() = 0;
// The delegate provides access to an UploadDataStream for use by the
// flip session. If the delegate is not uploading content, this call
// must return NULL.
virtual const UploadDataStream* data() = 0;
virtual void OnRequestSent(int status) = 0;
// Callbacks.
// Called by the FlipSession when UploadData has been sent. If the
// request has no upload data, this call will never be called. This
// callback may be called multiple times if large amounts of data are
// being uploaded. This callback will only be called prior to the
// OnRequestSent callback.
// |result| contains the number of bytes written or an error code.
virtual void OnUploadDataSent(int result) = 0;
// Called by the FlipSession when the Request has been entirely sent.
// If the request contains upload data, all upload data has been sent.
// |result| contains an error code if a failure has occurred or OK
// on success.
virtual void OnRequestSent(int result) = 0;
// Called by the FlipSession when a response (e.g. a SYN_REPLY) has been
// received for this request. This callback will never be called prior
// to the OnRequestSent() callback.
virtual void OnResponseReceived(HttpResponseInfo* response) = 0;
// Called by the FlipSession when response data has been received for this
// request. This callback may be called multiple times as data arrives
// from the network, and will never be called prior to OnResponseReceived.
// |buffer| contains the data received. The delegate must copy any data
// from this buffer before returning from this callback.
// |bytes| is the number of bytes received or an error.
// A zero-length count does not indicate end-of-stream.
virtual void OnDataReceived(const char* buffer, int bytes) = 0;
// Called by the FlipSession when the request is finished. This callback
// will always be called at the end of the request and signals to the
// delegate that the delegate can be torn down. No further callbacks to the
// delegate will be made after this call.
// |status| is an error code or OK.
virtual void OnClose(int status) = 0;
virtual void OnCancel() = 0;
};
class PrioritizedIOBuffer {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment