summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authormbelshe@google.com <mbelshe@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-28 20:12:36 +0000
committermbelshe@google.com <mbelshe@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-28 20:12:36 +0000
commit2329792307deebd09cf0b79bda7dfeffae61c715 (patch)
tree3999b9ad139989f6d4c257bda6db552fc349b450 /net
parent7da7f343ce147cb2fd628fa0dd3ab7cd281efc06 (diff)
downloadchromium_src-2329792307deebd09cf0b79bda7dfeffae61c715.zip
chromium_src-2329792307deebd09cf0b79bda7dfeffae61c715.tar.gz
chromium_src-2329792307deebd09cf0b79bda7dfeffae61c715.tar.bz2
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
Diffstat (limited to 'net')
-rw-r--r--net/flip/flip_network_transaction.cc14
-rw-r--r--net/flip/flip_network_transaction.h2
-rw-r--r--net/flip/flip_session.cc2
-rw-r--r--net/flip/flip_session.h47
4 files changed, 50 insertions, 15 deletions
diff --git a/net/flip/flip_network_transaction.cc b/net/flip/flip_network_transaction.cc
index 3061b36..77059fa 100644
--- a/net/flip/flip_network_transaction.cc
+++ b/net/flip/flip_network_transaction.cc
@@ -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) {
diff --git a/net/flip/flip_network_transaction.h b/net/flip/flip_network_transaction.h
index f4b0292..e228d37 100644
--- a/net/flip/flip_network_transaction.h
+++ b/net/flip/flip_network_transaction.h
@@ -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,
diff --git a/net/flip/flip_session.cc b/net/flip/flip_session.cc
index 7305103..70a4abe 100644
--- a/net/flip/flip_session.cc
+++ b/net/flip/flip_session.cc
@@ -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.
diff --git a/net/flip/flip_session.h b/net/flip/flip_session.h
index 81ec364..1030c01 100644
--- a/net/flip/flip_session.h
+++ b/net/flip/flip_session.h
@@ -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 {