Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(617)

Unified Diff: net/http/bidirectional_stream.h

Issue 1326503003: Added a net::BidirectionalStream to expose a bidirectional streaming interface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | net/http/bidirectional_stream.cc » ('j') | net/http/bidirectional_stream.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/bidirectional_stream.h
diff --git a/net/http/bidirectional_stream.h b/net/http/bidirectional_stream.h
new file mode 100644
index 0000000000000000000000000000000000000000..bf8a028699db66183dfb3c47ef68a347abac1192
--- /dev/null
+++ b/net/http/bidirectional_stream.h
@@ -0,0 +1,95 @@
+// Copyright 2015 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_HTTP_BIDIRECTIONAL_STREAM_H_
+#define NET_HTTP_BIDIRECTIONAL_STREAM_H_
+
+#include "base/memory/weak_ptr.h"
+#include "net/http/http_request_info.h"
+#include "net/spdy/spdy_session.h"
+#include "net/spdy/spdy_stream.h"
+
+namespace net {
+
+struct HttpRequestInfo;
+class IOBuffer;
+
+class BidirectionalStream : public SpdyStream::Delegate {
mef 2015/09/30 16:18:16 I think BidirectionalStream should be an abstract
xunjieli 2015/10/01 18:41:16 Done.
+ public:
+ // Delegate to handle BidirectionalStream events.
+ class Delegate {
+ public:
+ Delegate() {}
+ // Called when an error occurs. E.g. when an connection to the server cannot
+ // be established.
+ virtual void OnFailed(int error) = 0;
+
+ // Called when the request headers have been sent.
+ virtual void OnRequestHeadersSent() = 0;
+
+ // Called when response headers are received.
+ virtual void OnHeaders(const SpdyHeaderBlock& response_headers) = 0;
+
+ // Called when data is received.
+ virtual void OnDataReceived(scoped_ptr<SpdyBuffer> buffer) = 0;
mef 2015/09/30 16:18:16 I think it should be similar to onReadCompleted, c
xunjieli 2015/10/01 18:41:16 Done.
+
+ // Called when data is sent.
+ virtual void OnDataSent() = 0;
+
+ // Called when trailers are received.
+ virtual void OnTrailers(const SpdyHeaderBlock& trailers) = 0;
+
+ // Called when the stream is closed. No other delegate functions will be
+ // called after this.
+ virtual void OnClose(int status) = 0;
+
+ protected:
+ virtual ~Delegate() {}
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(Delegate);
+ };
+
+ BidirectionalStream(const base::WeakPtr<SpdySession>& spdy_session);
+ ~BidirectionalStream() override;
+
+ // Starts the BidirectionalStream and sends request headers.
+ void Start(const HttpRequestInfo* request_info, Delegate* delegate);
+
+ // Sends data.
mef 2015/09/30 16:18:16 I think it needs 'ReadData' counterpart, which in
xunjieli 2015/10/01 18:41:16 Done.
+ void SendData(IOBuffer* data, int length, bool end_stream);
+
+ // SpdyStream::Delegate implementation:
+
+ void OnRequestHeadersSent() override;
+
+ SpdyResponseHeadersStatus OnResponseHeadersUpdated(
+ const SpdyHeaderBlock& response_headers) override;
+
+ void OnDataReceived(scoped_ptr<SpdyBuffer> buffer) override;
+
+ void OnDataSent() override;
+
+ void OnTrailers(const SpdyHeaderBlock& trailers) override;
+
+ void OnClose(int status) override;
+
+ private:
+ void SendRequestHeaders();
+ void OnStreamInitialized(int rv);
+
+ const base::WeakPtr<SpdySession> spdy_session_;
+ const HttpRequestInfo* request_info_;
+ Delegate* delegate_;
+ SpdyStreamRequest stream_request_;
+ base::WeakPtr<SpdyStream> stream_;
+
+ base::WeakPtrFactory<BidirectionalStream> weak_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(BidirectionalStream);
+};
+
+} // namespace net
+
+#endif // NET_HTTP_BIDIRECTIONAL_STREAM_H_
« no previous file with comments | « no previous file | net/http/bidirectional_stream.cc » ('j') | net/http/bidirectional_stream.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698