| 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/spdy/bidirectional_stream_spdy_impl.h" | 5 #include "net/spdy/bidirectional_stream_spdy_impl.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 | 56 |
| 57 ~TestDelegateBase() override {} | 57 ~TestDelegateBase() override {} |
| 58 | 58 |
| 59 void OnStreamReady(bool request_headers_sent) override { | 59 void OnStreamReady(bool request_headers_sent) override { |
| 60 CHECK(!on_failed_called_); | 60 CHECK(!on_failed_called_); |
| 61 } | 61 } |
| 62 | 62 |
| 63 void OnHeadersReceived(const SpdyHeaderBlock& response_headers) override { | 63 void OnHeadersReceived(const SpdyHeaderBlock& response_headers) override { |
| 64 CHECK(!on_failed_called_); | 64 CHECK(!on_failed_called_); |
| 65 CHECK(!not_expect_callback_); | 65 CHECK(!not_expect_callback_); |
| 66 response_headers_ = response_headers; | 66 response_headers_ = response_headers.Clone(); |
| 67 if (!do_not_start_read_) | 67 if (!do_not_start_read_) |
| 68 StartOrContinueReading(); | 68 StartOrContinueReading(); |
| 69 } | 69 } |
| 70 | 70 |
| 71 void OnDataRead(int bytes_read) override { | 71 void OnDataRead(int bytes_read) override { |
| 72 CHECK(!on_failed_called_); | 72 CHECK(!on_failed_called_); |
| 73 CHECK(!not_expect_callback_); | 73 CHECK(!not_expect_callback_); |
| 74 on_data_read_count_++; | 74 on_data_read_count_++; |
| 75 CHECK_GE(bytes_read, OK); | 75 CHECK_GE(bytes_read, OK); |
| 76 bytes_read_ += bytes_read; | 76 bytes_read_ += bytes_read; |
| 77 data_received_.append(read_buf_->data(), bytes_read); | 77 data_received_.append(read_buf_->data(), bytes_read); |
| 78 if (!do_not_start_read_) | 78 if (!do_not_start_read_) |
| 79 StartOrContinueReading(); | 79 StartOrContinueReading(); |
| 80 } | 80 } |
| 81 | 81 |
| 82 void OnDataSent() override { | 82 void OnDataSent() override { |
| 83 CHECK(!on_failed_called_); | 83 CHECK(!on_failed_called_); |
| 84 CHECK(!not_expect_callback_); | 84 CHECK(!not_expect_callback_); |
| 85 on_data_sent_count_++; | 85 on_data_sent_count_++; |
| 86 } | 86 } |
| 87 | 87 |
| 88 void OnTrailersReceived(const SpdyHeaderBlock& trailers) override { | 88 void OnTrailersReceived(const SpdyHeaderBlock& trailers) override { |
| 89 CHECK(!on_failed_called_); | 89 CHECK(!on_failed_called_); |
| 90 trailers_ = trailers; | 90 trailers_ = trailers.Clone(); |
| 91 if (run_until_completion_) | 91 if (run_until_completion_) |
| 92 loop_->Quit(); | 92 loop_->Quit(); |
| 93 } | 93 } |
| 94 | 94 |
| 95 void OnFailed(int error) override { | 95 void OnFailed(int error) override { |
| 96 CHECK(!on_failed_called_); | 96 CHECK(!on_failed_called_); |
| 97 CHECK(!not_expect_callback_); | 97 CHECK(!not_expect_callback_); |
| 98 CHECK_NE(OK, error); | 98 CHECK_NE(OK, error); |
| 99 error_ = error; | 99 error_ = error; |
| 100 on_failed_called_ = true; | 100 on_failed_called_ = true; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 int64_t GetTotalReceivedBytes() const { | 156 int64_t GetTotalReceivedBytes() const { |
| 157 return stream_->GetTotalReceivedBytes(); | 157 return stream_->GetTotalReceivedBytes(); |
| 158 } | 158 } |
| 159 | 159 |
| 160 int64_t GetTotalSentBytes() const { return stream_->GetTotalSentBytes(); } | 160 int64_t GetTotalSentBytes() const { return stream_->GetTotalSentBytes(); } |
| 161 | 161 |
| 162 // Const getters for internal states. | 162 // Const getters for internal states. |
| 163 const std::string& data_received() const { return data_received_; } | 163 const std::string& data_received() const { return data_received_; } |
| 164 int bytes_read() const { return bytes_read_; } | 164 int bytes_read() const { return bytes_read_; } |
| 165 int error() const { return error_; } | 165 int error() const { return error_; } |
| 166 const SpdyHeaderBlock response_headers() const { return response_headers_; } | 166 const SpdyHeaderBlock& response_headers() const { return response_headers_; } |
| 167 const SpdyHeaderBlock trailers() const { return trailers_; } | 167 const SpdyHeaderBlock& trailers() const { return trailers_; } |
| 168 int on_data_read_count() const { return on_data_read_count_; } | 168 int on_data_read_count() const { return on_data_read_count_; } |
| 169 int on_data_sent_count() const { return on_data_sent_count_; } | 169 int on_data_sent_count() const { return on_data_sent_count_; } |
| 170 bool on_failed_called() const { return on_failed_called_; } | 170 bool on_failed_called() const { return on_failed_called_; } |
| 171 | 171 |
| 172 // Sets whether the delegate should automatically start reading. | 172 // Sets whether the delegate should automatically start reading. |
| 173 void set_do_not_start_read(bool do_not_start_read) { | 173 void set_do_not_start_read(bool do_not_start_read) { |
| 174 do_not_start_read_ = do_not_start_read; | 174 do_not_start_read_ = do_not_start_read; |
| 175 } | 175 } |
| 176 | 176 |
| 177 // Cancels |stream_|. | 177 // Cancels |stream_|. |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 364 EXPECT_FALSE(delegate->on_failed_called()); | 364 EXPECT_FALSE(delegate->on_failed_called()); |
| 365 | 365 |
| 366 EXPECT_EQ("200", delegate->response_headers().find(":status")->second); | 366 EXPECT_EQ("200", delegate->response_headers().find(":status")->second); |
| 367 EXPECT_EQ(0, delegate->on_data_read_count()); | 367 EXPECT_EQ(0, delegate->on_data_read_count()); |
| 368 EXPECT_EQ(kProtoHTTP2, delegate->GetProtocol()); | 368 EXPECT_EQ(kProtoHTTP2, delegate->GetProtocol()); |
| 369 EXPECT_EQ(0, delegate->GetTotalSentBytes()); | 369 EXPECT_EQ(0, delegate->GetTotalSentBytes()); |
| 370 EXPECT_EQ(0, delegate->GetTotalReceivedBytes()); | 370 EXPECT_EQ(0, delegate->GetTotalReceivedBytes()); |
| 371 } | 371 } |
| 372 | 372 |
| 373 } // namespace net | 373 } // namespace net |
| OLD | NEW |