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

Side by Side Diff: net/spdy/bidirectional_spdy_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: Pass through priority and netlog 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
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_SPDY_BIDIRECTIONAL_SPDY_STREAM_H_
6 #define NET_SPDY_BIDIRECTIONAL_SPDY_STREAM_H_
7
8 #include "base/macros.h"
9 #include "base/memory/weak_ptr.h"
10 #include "net/http/bidirectional_stream.h"
11 #include "net/http/http_request_info.h"
12 #include "net/spdy/spdy_read_queue.h"
13 #include "net/spdy/spdy_session.h"
14 #include "net/spdy/spdy_stream.h"
15
16 namespace net {
17
18 struct HttpRequestInfo;
19 class IOBuffer;
20
21 class NET_EXPORT_PRIVATE BidirectionalSpdyStream : public BidirectionalStream,
22 public SpdyStream::Delegate {
23 public:
24 BidirectionalSpdyStream(const base::WeakPtr<SpdySession>& spdy_session);
25 ~BidirectionalSpdyStream() override;
26
27 // BidirectionalStream implementation:
28
29 void Start(const HttpRequestInfo* request_info,
30 RequestPriority priority,
31 const BoundNetLog& net_log,
32 BidirectionalStream::Delegate* delegate) override;
33
34 int ReadData(IOBuffer* buf, int buf_len) override;
35
36 void SendData(IOBuffer* data, int length, bool end_stream) override;
37
38 // SpdyStream::Delegate implementation:
39
40 void OnRequestHeadersSent() override;
41
42 SpdyResponseHeadersStatus OnResponseHeadersUpdated(
43 const SpdyHeaderBlock& response_headers) override;
44
45 void OnDataReceived(scoped_ptr<SpdyBuffer> buffer) override;
46
47 void OnDataSent() override;
48
49 void OnTrailers(const SpdyHeaderBlock& trailers) override;
50
51 void OnClose(int status) override;
52
53 private:
54 void SendRequestHeaders();
55 void OnStreamInitialized(int rv);
56 void ScheduleBufferedReadCallback();
57 void DoBufferedReadCallback();
58 bool ShouldWaitForMoreBufferedData() const;
59
60 const base::WeakPtr<SpdySession> spdy_session_;
61 bool stream_closed_;
62 int closed_stream_status_;
63 bool buffered_read_callback_pending_;
64 bool more_read_data_pending_;
65
66 const HttpRequestInfo* request_info_;
67 // Buffers the data as it arrives asynchronously from the stream.
68 SpdyReadQueue data_queue_;
69 // User provided buffer for ReadData() response.
70 scoped_refptr<IOBuffer> user_buffer_;
71 int user_buffer_len_;
72
73 BidirectionalStream::Delegate* delegate_;
74 SpdyStreamRequest stream_request_;
75 base::WeakPtr<SpdyStream> stream_;
76
77 base::WeakPtrFactory<BidirectionalSpdyStream> weak_factory_;
78
79 DISALLOW_COPY_AND_ASSIGN(BidirectionalSpdyStream);
80 };
81
82 } // namespace net
83
84 #endif // NET_SPDY_BIDIRECTIONAL_SPDY_STREAM_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698