| 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 #include "net/spdy/spdy_stream.h" | 5 #include "net/spdy/spdy_stream.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "net/http/http_request_info.h" | 9 #include "net/http/http_request_info.h" |
| 10 #include "net/http/http_response_info.h" | 10 #include "net/http/http_response_info.h" |
| 11 #include "net/spdy/spdy_session.h" | 11 #include "net/spdy/spdy_session.h" |
| 12 | 12 |
| 13 namespace net { | 13 namespace net { |
| 14 | 14 |
| 15 SpdyStream::SpdyStream(SpdySession* session, spdy::SpdyStreamId stream_id, | 15 SpdyStream::SpdyStream(SpdySession* session, spdy::SpdyStreamId stream_id, |
| 16 bool pushed, LoadLog* log) | 16 bool pushed, const BoundNetLog& log) |
| 17 : stream_id_(stream_id), | 17 : stream_id_(stream_id), |
| 18 priority_(0), | 18 priority_(0), |
| 19 pushed_(pushed), | 19 pushed_(pushed), |
| 20 download_finished_(false), | 20 download_finished_(false), |
| 21 metrics_(Singleton<BandwidthMetrics>::get()), | 21 metrics_(Singleton<BandwidthMetrics>::get()), |
| 22 session_(session), | 22 session_(session), |
| 23 response_(NULL), | 23 response_(NULL), |
| 24 request_body_stream_(NULL), | 24 request_body_stream_(NULL), |
| 25 response_complete_(false), | 25 response_complete_(false), |
| 26 io_state_(STATE_NONE), | 26 io_state_(STATE_NONE), |
| 27 response_status_(OK), | 27 response_status_(OK), |
| 28 user_callback_(NULL), | 28 user_callback_(NULL), |
| 29 user_buffer_(NULL), | 29 user_buffer_(NULL), |
| 30 user_buffer_len_(0), | 30 user_buffer_len_(0), |
| 31 cancelled_(false), | 31 cancelled_(false), |
| 32 load_log_(log), | 32 net_log_(log), |
| 33 send_bytes_(0), | 33 send_bytes_(0), |
| 34 recv_bytes_(0), | 34 recv_bytes_(0), |
| 35 histograms_recorded_(false), | 35 histograms_recorded_(false), |
| 36 buffered_read_callback_pending_(false), | 36 buffered_read_callback_pending_(false), |
| 37 more_read_data_pending_(false) {} | 37 more_read_data_pending_(false) {} |
| 38 | 38 |
| 39 SpdyStream::~SpdyStream() { | 39 SpdyStream::~SpdyStream() { |
| 40 DLOG(INFO) << "Deleting SpdyStream for stream " << stream_id_; | 40 DLOG(INFO) << "Deleting SpdyStream for stream " << stream_id_; |
| 41 | 41 |
| 42 // TODO(willchan): We're still calling CancelStream() too many times, because | 42 // TODO(willchan): We're still calling CancelStream() too many times, because |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 } | 271 } |
| 272 | 272 |
| 273 int SpdyStream::DoLoop(int result) { | 273 int SpdyStream::DoLoop(int result) { |
| 274 do { | 274 do { |
| 275 State state = io_state_; | 275 State state = io_state_; |
| 276 io_state_ = STATE_NONE; | 276 io_state_ = STATE_NONE; |
| 277 switch (state) { | 277 switch (state) { |
| 278 // State machine 1: Send headers and wait for response headers. | 278 // State machine 1: Send headers and wait for response headers. |
| 279 case STATE_SEND_HEADERS: | 279 case STATE_SEND_HEADERS: |
| 280 CHECK_EQ(OK, result); | 280 CHECK_EQ(OK, result); |
| 281 LoadLog::BeginEvent(load_log_, | 281 net_log_.BeginEvent(NetLog::TYPE_SPDY_STREAM_SEND_HEADERS); |
| 282 LoadLog::TYPE_SPDY_STREAM_SEND_HEADERS); | |
| 283 result = DoSendHeaders(); | 282 result = DoSendHeaders(); |
| 284 break; | 283 break; |
| 285 case STATE_SEND_HEADERS_COMPLETE: | 284 case STATE_SEND_HEADERS_COMPLETE: |
| 286 LoadLog::EndEvent(load_log_, | 285 net_log_.EndEvent(NetLog::TYPE_SPDY_STREAM_SEND_HEADERS); |
| 287 LoadLog::TYPE_SPDY_STREAM_SEND_HEADERS); | |
| 288 result = DoSendHeadersComplete(result); | 286 result = DoSendHeadersComplete(result); |
| 289 break; | 287 break; |
| 290 case STATE_SEND_BODY: | 288 case STATE_SEND_BODY: |
| 291 CHECK_EQ(OK, result); | 289 CHECK_EQ(OK, result); |
| 292 LoadLog::BeginEvent(load_log_, | 290 net_log_.BeginEvent(NetLog::TYPE_SPDY_STREAM_SEND_BODY); |
| 293 LoadLog::TYPE_SPDY_STREAM_SEND_BODY); | |
| 294 result = DoSendBody(); | 291 result = DoSendBody(); |
| 295 break; | 292 break; |
| 296 case STATE_SEND_BODY_COMPLETE: | 293 case STATE_SEND_BODY_COMPLETE: |
| 297 LoadLog::EndEvent(load_log_, | 294 net_log_.EndEvent(NetLog::TYPE_SPDY_STREAM_SEND_BODY); |
| 298 LoadLog::TYPE_SPDY_STREAM_SEND_BODY); | |
| 299 result = DoSendBodyComplete(result); | 295 result = DoSendBodyComplete(result); |
| 300 break; | 296 break; |
| 301 case STATE_READ_HEADERS: | 297 case STATE_READ_HEADERS: |
| 302 CHECK_EQ(OK, result); | 298 CHECK_EQ(OK, result); |
| 303 LoadLog::BeginEvent(load_log_, | 299 net_log_.BeginEvent(NetLog::TYPE_SPDY_STREAM_READ_HEADERS); |
| 304 LoadLog::TYPE_SPDY_STREAM_READ_HEADERS); | |
| 305 result = DoReadHeaders(); | 300 result = DoReadHeaders(); |
| 306 break; | 301 break; |
| 307 case STATE_READ_HEADERS_COMPLETE: | 302 case STATE_READ_HEADERS_COMPLETE: |
| 308 LoadLog::EndEvent(load_log_, | 303 net_log_.EndEvent(NetLog::TYPE_SPDY_STREAM_READ_HEADERS); |
| 309 LoadLog::TYPE_SPDY_STREAM_READ_HEADERS); | |
| 310 result = DoReadHeadersComplete(result); | 304 result = DoReadHeadersComplete(result); |
| 311 break; | 305 break; |
| 312 | 306 |
| 313 // State machine 2: Read body. | 307 // State machine 2: Read body. |
| 314 // NOTE(willchan): Currently unused. Currently we handle this stuff in | 308 // NOTE(willchan): Currently unused. Currently we handle this stuff in |
| 315 // the OnDataReceived()/OnClose()/ReadResponseHeaders()/etc. Only reason | 309 // the OnDataReceived()/OnClose()/ReadResponseHeaders()/etc. Only reason |
| 316 // to do this is for consistency with the Http code. | 310 // to do this is for consistency with the Http code. |
| 317 case STATE_READ_BODY: | 311 case STATE_READ_BODY: |
| 318 LoadLog::BeginEvent(load_log_, | 312 net_log_.BeginEvent(NetLog::TYPE_SPDY_STREAM_READ_BODY); |
| 319 LoadLog::TYPE_SPDY_STREAM_READ_BODY); | |
| 320 result = DoReadBody(); | 313 result = DoReadBody(); |
| 321 break; | 314 break; |
| 322 case STATE_READ_BODY_COMPLETE: | 315 case STATE_READ_BODY_COMPLETE: |
| 323 LoadLog::EndEvent(load_log_, | 316 net_log_.EndEvent(NetLog::TYPE_SPDY_STREAM_READ_BODY); |
| 324 LoadLog::TYPE_SPDY_STREAM_READ_BODY); | |
| 325 result = DoReadBodyComplete(result); | 317 result = DoReadBodyComplete(result); |
| 326 break; | 318 break; |
| 327 case STATE_DONE: | 319 case STATE_DONE: |
| 328 DCHECK(result != ERR_IO_PENDING); | 320 DCHECK(result != ERR_IO_PENDING); |
| 329 break; | 321 break; |
| 330 default: | 322 default: |
| 331 NOTREACHED(); | 323 NOTREACHED(); |
| 332 break; | 324 break; |
| 333 } | 325 } |
| 334 } while (result != ERR_IO_PENDING && io_state_ != STATE_NONE); | 326 } while (result != ERR_IO_PENDING && io_state_ != STATE_NONE); |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 499 UMA_HISTOGRAM_TIMES("Net.SpdyStreamDownloadTime", | 491 UMA_HISTOGRAM_TIMES("Net.SpdyStreamDownloadTime", |
| 500 recv_last_byte_time_ - recv_first_byte_time_); | 492 recv_last_byte_time_ - recv_first_byte_time_); |
| 501 UMA_HISTOGRAM_TIMES("Net.SpdyStreamTime", | 493 UMA_HISTOGRAM_TIMES("Net.SpdyStreamTime", |
| 502 recv_last_byte_time_ - send_time_); | 494 recv_last_byte_time_ - send_time_); |
| 503 | 495 |
| 504 UMA_HISTOGRAM_COUNTS("Net.SpdySendBytes", send_bytes_); | 496 UMA_HISTOGRAM_COUNTS("Net.SpdySendBytes", send_bytes_); |
| 505 UMA_HISTOGRAM_COUNTS("Net.SpdyRecvBytes", recv_bytes_); | 497 UMA_HISTOGRAM_COUNTS("Net.SpdyRecvBytes", recv_bytes_); |
| 506 } | 498 } |
| 507 | 499 |
| 508 } // namespace net | 500 } // namespace net |
| OLD | NEW |