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 "base/singleton.h" | 9 #include "base/singleton.h" |
10 #include "net/spdy/spdy_session.h" | 10 #include "net/spdy/spdy_session.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 std::vector<scoped_refptr<IOBufferWithSize> > buffers; | 46 std::vector<scoped_refptr<IOBufferWithSize> > buffers; |
47 buffers.swap(pending_buffers_); | 47 buffers.swap(pending_buffers_); |
48 for (size_t i = 0; i < buffers.size(); ++i) { | 48 for (size_t i = 0; i < buffers.size(); ++i) { |
49 if (delegate_) | 49 if (delegate_) |
50 delegate_->OnDataReceived(buffers[i]->data(), buffers[i]->size()); | 50 delegate_->OnDataReceived(buffers[i]->data(), buffers[i]->size()); |
51 } | 51 } |
52 } | 52 } |
53 | 53 |
54 void SpdyStream::DetachDelegate() { | 54 void SpdyStream::DetachDelegate() { |
55 delegate_ = NULL; | 55 delegate_ = NULL; |
56 if (!response_complete_ && !cancelled()) | 56 if (!response_complete_) |
57 Cancel(); | 57 Cancel(); |
58 } | 58 } |
59 | 59 |
60 const linked_ptr<spdy::SpdyHeaderBlock>& SpdyStream::spdy_headers() const { | 60 const linked_ptr<spdy::SpdyHeaderBlock>& SpdyStream::spdy_headers() const { |
61 return request_; | 61 return request_; |
62 } | 62 } |
63 | 63 |
64 void SpdyStream::set_spdy_headers( | 64 void SpdyStream::set_spdy_headers( |
65 const linked_ptr<spdy::SpdyHeaderBlock>& headers) { | 65 const linked_ptr<spdy::SpdyHeaderBlock>& headers) { |
66 request_ = headers; | 66 request_ = headers; |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 void SpdyStream::OnClose(int status) { | 209 void SpdyStream::OnClose(int status) { |
210 response_complete_ = true; | 210 response_complete_ = true; |
211 response_status_ = status; | 211 response_status_ = status; |
212 Delegate* delegate = delegate_; | 212 Delegate* delegate = delegate_; |
213 delegate_ = NULL; | 213 delegate_ = NULL; |
214 if (delegate) | 214 if (delegate) |
215 delegate->OnClose(status); | 215 delegate->OnClose(status); |
216 } | 216 } |
217 | 217 |
218 void SpdyStream::Cancel() { | 218 void SpdyStream::Cancel() { |
| 219 if (cancelled()) |
| 220 return; |
| 221 |
219 cancelled_ = true; | 222 cancelled_ = true; |
220 session_->CloseStream(stream_id_, ERR_ABORTED); | 223 if(session_->IsStreamActive(stream_id_)) |
| 224 session_->ResetStream(stream_id_, spdy::CANCEL); |
221 } | 225 } |
222 | 226 |
223 int SpdyStream::DoSendRequest(bool has_upload_data) { | 227 int SpdyStream::DoSendRequest(bool has_upload_data) { |
224 CHECK(!cancelled_); | 228 CHECK(!cancelled_); |
225 | 229 |
226 if (!pushed_) { | 230 if (!pushed_) { |
227 spdy::SpdyControlFlags flags = spdy::CONTROL_FLAG_NONE; | 231 spdy::SpdyControlFlags flags = spdy::CONTROL_FLAG_NONE; |
228 if (!has_upload_data) | 232 if (!has_upload_data) |
229 flags = spdy::CONTROL_FLAG_FIN; | 233 flags = spdy::CONTROL_FLAG_FIN; |
230 | 234 |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
442 UMA_HISTOGRAM_TIMES("Net.SpdyStreamDownloadTime", | 446 UMA_HISTOGRAM_TIMES("Net.SpdyStreamDownloadTime", |
443 recv_last_byte_time_ - recv_first_byte_time_); | 447 recv_last_byte_time_ - recv_first_byte_time_); |
444 UMA_HISTOGRAM_TIMES("Net.SpdyStreamTime", | 448 UMA_HISTOGRAM_TIMES("Net.SpdyStreamTime", |
445 recv_last_byte_time_ - send_time_); | 449 recv_last_byte_time_ - send_time_); |
446 | 450 |
447 UMA_HISTOGRAM_COUNTS("Net.SpdySendBytes", send_bytes_); | 451 UMA_HISTOGRAM_COUNTS("Net.SpdySendBytes", send_bytes_); |
448 UMA_HISTOGRAM_COUNTS("Net.SpdyRecvBytes", recv_bytes_); | 452 UMA_HISTOGRAM_COUNTS("Net.SpdyRecvBytes", recv_bytes_); |
449 } | 453 } |
450 | 454 |
451 } // namespace net | 455 } // namespace net |
OLD | NEW |