| 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_test_util.h" | 5 #include "net/spdy/spdy_stream_test_util.h" |
| 6 | 6 |
| 7 #include <cstddef> | 7 #include <cstddef> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 void ClosingDelegate::OnDataSent() {} | 33 void ClosingDelegate::OnDataSent() {} |
| 34 | 34 |
| 35 void ClosingDelegate::OnTrailers(const SpdyHeaderBlock& trailers) {} | 35 void ClosingDelegate::OnTrailers(const SpdyHeaderBlock& trailers) {} |
| 36 | 36 |
| 37 void ClosingDelegate::OnClose(int status) { | 37 void ClosingDelegate::OnClose(int status) { |
| 38 DCHECK(stream_); | 38 DCHECK(stream_); |
| 39 stream_->Close(); | 39 stream_->Close(); |
| 40 // The |stream_| may still be alive (if it is our delegate). | 40 // The |stream_| may still be alive (if it is our delegate). |
| 41 } | 41 } |
| 42 | 42 |
| 43 NetLogSource ClosingDelegate::source_dependency() const { |
| 44 return NetLogSource(); |
| 45 } |
| 46 |
| 43 StreamDelegateBase::StreamDelegateBase( | 47 StreamDelegateBase::StreamDelegateBase( |
| 44 const base::WeakPtr<SpdyStream>& stream) | 48 const base::WeakPtr<SpdyStream>& stream) |
| 45 : stream_(stream), | 49 : stream_(stream), |
| 46 stream_id_(0), | 50 stream_id_(0), |
| 47 send_headers_completed_(false) { | 51 send_headers_completed_(false) { |
| 48 } | 52 } |
| 49 | 53 |
| 50 StreamDelegateBase::~StreamDelegateBase() { | 54 StreamDelegateBase::~StreamDelegateBase() { |
| 51 } | 55 } |
| 52 | 56 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 72 void StreamDelegateBase::OnTrailers(const SpdyHeaderBlock& trailers) {} | 76 void StreamDelegateBase::OnTrailers(const SpdyHeaderBlock& trailers) {} |
| 73 | 77 |
| 74 void StreamDelegateBase::OnClose(int status) { | 78 void StreamDelegateBase::OnClose(int status) { |
| 75 if (!stream_.get()) | 79 if (!stream_.get()) |
| 76 return; | 80 return; |
| 77 stream_id_ = stream_->stream_id(); | 81 stream_id_ = stream_->stream_id(); |
| 78 stream_.reset(); | 82 stream_.reset(); |
| 79 callback_.callback().Run(status); | 83 callback_.callback().Run(status); |
| 80 } | 84 } |
| 81 | 85 |
| 86 NetLogSource StreamDelegateBase::source_dependency() const { |
| 87 return NetLogSource(); |
| 88 } |
| 89 |
| 82 int StreamDelegateBase::WaitForClose() { | 90 int StreamDelegateBase::WaitForClose() { |
| 83 int result = callback_.WaitForResult(); | 91 int result = callback_.WaitForResult(); |
| 84 EXPECT_TRUE(!stream_.get()); | 92 EXPECT_TRUE(!stream_.get()); |
| 85 return result; | 93 return result; |
| 86 } | 94 } |
| 87 | 95 |
| 88 std::string StreamDelegateBase::TakeReceivedData() { | 96 std::string StreamDelegateBase::TakeReceivedData() { |
| 89 size_t len = received_data_queue_.GetTotalSize(); | 97 size_t len = received_data_queue_.GetTotalSize(); |
| 90 std::string received_data(len, '\0'); | 98 std::string received_data(len, '\0'); |
| 91 if (len > 0) { | 99 if (len > 0) { |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 } | 156 } |
| 149 | 157 |
| 150 void StreamDelegateCloseOnHeaders::OnHeadersReceived( | 158 void StreamDelegateCloseOnHeaders::OnHeadersReceived( |
| 151 const SpdyHeaderBlock& response_headers) { | 159 const SpdyHeaderBlock& response_headers) { |
| 152 stream()->Cancel(); | 160 stream()->Cancel(); |
| 153 } | 161 } |
| 154 | 162 |
| 155 } // namespace test | 163 } // namespace test |
| 156 | 164 |
| 157 } // namespace net | 165 } // namespace net |
| OLD | NEW |