| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <limits> |
| 8 |
| 7 #include "base/bind.h" | 9 #include "base/bind.h" |
| 8 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 9 #include "base/location.h" | 11 #include "base/location.h" |
| 10 #include "base/logging.h" | 12 #include "base/logging.h" |
| 11 #include "base/metrics/histogram_macros.h" | 13 #include "base/metrics/histogram_macros.h" |
| 12 #include "base/single_thread_task_runner.h" | 14 #include "base/single_thread_task_runner.h" |
| 13 #include "base/strings/string_number_conversions.h" | 15 #include "base/strings/string_number_conversions.h" |
| 14 #include "base/strings/stringprintf.h" | 16 #include "base/strings/stringprintf.h" |
| 15 #include "base/thread_task_runner_handle.h" | 17 #include "base/thread_task_runner_handle.h" |
| 16 #include "base/values.h" | 18 #include "base/values.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 29 NetLogCaptureMode /* capture_mode */) { | 31 NetLogCaptureMode /* capture_mode */) { |
| 30 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | 32 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
| 31 dict->SetInteger("stream_id", static_cast<int>(stream_id)); | 33 dict->SetInteger("stream_id", static_cast<int>(stream_id)); |
| 32 dict->SetInteger("status", status); | 34 dict->SetInteger("status", status); |
| 33 dict->SetString("description", *description); | 35 dict->SetString("description", *description); |
| 34 return dict.Pass(); | 36 return dict.Pass(); |
| 35 } | 37 } |
| 36 | 38 |
| 37 scoped_ptr<base::Value> NetLogSpdyStreamWindowUpdateCallback( | 39 scoped_ptr<base::Value> NetLogSpdyStreamWindowUpdateCallback( |
| 38 SpdyStreamId stream_id, | 40 SpdyStreamId stream_id, |
| 39 int32 delta, | 41 int32_t delta, |
| 40 int32 window_size, | 42 int32_t window_size, |
| 41 NetLogCaptureMode /* capture_mode */) { | 43 NetLogCaptureMode /* capture_mode */) { |
| 42 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | 44 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
| 43 dict->SetInteger("stream_id", stream_id); | 45 dict->SetInteger("stream_id", stream_id); |
| 44 dict->SetInteger("delta", delta); | 46 dict->SetInteger("delta", delta); |
| 45 dict->SetInteger("window_size", window_size); | 47 dict->SetInteger("window_size", window_size); |
| 46 return dict.Pass(); | 48 return dict.Pass(); |
| 47 } | 49 } |
| 48 | 50 |
| 49 bool ContainsUppercaseAscii(const std::string& str) { | 51 bool ContainsUppercaseAscii(const std::string& str) { |
| 50 for (std::string::const_iterator i(str.begin()); i != str.end(); ++i) { | 52 for (std::string::const_iterator i(str.begin()); i != str.end(); ++i) { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 80 } | 82 } |
| 81 | 83 |
| 82 private: | 84 private: |
| 83 const base::WeakPtr<SpdyStream> stream_; | 85 const base::WeakPtr<SpdyStream> stream_; |
| 84 }; | 86 }; |
| 85 | 87 |
| 86 SpdyStream::SpdyStream(SpdyStreamType type, | 88 SpdyStream::SpdyStream(SpdyStreamType type, |
| 87 const base::WeakPtr<SpdySession>& session, | 89 const base::WeakPtr<SpdySession>& session, |
| 88 const GURL& url, | 90 const GURL& url, |
| 89 RequestPriority priority, | 91 RequestPriority priority, |
| 90 int32 initial_send_window_size, | 92 int32_t initial_send_window_size, |
| 91 int32 max_recv_window_size, | 93 int32_t max_recv_window_size, |
| 92 const BoundNetLog& net_log) | 94 const BoundNetLog& net_log) |
| 93 : type_(type), | 95 : type_(type), |
| 94 stream_id_(0), | 96 stream_id_(0), |
| 95 url_(url), | 97 url_(url), |
| 96 priority_(priority), | 98 priority_(priority), |
| 97 send_stalled_by_flow_control_(false), | 99 send_stalled_by_flow_control_(false), |
| 98 send_window_size_(initial_send_window_size), | 100 send_window_size_(initial_send_window_size), |
| 99 max_recv_window_size_(max_recv_window_size), | 101 max_recv_window_size_(max_recv_window_size), |
| 100 recv_window_size_(max_recv_window_size), | 102 recv_window_size_(max_recv_window_size), |
| 101 unacked_recv_window_bytes_(0), | 103 unacked_recv_window_bytes_(0), |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 send_time_ = base::TimeTicks::Now(); | 215 send_time_ = base::TimeTicks::Now(); |
| 214 return frame.Pass(); | 216 return frame.Pass(); |
| 215 } | 217 } |
| 216 | 218 |
| 217 void SpdyStream::DetachDelegate() { | 219 void SpdyStream::DetachDelegate() { |
| 218 DCHECK(!IsClosed()); | 220 DCHECK(!IsClosed()); |
| 219 delegate_ = NULL; | 221 delegate_ = NULL; |
| 220 Cancel(); | 222 Cancel(); |
| 221 } | 223 } |
| 222 | 224 |
| 223 void SpdyStream::AdjustSendWindowSize(int32 delta_window_size) { | 225 void SpdyStream::AdjustSendWindowSize(int32_t delta_window_size) { |
| 224 DCHECK_GE(session_->flow_control_state(), SpdySession::FLOW_CONTROL_STREAM); | 226 DCHECK_GE(session_->flow_control_state(), SpdySession::FLOW_CONTROL_STREAM); |
| 225 | 227 |
| 226 if (IsClosed()) | 228 if (IsClosed()) |
| 227 return; | 229 return; |
| 228 | 230 |
| 229 // Check for wraparound. | 231 // Check for wraparound. |
| 230 if (send_window_size_ > 0) { | 232 if (send_window_size_ > 0) { |
| 231 DCHECK_LE(delta_window_size, kint32max - send_window_size_); | 233 DCHECK_LE(delta_window_size, |
| 234 std::numeric_limits<int32_t>::max() - send_window_size_); |
| 232 } | 235 } |
| 233 if (send_window_size_ < 0) { | 236 if (send_window_size_ < 0) { |
| 234 DCHECK_GE(delta_window_size, kint32min - send_window_size_); | 237 DCHECK_GE(delta_window_size, |
| 238 std::numeric_limits<int32_t>::min() - send_window_size_); |
| 235 } | 239 } |
| 236 send_window_size_ += delta_window_size; | 240 send_window_size_ += delta_window_size; |
| 237 PossiblyResumeIfSendStalled(); | 241 PossiblyResumeIfSendStalled(); |
| 238 } | 242 } |
| 239 | 243 |
| 240 void SpdyStream::OnWriteBufferConsumed( | 244 void SpdyStream::OnWriteBufferConsumed( |
| 241 size_t frame_payload_size, | 245 size_t frame_payload_size, |
| 242 size_t consume_size, | 246 size_t consume_size, |
| 243 SpdyBuffer::ConsumeSource consume_source) { | 247 SpdyBuffer::ConsumeSource consume_source) { |
| 244 DCHECK_GE(session_->flow_control_state(), SpdySession::FLOW_CONTROL_STREAM); | 248 DCHECK_GE(session_->flow_control_state(), SpdySession::FLOW_CONTROL_STREAM); |
| 245 if (consume_source == SpdyBuffer::DISCARD) { | 249 if (consume_source == SpdyBuffer::DISCARD) { |
| 246 // If we're discarding a frame or part of it, increase the send | 250 // If we're discarding a frame or part of it, increase the send |
| 247 // window by the number of discarded bytes. (Although if we're | 251 // window by the number of discarded bytes. (Although if we're |
| 248 // discarding part of a frame, it's probably because of a write | 252 // discarding part of a frame, it's probably because of a write |
| 249 // error and we'll be tearing down the stream soon.) | 253 // error and we'll be tearing down the stream soon.) |
| 250 size_t remaining_payload_bytes = std::min(consume_size, frame_payload_size); | 254 size_t remaining_payload_bytes = std::min(consume_size, frame_payload_size); |
| 251 DCHECK_GT(remaining_payload_bytes, 0u); | 255 DCHECK_GT(remaining_payload_bytes, 0u); |
| 252 IncreaseSendWindowSize(static_cast<int32>(remaining_payload_bytes)); | 256 IncreaseSendWindowSize(static_cast<int32_t>(remaining_payload_bytes)); |
| 253 } | 257 } |
| 254 // For consumed bytes, the send window is increased when we receive | 258 // For consumed bytes, the send window is increased when we receive |
| 255 // a WINDOW_UPDATE frame. | 259 // a WINDOW_UPDATE frame. |
| 256 } | 260 } |
| 257 | 261 |
| 258 void SpdyStream::IncreaseSendWindowSize(int32 delta_window_size) { | 262 void SpdyStream::IncreaseSendWindowSize(int32_t delta_window_size) { |
| 259 DCHECK_GE(session_->flow_control_state(), SpdySession::FLOW_CONTROL_STREAM); | 263 DCHECK_GE(session_->flow_control_state(), SpdySession::FLOW_CONTROL_STREAM); |
| 260 DCHECK_GE(delta_window_size, 1); | 264 DCHECK_GE(delta_window_size, 1); |
| 261 | 265 |
| 262 // Ignore late WINDOW_UPDATEs. | 266 // Ignore late WINDOW_UPDATEs. |
| 263 if (IsClosed()) | 267 if (IsClosed()) |
| 264 return; | 268 return; |
| 265 | 269 |
| 266 if (send_window_size_ > 0) { | 270 if (send_window_size_ > 0) { |
| 267 // Check for overflow. | 271 // Check for overflow. |
| 268 int32 max_delta_window_size = kint32max - send_window_size_; | 272 int32_t max_delta_window_size = |
| 273 std::numeric_limits<int32_t>::max() - send_window_size_; |
| 269 if (delta_window_size > max_delta_window_size) { | 274 if (delta_window_size > max_delta_window_size) { |
| 270 std::string desc = base::StringPrintf( | 275 std::string desc = base::StringPrintf( |
| 271 "Received WINDOW_UPDATE [delta: %d] for stream %d overflows " | 276 "Received WINDOW_UPDATE [delta: %d] for stream %d overflows " |
| 272 "send_window_size_ [current: %d]", delta_window_size, stream_id_, | 277 "send_window_size_ [current: %d]", delta_window_size, stream_id_, |
| 273 send_window_size_); | 278 send_window_size_); |
| 274 session_->ResetStream(stream_id_, RST_STREAM_FLOW_CONTROL_ERROR, desc); | 279 session_->ResetStream(stream_id_, RST_STREAM_FLOW_CONTROL_ERROR, desc); |
| 275 return; | 280 return; |
| 276 } | 281 } |
| 277 } | 282 } |
| 278 | 283 |
| 279 send_window_size_ += delta_window_size; | 284 send_window_size_ += delta_window_size; |
| 280 | 285 |
| 281 net_log_.AddEvent( | 286 net_log_.AddEvent( |
| 282 NetLog::TYPE_HTTP2_STREAM_UPDATE_SEND_WINDOW, | 287 NetLog::TYPE_HTTP2_STREAM_UPDATE_SEND_WINDOW, |
| 283 base::Bind(&NetLogSpdyStreamWindowUpdateCallback, stream_id_, | 288 base::Bind(&NetLogSpdyStreamWindowUpdateCallback, stream_id_, |
| 284 delta_window_size, send_window_size_)); | 289 delta_window_size, send_window_size_)); |
| 285 | 290 |
| 286 PossiblyResumeIfSendStalled(); | 291 PossiblyResumeIfSendStalled(); |
| 287 } | 292 } |
| 288 | 293 |
| 289 void SpdyStream::DecreaseSendWindowSize(int32 delta_window_size) { | 294 void SpdyStream::DecreaseSendWindowSize(int32_t delta_window_size) { |
| 290 DCHECK_GE(session_->flow_control_state(), SpdySession::FLOW_CONTROL_STREAM); | 295 DCHECK_GE(session_->flow_control_state(), SpdySession::FLOW_CONTROL_STREAM); |
| 291 | 296 |
| 292 if (IsClosed()) | 297 if (IsClosed()) |
| 293 return; | 298 return; |
| 294 | 299 |
| 295 // We only call this method when sending a frame. Therefore, | 300 // We only call this method when sending a frame. Therefore, |
| 296 // |delta_window_size| should be within the valid frame size range. | 301 // |delta_window_size| should be within the valid frame size range. |
| 297 DCHECK_GE(delta_window_size, 1); | 302 DCHECK_GE(delta_window_size, 1); |
| 298 DCHECK_LE(delta_window_size, kMaxSpdyFrameChunkSize); | 303 DCHECK_LE(delta_window_size, kMaxSpdyFrameChunkSize); |
| 299 | 304 |
| 300 // |send_window_size_| should have been at least |delta_window_size| for | 305 // |send_window_size_| should have been at least |delta_window_size| for |
| 301 // this call to happen. | 306 // this call to happen. |
| 302 DCHECK_GE(send_window_size_, delta_window_size); | 307 DCHECK_GE(send_window_size_, delta_window_size); |
| 303 | 308 |
| 304 send_window_size_ -= delta_window_size; | 309 send_window_size_ -= delta_window_size; |
| 305 | 310 |
| 306 net_log_.AddEvent( | 311 net_log_.AddEvent( |
| 307 NetLog::TYPE_HTTP2_STREAM_UPDATE_SEND_WINDOW, | 312 NetLog::TYPE_HTTP2_STREAM_UPDATE_SEND_WINDOW, |
| 308 base::Bind(&NetLogSpdyStreamWindowUpdateCallback, stream_id_, | 313 base::Bind(&NetLogSpdyStreamWindowUpdateCallback, stream_id_, |
| 309 -delta_window_size, send_window_size_)); | 314 -delta_window_size, send_window_size_)); |
| 310 } | 315 } |
| 311 | 316 |
| 312 void SpdyStream::OnReadBufferConsumed( | 317 void SpdyStream::OnReadBufferConsumed( |
| 313 size_t consume_size, | 318 size_t consume_size, |
| 314 SpdyBuffer::ConsumeSource consume_source) { | 319 SpdyBuffer::ConsumeSource consume_source) { |
| 315 DCHECK_GE(session_->flow_control_state(), SpdySession::FLOW_CONTROL_STREAM); | 320 DCHECK_GE(session_->flow_control_state(), SpdySession::FLOW_CONTROL_STREAM); |
| 316 DCHECK_GE(consume_size, 1u); | 321 DCHECK_GE(consume_size, 1u); |
| 317 DCHECK_LE(consume_size, static_cast<size_t>(kint32max)); | 322 DCHECK_LE(consume_size, |
| 318 IncreaseRecvWindowSize(static_cast<int32>(consume_size)); | 323 static_cast<size_t>(std::numeric_limits<int32_t>::max())); |
| 324 IncreaseRecvWindowSize(static_cast<int32_t>(consume_size)); |
| 319 } | 325 } |
| 320 | 326 |
| 321 void SpdyStream::IncreaseRecvWindowSize(int32 delta_window_size) { | 327 void SpdyStream::IncreaseRecvWindowSize(int32_t delta_window_size) { |
| 322 DCHECK_GE(session_->flow_control_state(), SpdySession::FLOW_CONTROL_STREAM); | 328 DCHECK_GE(session_->flow_control_state(), SpdySession::FLOW_CONTROL_STREAM); |
| 323 | 329 |
| 324 // By the time a read is processed by the delegate, this stream may | 330 // By the time a read is processed by the delegate, this stream may |
| 325 // already be inactive. | 331 // already be inactive. |
| 326 if (!session_->IsStreamActive(stream_id_)) | 332 if (!session_->IsStreamActive(stream_id_)) |
| 327 return; | 333 return; |
| 328 | 334 |
| 329 DCHECK_GE(unacked_recv_window_bytes_, 0); | 335 DCHECK_GE(unacked_recv_window_bytes_, 0); |
| 330 DCHECK_GE(recv_window_size_, unacked_recv_window_bytes_); | 336 DCHECK_GE(recv_window_size_, unacked_recv_window_bytes_); |
| 331 DCHECK_GE(delta_window_size, 1); | 337 DCHECK_GE(delta_window_size, 1); |
| 332 // Check for overflow. | 338 // Check for overflow. |
| 333 DCHECK_LE(delta_window_size, kint32max - recv_window_size_); | 339 DCHECK_LE(delta_window_size, |
| 340 std::numeric_limits<int32_t>::max() - recv_window_size_); |
| 334 | 341 |
| 335 recv_window_size_ += delta_window_size; | 342 recv_window_size_ += delta_window_size; |
| 336 net_log_.AddEvent( | 343 net_log_.AddEvent( |
| 337 NetLog::TYPE_HTTP2_STREAM_UPDATE_RECV_WINDOW, | 344 NetLog::TYPE_HTTP2_STREAM_UPDATE_RECV_WINDOW, |
| 338 base::Bind(&NetLogSpdyStreamWindowUpdateCallback, stream_id_, | 345 base::Bind(&NetLogSpdyStreamWindowUpdateCallback, stream_id_, |
| 339 delta_window_size, recv_window_size_)); | 346 delta_window_size, recv_window_size_)); |
| 340 | 347 |
| 341 unacked_recv_window_bytes_ += delta_window_size; | 348 unacked_recv_window_bytes_ += delta_window_size; |
| 342 if (unacked_recv_window_bytes_ > max_recv_window_size_ / 2) { | 349 if (unacked_recv_window_bytes_ > max_recv_window_size_ / 2) { |
| 343 session_->SendStreamWindowUpdate( | 350 session_->SendStreamWindowUpdate( |
| 344 stream_id_, static_cast<uint32>(unacked_recv_window_bytes_)); | 351 stream_id_, static_cast<uint32_t>(unacked_recv_window_bytes_)); |
| 345 unacked_recv_window_bytes_ = 0; | 352 unacked_recv_window_bytes_ = 0; |
| 346 } | 353 } |
| 347 } | 354 } |
| 348 | 355 |
| 349 void SpdyStream::DecreaseRecvWindowSize(int32 delta_window_size) { | 356 void SpdyStream::DecreaseRecvWindowSize(int32_t delta_window_size) { |
| 350 DCHECK(session_->IsStreamActive(stream_id_)); | 357 DCHECK(session_->IsStreamActive(stream_id_)); |
| 351 DCHECK_GE(session_->flow_control_state(), SpdySession::FLOW_CONTROL_STREAM); | 358 DCHECK_GE(session_->flow_control_state(), SpdySession::FLOW_CONTROL_STREAM); |
| 352 DCHECK_GE(delta_window_size, 1); | 359 DCHECK_GE(delta_window_size, 1); |
| 353 | 360 |
| 354 // The receiving window size as the peer knows it is | 361 // The receiving window size as the peer knows it is |
| 355 // |recv_window_size_ - unacked_recv_window_bytes_|, if more data are sent by | 362 // |recv_window_size_ - unacked_recv_window_bytes_|, if more data are sent by |
| 356 // the peer, that means that the receive window is not being respected. | 363 // the peer, that means that the receive window is not being respected. |
| 357 if (delta_window_size > recv_window_size_ - unacked_recv_window_bytes_) { | 364 if (delta_window_size > recv_window_size_ - unacked_recv_window_bytes_) { |
| 358 session_->ResetStream( | 365 session_->ResetStream( |
| 359 stream_id_, RST_STREAM_FLOW_CONTROL_ERROR, | 366 stream_id_, RST_STREAM_FLOW_CONTROL_ERROR, |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 523 NOTREACHED() << io_state_; | 530 NOTREACHED() << io_state_; |
| 524 } | 531 } |
| 525 return; | 532 return; |
| 526 } | 533 } |
| 527 | 534 |
| 528 size_t length = buffer->GetRemainingSize(); | 535 size_t length = buffer->GetRemainingSize(); |
| 529 DCHECK_LE(length, session_->GetDataFrameMaximumPayload()); | 536 DCHECK_LE(length, session_->GetDataFrameMaximumPayload()); |
| 530 if (session_->flow_control_state() >= SpdySession::FLOW_CONTROL_STREAM) { | 537 if (session_->flow_control_state() >= SpdySession::FLOW_CONTROL_STREAM) { |
| 531 base::WeakPtr<SpdyStream> weak_this = GetWeakPtr(); | 538 base::WeakPtr<SpdyStream> weak_this = GetWeakPtr(); |
| 532 // May close the stream. | 539 // May close the stream. |
| 533 DecreaseRecvWindowSize(static_cast<int32>(length)); | 540 DecreaseRecvWindowSize(static_cast<int32_t>(length)); |
| 534 if (!weak_this) | 541 if (!weak_this) |
| 535 return; | 542 return; |
| 536 buffer->AddConsumeCallback( | 543 buffer->AddConsumeCallback( |
| 537 base::Bind(&SpdyStream::OnReadBufferConsumed, GetWeakPtr())); | 544 base::Bind(&SpdyStream::OnReadBufferConsumed, GetWeakPtr())); |
| 538 } | 545 } |
| 539 | 546 |
| 540 // Track our bandwidth. | 547 // Track our bandwidth. |
| 541 recv_bytes_ += length; | 548 recv_bytes_ += length; |
| 542 recv_last_byte_time_ = base::TimeTicks::Now(); | 549 recv_last_byte_time_ = base::TimeTicks::Now(); |
| 543 | 550 |
| 544 // May close |this|. | 551 // May close |this|. |
| 545 delegate_->OnDataReceived(buffer.Pass()); | 552 delegate_->OnDataReceived(buffer.Pass()); |
| 546 } | 553 } |
| 547 | 554 |
| 548 void SpdyStream::OnPaddingConsumed(size_t len) { | 555 void SpdyStream::OnPaddingConsumed(size_t len) { |
| 549 if (session_->flow_control_state() >= SpdySession::FLOW_CONTROL_STREAM) { | 556 if (session_->flow_control_state() >= SpdySession::FLOW_CONTROL_STREAM) { |
| 550 // Decrease window size because padding bytes are received. | 557 // Decrease window size because padding bytes are received. |
| 551 // Increase window size because padding bytes are consumed (by discarding). | 558 // Increase window size because padding bytes are consumed (by discarding). |
| 552 // Net result: |unacked_recv_window_bytes_| increases by |len|, | 559 // Net result: |unacked_recv_window_bytes_| increases by |len|, |
| 553 // |recv_window_size_| does not change. | 560 // |recv_window_size_| does not change. |
| 554 base::WeakPtr<SpdyStream> weak_this = GetWeakPtr(); | 561 base::WeakPtr<SpdyStream> weak_this = GetWeakPtr(); |
| 555 // May close the stream. | 562 // May close the stream. |
| 556 DecreaseRecvWindowSize(static_cast<int32>(len)); | 563 DecreaseRecvWindowSize(static_cast<int32_t>(len)); |
| 557 if (!weak_this) | 564 if (!weak_this) |
| 558 return; | 565 return; |
| 559 IncreaseRecvWindowSize(static_cast<int32>(len)); | 566 IncreaseRecvWindowSize(static_cast<int32_t>(len)); |
| 560 } | 567 } |
| 561 } | 568 } |
| 562 | 569 |
| 563 void SpdyStream::OnFrameWriteComplete(SpdyFrameType frame_type, | 570 void SpdyStream::OnFrameWriteComplete(SpdyFrameType frame_type, |
| 564 size_t frame_size) { | 571 size_t frame_size) { |
| 565 DCHECK_NE(type_, SPDY_PUSH_STREAM); | 572 DCHECK_NE(type_, SPDY_PUSH_STREAM); |
| 566 CHECK(frame_type == SYN_STREAM || | 573 CHECK(frame_type == SYN_STREAM || |
| 567 frame_type == DATA) << frame_type; | 574 frame_type == DATA) << frame_type; |
| 568 | 575 |
| 569 int result = (frame_type == SYN_STREAM) ? | 576 int result = (frame_type == SYN_STREAM) ? |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 847 if (session_->flow_control_state() >= SpdySession::FLOW_CONTROL_STREAM) { | 854 if (session_->flow_control_state() >= SpdySession::FLOW_CONTROL_STREAM) { |
| 848 DCHECK_GE(data_buffer->GetRemainingSize(), | 855 DCHECK_GE(data_buffer->GetRemainingSize(), |
| 849 session_->GetDataFrameMinimumSize()); | 856 session_->GetDataFrameMinimumSize()); |
| 850 size_t payload_size = | 857 size_t payload_size = |
| 851 data_buffer->GetRemainingSize() - session_->GetDataFrameMinimumSize(); | 858 data_buffer->GetRemainingSize() - session_->GetDataFrameMinimumSize(); |
| 852 DCHECK_LE(payload_size, session_->GetDataFrameMaximumPayload()); | 859 DCHECK_LE(payload_size, session_->GetDataFrameMaximumPayload()); |
| 853 | 860 |
| 854 // Send window size is based on payload size, so nothing to do if this is | 861 // Send window size is based on payload size, so nothing to do if this is |
| 855 // just a FIN with no payload. | 862 // just a FIN with no payload. |
| 856 if (payload_size != 0) { | 863 if (payload_size != 0) { |
| 857 DecreaseSendWindowSize(static_cast<int32>(payload_size)); | 864 DecreaseSendWindowSize(static_cast<int32_t>(payload_size)); |
| 858 // This currently isn't strictly needed, since write frames are | 865 // This currently isn't strictly needed, since write frames are |
| 859 // discarded only if the stream is about to be closed. But have it | 866 // discarded only if the stream is about to be closed. But have it |
| 860 // here anyway just in case this changes. | 867 // here anyway just in case this changes. |
| 861 data_buffer->AddConsumeCallback( | 868 data_buffer->AddConsumeCallback( |
| 862 base::Bind(&SpdyStream::OnWriteBufferConsumed, | 869 base::Bind(&SpdyStream::OnWriteBufferConsumed, |
| 863 GetWeakPtr(), payload_size)); | 870 GetWeakPtr(), payload_size)); |
| 864 } | 871 } |
| 865 } | 872 } |
| 866 | 873 |
| 867 session_->EnqueueStreamWrite( | 874 session_->EnqueueStreamWrite( |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 946 description = base::StringPrintf("Unknown state 0x%08X (%u)", state, | 953 description = base::StringPrintf("Unknown state 0x%08X (%u)", state, |
| 947 state); | 954 state); |
| 948 break; | 955 break; |
| 949 } | 956 } |
| 950 return description; | 957 return description; |
| 951 } | 958 } |
| 952 | 959 |
| 953 #undef STATE_CASE | 960 #undef STATE_CASE |
| 954 | 961 |
| 955 } // namespace net | 962 } // namespace net |
| OLD | NEW |