OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_SPDY_SPDY_STREAM_H_ | 5 #ifndef NET_SPDY_SPDY_STREAM_H_ |
6 #define NET_SPDY_SPDY_STREAM_H_ | 6 #define NET_SPDY_SPDY_STREAM_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 | 102 |
103 const BoundNetLog& net_log() const { return net_log_; } | 103 const BoundNetLog& net_log() const { return net_log_; } |
104 void set_net_log(const BoundNetLog& log) { net_log_ = log; } | 104 void set_net_log(const BoundNetLog& log) { net_log_ = log; } |
105 | 105 |
106 const linked_ptr<spdy::SpdyHeaderBlock>& spdy_headers() const; | 106 const linked_ptr<spdy::SpdyHeaderBlock>& spdy_headers() const; |
107 void set_spdy_headers(const linked_ptr<spdy::SpdyHeaderBlock>& headers); | 107 void set_spdy_headers(const linked_ptr<spdy::SpdyHeaderBlock>& headers); |
108 base::Time GetRequestTime() const; | 108 base::Time GetRequestTime() const; |
109 void SetRequestTime(base::Time t); | 109 void SetRequestTime(base::Time t); |
110 | 110 |
111 // Called by the SpdySession when a response (e.g. a SYN_REPLY) has been | 111 // Called by the SpdySession when a response (e.g. a SYN_REPLY) has been |
112 // received for this stream. | 112 // received for this stream. |path| is the path of the URL for a server |
| 113 // initiated stream, otherwise is empty. |
113 // Returns a status code. | 114 // Returns a status code. |
114 int OnResponseReceived(const spdy::SpdyHeaderBlock& response); | 115 int OnResponseReceived(const spdy::SpdyHeaderBlock& response); |
115 | 116 |
116 // Called by the SpdySession when response data has been received for this | 117 // Called by the SpdySession when response data has been received for this |
117 // stream. This callback may be called multiple times as data arrives | 118 // stream. This callback may be called multiple times as data arrives |
118 // from the network, and will never be called prior to OnResponseReceived. | 119 // from the network, and will never be called prior to OnResponseReceived. |
119 // |buffer| contains the data received. The stream must copy any data | 120 // |buffer| contains the data received. The stream must copy any data |
120 // from this buffer before returning from this callback. | 121 // from this buffer before returning from this callback. |
121 // |length| is the number of bytes received or an error. | 122 // |length| is the number of bytes received or an error. |
122 // A length of zero indicates end-of-stream. | 123 // A zero-length count does not indicate end-of-stream. |
123 void OnDataReceived(const char* buffer, int bytes); | 124 void OnDataReceived(const char* buffer, int bytes); |
124 | 125 |
125 // Called by the SpdySession when a write has completed. This callback | 126 // Called by the SpdySession when a write has completed. This callback |
126 // will be called multiple times for each write which completes. Writes | 127 // will be called multiple times for each write which completes. Writes |
127 // include the SYN_STREAM write and also DATA frame writes. | 128 // include the SYN_STREAM write and also DATA frame writes. |
128 // |result| is the number of bytes written or a net error code. | 129 // |result| is the number of bytes written or a net error code. |
129 void OnWriteComplete(int status); | 130 void OnWriteComplete(int status); |
130 | 131 |
131 // Called by the SpdySession when the request is finished. This callback | 132 // Called by the SpdySession when the request is finished. This callback |
132 // will always be called at the end of the request and signals to the | 133 // will always be called at the end of the request and signals to the |
(...skipping 19 matching lines...) Expand all Loading... |
152 | 153 |
153 // Sends DATA frame. | 154 // Sends DATA frame. |
154 int WriteStreamData(IOBuffer* data, int length); | 155 int WriteStreamData(IOBuffer* data, int length); |
155 | 156 |
156 bool GetSSLInfo(SSLInfo* ssl_info, bool* was_npn_negotiated); | 157 bool GetSSLInfo(SSLInfo* ssl_info, bool* was_npn_negotiated); |
157 | 158 |
158 bool is_idle() const { return io_state_ == STATE_NONE; } | 159 bool is_idle() const { return io_state_ == STATE_NONE; } |
159 bool response_complete() const { return response_complete_; } | 160 bool response_complete() const { return response_complete_; } |
160 int response_status() const { return response_status_; } | 161 int response_status() const { return response_status_; } |
161 | 162 |
162 // If this function returns true, then the spdy_session is guaranteeing that | |
163 // this spdy_stream has been removed from active_streams. | |
164 bool half_closed_client_side() const { return half_closed_client_side_; } | |
165 | |
166 bool half_closed_server_side() const { return half_closed_server_side_; } | |
167 bool half_closed_both_sides() const { | |
168 return half_closed_client_side_ && half_closed_server_side_; | |
169 } | |
170 | |
171 // These two functions should only ever be called by spdy_session, and should | |
172 // only be called once. | |
173 void HalfCloseClientSide() { half_closed_client_side_ = true; } | |
174 void HalfCloseServerSide() { half_closed_server_side_ = true; } | |
175 | |
176 private: | 163 private: |
177 enum State { | 164 enum State { |
178 STATE_NONE, | 165 STATE_NONE, |
179 STATE_SEND_HEADERS, | 166 STATE_SEND_HEADERS, |
180 STATE_SEND_HEADERS_COMPLETE, | 167 STATE_SEND_HEADERS_COMPLETE, |
181 STATE_SEND_BODY, | 168 STATE_SEND_BODY, |
182 STATE_SEND_BODY_COMPLETE, | 169 STATE_SEND_BODY_COMPLETE, |
183 STATE_READ_HEADERS, | 170 STATE_READ_HEADERS, |
184 STATE_READ_HEADERS_COMPLETE, | 171 STATE_READ_HEADERS_COMPLETE, |
185 STATE_READ_BODY, | 172 STATE_READ_BODY, |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 BoundNetLog net_log_; | 228 BoundNetLog net_log_; |
242 | 229 |
243 base::TimeTicks send_time_; | 230 base::TimeTicks send_time_; |
244 base::TimeTicks recv_first_byte_time_; | 231 base::TimeTicks recv_first_byte_time_; |
245 base::TimeTicks recv_last_byte_time_; | 232 base::TimeTicks recv_last_byte_time_; |
246 int send_bytes_; | 233 int send_bytes_; |
247 int recv_bytes_; | 234 int recv_bytes_; |
248 bool histograms_recorded_; | 235 bool histograms_recorded_; |
249 // Data received before delegate is attached. | 236 // Data received before delegate is attached. |
250 std::vector<scoped_refptr<IOBufferWithSize> > pending_buffers_; | 237 std::vector<scoped_refptr<IOBufferWithSize> > pending_buffers_; |
251 bool half_closed_client_side_; | |
252 bool half_closed_server_side_; | |
253 | 238 |
254 DISALLOW_COPY_AND_ASSIGN(SpdyStream); | 239 DISALLOW_COPY_AND_ASSIGN(SpdyStream); |
255 }; | 240 }; |
256 | 241 |
257 } // namespace net | 242 } // namespace net |
258 | 243 |
259 #endif // NET_SPDY_SPDY_STREAM_H_ | 244 #endif // NET_SPDY_SPDY_STREAM_H_ |
OLD | NEW |