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/spdy_network_transaction.cc

Issue 2919011: Implement MAX_CONCURRENT_STREAMS SETTINGS header (Closed)
Patch Set: landing soon on a repo near you Created 10 years, 5 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 | « net/spdy/spdy_network_transaction.h ('k') | net/spdy/spdy_network_transaction_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 #include "net/spdy/spdy_network_transaction.h" 5 #include "net/spdy/spdy_network_transaction.h"
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/scoped_ptr.h" 9 #include "base/scoped_ptr.h"
10 #include "base/stats_counters.h" 10 #include "base/stats_counters.h"
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 const HttpResponseInfo* SpdyNetworkTransaction::GetResponseInfo() const { 105 const HttpResponseInfo* SpdyNetworkTransaction::GetResponseInfo() const {
106 return (response_.headers || response_.ssl_info.cert) ? &response_ : NULL; 106 return (response_.headers || response_.ssl_info.cert) ? &response_ : NULL;
107 } 107 }
108 108
109 LoadState SpdyNetworkTransaction::GetLoadState() const { 109 LoadState SpdyNetworkTransaction::GetLoadState() const {
110 switch (next_state_) { 110 switch (next_state_) {
111 case STATE_INIT_CONNECTION_COMPLETE: 111 case STATE_INIT_CONNECTION_COMPLETE:
112 if (spdy_.get()) 112 if (spdy_.get())
113 return spdy_->GetLoadState(); 113 return spdy_->GetLoadState();
114 return LOAD_STATE_CONNECTING; 114 return LOAD_STATE_CONNECTING;
115 case STATE_GET_STREAM_COMPLETE:
115 case STATE_SEND_REQUEST_COMPLETE: 116 case STATE_SEND_REQUEST_COMPLETE:
116 return LOAD_STATE_SENDING_REQUEST; 117 return LOAD_STATE_SENDING_REQUEST;
117 case STATE_READ_HEADERS_COMPLETE: 118 case STATE_READ_HEADERS_COMPLETE:
118 return LOAD_STATE_WAITING_FOR_RESPONSE; 119 return LOAD_STATE_WAITING_FOR_RESPONSE;
119 case STATE_READ_BODY_COMPLETE: 120 case STATE_READ_BODY_COMPLETE:
120 return LOAD_STATE_READING_RESPONSE; 121 return LOAD_STATE_READING_RESPONSE;
121 default: 122 default:
122 return LOAD_STATE_IDLE; 123 return LOAD_STATE_IDLE;
123 } 124 }
124 } 125 }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 case STATE_INIT_CONNECTION: 162 case STATE_INIT_CONNECTION:
162 DCHECK_EQ(OK, rv); 163 DCHECK_EQ(OK, rv);
163 net_log_.BeginEvent(NetLog::TYPE_SPDY_TRANSACTION_INIT_CONNECTION, 164 net_log_.BeginEvent(NetLog::TYPE_SPDY_TRANSACTION_INIT_CONNECTION,
164 NULL); 165 NULL);
165 rv = DoInitConnection(); 166 rv = DoInitConnection();
166 break; 167 break;
167 case STATE_INIT_CONNECTION_COMPLETE: 168 case STATE_INIT_CONNECTION_COMPLETE:
168 net_log_.EndEvent(NetLog::TYPE_SPDY_TRANSACTION_INIT_CONNECTION, NULL); 169 net_log_.EndEvent(NetLog::TYPE_SPDY_TRANSACTION_INIT_CONNECTION, NULL);
169 rv = DoInitConnectionComplete(rv); 170 rv = DoInitConnectionComplete(rv);
170 break; 171 break;
172 case STATE_GET_STREAM:
173 DCHECK_EQ(OK, rv);
174 rv = DoGetStream();
175 break;
176 case STATE_GET_STREAM_COMPLETE:
177 rv = DoGetStreamComplete(rv);
171 case STATE_SEND_REQUEST: 178 case STATE_SEND_REQUEST:
172 DCHECK_EQ(OK, rv); 179 DCHECK_EQ(OK, rv);
173 net_log_.BeginEvent(NetLog::TYPE_SPDY_TRANSACTION_SEND_REQUEST, NULL); 180 net_log_.BeginEvent(NetLog::TYPE_SPDY_TRANSACTION_SEND_REQUEST, NULL);
174 rv = DoSendRequest(); 181 rv = DoSendRequest();
175 break; 182 break;
176 case STATE_SEND_REQUEST_COMPLETE: 183 case STATE_SEND_REQUEST_COMPLETE:
177 net_log_.EndEvent(NetLog::TYPE_SPDY_TRANSACTION_SEND_REQUEST, NULL); 184 net_log_.EndEvent(NetLog::TYPE_SPDY_TRANSACTION_SEND_REQUEST, NULL);
178 rv = DoSendRequestComplete(rv); 185 rv = DoSendRequestComplete(rv);
179 break; 186 break;
180 case STATE_READ_HEADERS: 187 case STATE_READ_HEADERS:
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 DCHECK(spdy_); 243 DCHECK(spdy_);
237 244
238 return spdy_->Connect( 245 return spdy_->Connect(
239 connection_group, tcp_params, request_->priority); 246 connection_group, tcp_params, request_->priority);
240 } 247 }
241 248
242 int SpdyNetworkTransaction::DoInitConnectionComplete(int result) { 249 int SpdyNetworkTransaction::DoInitConnectionComplete(int result) {
243 if (result < 0) 250 if (result < 0)
244 return result; 251 return result;
245 252
253 next_state_ = STATE_GET_STREAM;
254 return OK;
255 }
256
257 int SpdyNetworkTransaction::DoGetStream() {
258 next_state_ = STATE_GET_STREAM_COMPLETE;
259
260 // It is possible that the spdy session was shut down while it was
261 // asynchronously waiting to connect.
262 if (spdy_->IsClosed())
263 return ERR_CONNECTION_CLOSED;
264
265 CHECK(!stream_.get());
266
267 stream_.reset(new SpdyHttpStream());
268 return stream_->InitializeStream(spdy_, *request_,
269 net_log_, &io_callback_);
270 }
271
272 int SpdyNetworkTransaction::DoGetStreamComplete(int result) {
273 if (result < 0) {
274 return result;
275 }
276
246 next_state_ = STATE_SEND_REQUEST; 277 next_state_ = STATE_SEND_REQUEST;
247 return OK; 278 return OK;
248 } 279 }
249 280
250 int SpdyNetworkTransaction::DoSendRequest() { 281 int SpdyNetworkTransaction::DoSendRequest() {
251 next_state_ = STATE_SEND_REQUEST_COMPLETE; 282 next_state_ = STATE_SEND_REQUEST_COMPLETE;
252 CHECK(!stream_.get());
253 283
254 // It is possible that the spdy session was shut down while it was 284 UploadDataStream* upload_data_stream = NULL;
255 // asynchronously waiting to connect.
256 if(spdy_->IsClosed())
257 return ERR_CONNECTION_CLOSED;
258
259 UploadDataStream* upload_data = NULL;
260 if (request_->upload_data) { 285 if (request_->upload_data) {
261 int error_code; 286 int error_code;
262 upload_data = UploadDataStream::Create(request_->upload_data, &error_code); 287 upload_data_stream = UploadDataStream::Create(request_->upload_data,
263 if (!upload_data) 288 &error_code);
289 if (!upload_data_stream)
264 return error_code; 290 return error_code;
265 } 291 }
266 scoped_refptr<SpdyStream> spdy_stream; 292 stream_->InitializeRequest(base::Time::Now(), upload_data_stream);
267 if (request_->method == "GET") {
268 int error = spdy_->GetPushStream(request_->url, &spdy_stream, net_log_);
269 if (error != OK)
270 return error;
271 }
272 if (spdy_stream.get()) {
273 DCHECK(spdy_stream->pushed());
274 CHECK(spdy_stream->GetDelegate() == NULL);
275 stream_.reset(new SpdyHttpStream(spdy_stream));
276 stream_->InitializeRequest(*request_, base::Time::Now(), NULL);
277 // "vary" field?
278 } else {
279 int error = spdy_->CreateStream(request_->url,
280 request_->priority,
281 &spdy_stream,
282 net_log_);
283 if (error != OK)
284 return error;
285 DCHECK(!spdy_stream->pushed());
286 CHECK(spdy_stream->GetDelegate() == NULL);
287 stream_.reset(new SpdyHttpStream(spdy_stream));
288 stream_->InitializeRequest(*request_, base::Time::Now(), upload_data);
289 }
290 spdy_ = NULL; 293 spdy_ = NULL;
294
291 return stream_->SendRequest(&response_, &io_callback_); 295 return stream_->SendRequest(&response_, &io_callback_);
292 } 296 }
293 297
294 int SpdyNetworkTransaction::DoSendRequestComplete(int result) { 298 int SpdyNetworkTransaction::DoSendRequestComplete(int result) {
295 if (result < 0) { 299 if (result < 0) {
296 stream_.reset() ; 300 stream_.reset();
297 return result; 301 return result;
298 } 302 }
299 303
300 next_state_ = STATE_READ_HEADERS; 304 next_state_ = STATE_READ_HEADERS;
301 return OK; 305 return OK;
302 } 306 }
303 307
304 int SpdyNetworkTransaction::DoReadHeaders() { 308 int SpdyNetworkTransaction::DoReadHeaders() {
305 next_state_ = STATE_READ_HEADERS_COMPLETE; 309 next_state_ = STATE_READ_HEADERS_COMPLETE;
306 return stream_->ReadResponseHeaders(&io_callback_); 310 return stream_->ReadResponseHeaders(&io_callback_);
(...skipping 15 matching lines...) Expand all
322 user_buffer_ = NULL; 326 user_buffer_ = NULL;
323 user_buffer_len_ = 0; 327 user_buffer_len_ = 0;
324 328
325 if (result <= 0) 329 if (result <= 0)
326 stream_.reset(); 330 stream_.reset();
327 331
328 return result; 332 return result;
329 } 333 }
330 334
331 } // namespace net 335 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/spdy_network_transaction.h ('k') | net/spdy/spdy_network_transaction_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698