OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef NET_HTTP_BIDIRECTIONAL_STREAM_IMPL_H_ | 5 #ifndef NET_HTTP_BIDIRECTIONAL_STREAM_IMPL_H_ |
6 #define NET_HTTP_BIDIRECTIONAL_STREAM_IMPL_H_ | 6 #define NET_HTTP_BIDIRECTIONAL_STREAM_IMPL_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 // operation completes synchronously or asynchronously. | 28 // operation completes synchronously or asynchronously. |
29 // BidirectionalStreamImpl once created by HttpStreamFactoryImpl should be owned | 29 // BidirectionalStreamImpl once created by HttpStreamFactoryImpl should be owned |
30 // by BidirectionalStream. | 30 // by BidirectionalStream. |
31 class NET_EXPORT_PRIVATE BidirectionalStreamImpl { | 31 class NET_EXPORT_PRIVATE BidirectionalStreamImpl { |
32 public: | 32 public: |
33 // Delegate to handle BidirectionalStreamImpl events. | 33 // Delegate to handle BidirectionalStreamImpl events. |
34 class NET_EXPORT_PRIVATE Delegate { | 34 class NET_EXPORT_PRIVATE Delegate { |
35 public: | 35 public: |
36 Delegate(); | 36 Delegate(); |
37 | 37 |
38 // Called when the request headers have been sent. | 38 // Called when the stream is ready for reading and writing. |
39 // The delegate may call BidirectionalStreamImpl::ReadData to start reading, | 39 // The delegate may call BidirectionalStreamImpl::ReadData to start reading, |
40 // call BidirectionalStreamImpl::SendData to send data, | 40 // call BidirectionalStreamImpl::SendData to send data, |
41 // or call BidirectionalStreamImpl::Cancel to cancel the stream. | 41 // or call BidirectionalStreamImpl::Cancel to cancel the stream. |
42 // The delegate should not call BidirectionalStreamImpl::Cancel | 42 // The delegate should not call BidirectionalStreamImpl::Cancel |
43 // during this callback. | 43 // during this callback. |
44 virtual void OnHeadersSent() = 0; | 44 virtual void OnStreamReady() = 0; |
45 | 45 |
46 // Called when response headers are received. | 46 // Called when response headers are received. |
47 // This is called at most once for the lifetime of a stream. | 47 // This is called at most once for the lifetime of a stream. |
48 // The delegate may call BidirectionalStreamImpl::ReadData to start | 48 // The delegate may call BidirectionalStreamImpl::ReadData to start |
49 // reading, call BidirectionalStreamImpl::SendData to send data, | 49 // reading, call BidirectionalStreamImpl::SendData to send data, |
50 // or call BidirectionalStreamImpl::Cancel to cancel the stream. | 50 // or call BidirectionalStreamImpl::Cancel to cancel the stream. |
51 virtual void OnHeadersReceived(const SpdyHeaderBlock& response_headers) = 0; | 51 virtual void OnHeadersReceived(const SpdyHeaderBlock& response_headers) = 0; |
52 | 52 |
53 // Called when read is completed asynchronously. |bytes_read| specifies how | 53 // Called when read is completed asynchronously. |bytes_read| specifies how |
54 // much data is available. | 54 // much data is available. |
(...skipping 28 matching lines...) Expand all Loading... |
83 | 83 |
84 BidirectionalStreamImpl(); | 84 BidirectionalStreamImpl(); |
85 | 85 |
86 // |this| should not be destroyed during Delegate::OnHeadersSent or | 86 // |this| should not be destroyed during Delegate::OnHeadersSent or |
87 // Delegate::OnDataSent. | 87 // Delegate::OnDataSent. |
88 virtual ~BidirectionalStreamImpl(); | 88 virtual ~BidirectionalStreamImpl(); |
89 | 89 |
90 // Starts the BidirectionalStreamImpl and sends request headers. | 90 // Starts the BidirectionalStreamImpl and sends request headers. |
91 virtual void Start(const BidirectionalStreamRequestInfo* request_info, | 91 virtual void Start(const BidirectionalStreamRequestInfo* request_info, |
92 const BoundNetLog& net_log, | 92 const BoundNetLog& net_log, |
| 93 bool disable_auto_flush, |
93 BidirectionalStreamImpl::Delegate* delegate, | 94 BidirectionalStreamImpl::Delegate* delegate, |
94 scoped_ptr<base::Timer> timer) = 0; | 95 scoped_ptr<base::Timer> timer) = 0; |
95 | 96 |
96 // Reads at most |buf_len| bytes into |buf|. Returns the number of bytes read, | 97 // Reads at most |buf_len| bytes into |buf|. Returns the number of bytes read, |
97 // ERR_IO_PENDING if the read is to be completed asynchronously, or an error | 98 // ERR_IO_PENDING if the read is to be completed asynchronously, or an error |
98 // code if any error occurred. If returns 0, there is no more data to read. | 99 // code if any error occurred. If returns 0, there is no more data to read. |
99 // This should not be called before Delegate::OnHeadersReceived is invoked, | 100 // This should not be called before Delegate::OnHeadersReceived is invoked, |
100 // and should not be called again unless it returns with number greater than | 101 // and should not be called again unless it returns with number greater than |
101 // 0 or until Delegate::OnDataRead is invoked. | 102 // 0 or until Delegate::OnDataRead is invoked. |
102 virtual int ReadData(IOBuffer* buf, int buf_len) = 0; | 103 virtual int ReadData(IOBuffer* buf, int buf_len) = 0; |
103 | 104 |
104 // Sends data. This should not be called be called before | 105 // Sends data. This should not be called be called before |
105 // Delegate::OnHeadersSent is invoked, and should not be called again until | 106 // Delegate::OnHeadersSent is invoked, and should not be called again until |
106 // Delegate::OnDataSent is invoked. If |end_stream| is true, the DATA frame | 107 // Delegate::OnDataSent is invoked. If |end_stream| is true, the DATA frame |
107 // will have an END_STREAM flag. | 108 // will have an END_STREAM flag. |
108 virtual void SendData(IOBuffer* data, int length, bool end_stream) = 0; | 109 virtual void SendData(IOBuffer* data, int length, bool end_stream) = 0; |
109 | 110 |
| 111 virtual void SendvData(const std::vector<IOBuffer*>& buffers, |
| 112 const std::vector<int>& lengths, |
| 113 bool end_stream) = 0; |
| 114 |
110 // Cancels the stream. No Delegate method will be called. Any pending | 115 // Cancels the stream. No Delegate method will be called. Any pending |
111 // operations may or may not succeed. | 116 // operations may or may not succeed. |
112 virtual void Cancel() = 0; | 117 virtual void Cancel() = 0; |
113 | 118 |
114 // Returns the protocol used by this stream. If stream has not been | 119 // Returns the protocol used by this stream. If stream has not been |
115 // established, return kProtoUnknown. | 120 // established, return kProtoUnknown. |
116 virtual NextProto GetProtocol() const = 0; | 121 virtual NextProto GetProtocol() const = 0; |
117 | 122 |
118 // Total number of bytes received over the network of SPDY data, headers, and | 123 // Total number of bytes received over the network of SPDY data, headers, and |
119 // push_promise frames associated with this stream, including the size of | 124 // push_promise frames associated with this stream, including the size of |
120 // frame headers, after SSL decryption and not including proxy overhead. | 125 // frame headers, after SSL decryption and not including proxy overhead. |
121 virtual int64_t GetTotalReceivedBytes() const = 0; | 126 virtual int64_t GetTotalReceivedBytes() const = 0; |
122 | 127 |
123 // Total number of bytes sent over the network of SPDY frames associated with | 128 // Total number of bytes sent over the network of SPDY frames associated with |
124 // this stream, including the size of frame headers, before SSL encryption and | 129 // this stream, including the size of frame headers, before SSL encryption and |
125 // not including proxy overhead. Note that some SPDY frames such as pings are | 130 // not including proxy overhead. Note that some SPDY frames such as pings are |
126 // not associated with any stream, and are not included in this value. | 131 // not associated with any stream, and are not included in this value. |
127 virtual int64_t GetTotalSentBytes() const = 0; | 132 virtual int64_t GetTotalSentBytes() const = 0; |
128 | 133 |
129 private: | 134 private: |
130 DISALLOW_COPY_AND_ASSIGN(BidirectionalStreamImpl); | 135 DISALLOW_COPY_AND_ASSIGN(BidirectionalStreamImpl); |
131 }; | 136 }; |
132 | 137 |
133 } // namespace net | 138 } // namespace net |
134 | 139 |
135 #endif // NET_HTTP_BIDIRECTIONAL_STREAM_IMPL_H_ | 140 #endif // NET_HTTP_BIDIRECTIONAL_STREAM_IMPL_H_ |
OLD | NEW |