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

Side by Side 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, 2 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 unified diff | Download patch
« no previous file with comments | « no previous file | net/http/bidirectional_stream.cc » ('j') | net/http/bidirectional_stream.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2015 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_HTTP_BIDIRECTIONAL_STREAM_H_
6 #define NET_HTTP_BIDIRECTIONAL_STREAM_H_
7
8 #include "base/memory/weak_ptr.h"
9 #include "net/http/http_request_info.h"
10 #include "net/spdy/spdy_session.h"
11 #include "net/spdy/spdy_stream.h"
12
13 namespace net {
14
15 struct HttpRequestInfo;
16 class IOBuffer;
17
18 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.
19 public:
20 // Delegate to handle BidirectionalStream events.
21 class Delegate {
22 public:
23 Delegate() {}
24 // Called when an error occurs. E.g. when an connection to the server cannot
25 // be established.
26 virtual void OnFailed(int error) = 0;
27
28 // Called when the request headers have been sent.
29 virtual void OnRequestHeadersSent() = 0;
30
31 // Called when response headers are received.
32 virtual void OnHeaders(const SpdyHeaderBlock& response_headers) = 0;
33
34 // Called when data is received.
35 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.
36
37 // Called when data is sent.
38 virtual void OnDataSent() = 0;
39
40 // Called when trailers are received.
41 virtual void OnTrailers(const SpdyHeaderBlock& trailers) = 0;
42
43 // Called when the stream is closed. No other delegate functions will be
44 // called after this.
45 virtual void OnClose(int status) = 0;
46
47 protected:
48 virtual ~Delegate() {}
49
50 private:
51 DISALLOW_COPY_AND_ASSIGN(Delegate);
52 };
53
54 BidirectionalStream(const base::WeakPtr<SpdySession>& spdy_session);
55 ~BidirectionalStream() override;
56
57 // Starts the BidirectionalStream and sends request headers.
58 void Start(const HttpRequestInfo* request_info, Delegate* delegate);
59
60 // 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.
61 void SendData(IOBuffer* data, int length, bool end_stream);
62
63 // SpdyStream::Delegate implementation:
64
65 void OnRequestHeadersSent() override;
66
67 SpdyResponseHeadersStatus OnResponseHeadersUpdated(
68 const SpdyHeaderBlock& response_headers) override;
69
70 void OnDataReceived(scoped_ptr<SpdyBuffer> buffer) override;
71
72 void OnDataSent() override;
73
74 void OnTrailers(const SpdyHeaderBlock& trailers) override;
75
76 void OnClose(int status) override;
77
78 private:
79 void SendRequestHeaders();
80 void OnStreamInitialized(int rv);
81
82 const base::WeakPtr<SpdySession> spdy_session_;
83 const HttpRequestInfo* request_info_;
84 Delegate* delegate_;
85 SpdyStreamRequest stream_request_;
86 base::WeakPtr<SpdyStream> stream_;
87
88 base::WeakPtrFactory<BidirectionalStream> weak_factory_;
89
90 DISALLOW_COPY_AND_ASSIGN(BidirectionalStream);
91 };
92
93 } // namespace net
94
95 #endif // NET_HTTP_BIDIRECTIONAL_STREAM_H_
OLDNEW
« 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