OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/quic/chromium/bidirectional_stream_quic_impl.h" | 5 #include "net/quic/chromium/bidirectional_stream_quic_impl.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/callback_helpers.h" | 9 #include "base/callback_helpers.h" |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 void OnDataRead(int bytes_read) override { | 310 void OnDataRead(int bytes_read) override { |
311 DCHECK_NE(ON_HEADERS_RECEIVED, phase_); | 311 DCHECK_NE(ON_HEADERS_RECEIVED, phase_); |
312 if (phase_ == ON_DATA_READ) | 312 if (phase_ == ON_DATA_READ) |
313 DeleteStream(); | 313 DeleteStream(); |
314 TestDelegateBase::OnDataRead(bytes_read); | 314 TestDelegateBase::OnDataRead(bytes_read); |
315 } | 315 } |
316 | 316 |
317 void OnTrailersReceived(const SpdyHeaderBlock& trailers) override { | 317 void OnTrailersReceived(const SpdyHeaderBlock& trailers) override { |
318 DCHECK_NE(ON_HEADERS_RECEIVED, phase_); | 318 DCHECK_NE(ON_HEADERS_RECEIVED, phase_); |
319 DCHECK_NE(ON_DATA_READ, phase_); | 319 DCHECK_NE(ON_DATA_READ, phase_); |
| 320 // Make a copy of |response_headers| before the stream is deleted, since |
| 321 // the headers are owned by the stream. |
| 322 SpdyHeaderBlock trailers_copy = trailers.Clone(); |
320 if (phase_ == ON_TRAILERS_RECEIVED) | 323 if (phase_ == ON_TRAILERS_RECEIVED) |
321 DeleteStream(); | 324 DeleteStream(); |
322 TestDelegateBase::OnTrailersReceived(trailers); | 325 TestDelegateBase::OnTrailersReceived(trailers_copy); |
323 } | 326 } |
324 | 327 |
325 void OnFailed(int error) override { | 328 void OnFailed(int error) override { |
326 DCHECK_EQ(ON_FAILED, phase_); | 329 DCHECK_EQ(ON_FAILED, phase_); |
327 DeleteStream(); | 330 DeleteStream(); |
328 TestDelegateBase::OnFailed(error); | 331 TestDelegateBase::OnFailed(error); |
329 } | 332 } |
330 | 333 |
331 private: | 334 private: |
332 // Indicates in which callback the delegate should cancel or delete the | 335 // Indicates in which callback the delegate should cancel or delete the |
(...skipping 1560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1893 | 1896 |
1894 base::RunLoop().RunUntilIdle(); | 1897 base::RunLoop().RunUntilIdle(); |
1895 | 1898 |
1896 EXPECT_EQ(1, delegate->on_data_read_count()); | 1899 EXPECT_EQ(1, delegate->on_data_read_count()); |
1897 EXPECT_EQ(0, delegate->on_data_sent_count()); | 1900 EXPECT_EQ(0, delegate->on_data_sent_count()); |
1898 } | 1901 } |
1899 | 1902 |
1900 } // namespace test | 1903 } // namespace test |
1901 | 1904 |
1902 } // namespace net | 1905 } // namespace net |
OLD | NEW |