| 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 #include "base/ref_counted.h" | 6 #include "base/ref_counted.h" |
| 7 #include "net/spdy/spdy_http_utils.h" | 7 #include "net/spdy/spdy_http_utils.h" |
| 8 #include "net/spdy/spdy_session.h" | 8 #include "net/spdy/spdy_session.h" |
| 9 #include "net/spdy/spdy_test_util.h" | 9 #include "net/spdy/spdy_test_util.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 virtual ~TestSpdyStreamDelegate() {} | 44 virtual ~TestSpdyStreamDelegate() {} |
| 45 | 45 |
| 46 virtual bool OnSendHeadersComplete(int status) { | 46 virtual bool OnSendHeadersComplete(int status) { |
| 47 send_headers_completed_ = true; | 47 send_headers_completed_ = true; |
| 48 return true; | 48 return true; |
| 49 } | 49 } |
| 50 virtual int OnSendBody() { | 50 virtual int OnSendBody() { |
| 51 ADD_FAILURE() << "OnSendBody should not be called"; | 51 ADD_FAILURE() << "OnSendBody should not be called"; |
| 52 return ERR_UNEXPECTED; | 52 return ERR_UNEXPECTED; |
| 53 } | 53 } |
| 54 virtual bool OnSendBodyComplete(int status) { | 54 virtual int OnSendBodyComplete(int /*status*/, bool* /*eof*/) { |
| 55 ADD_FAILURE() << "OnSendBodyComplete should not be called"; | 55 ADD_FAILURE() << "OnSendBodyComplete should not be called"; |
| 56 return true; | 56 return ERR_UNEXPECTED; |
| 57 } | 57 } |
| 58 | 58 |
| 59 virtual int OnResponseReceived(const spdy::SpdyHeaderBlock& response, | 59 virtual int OnResponseReceived(const spdy::SpdyHeaderBlock& response, |
| 60 base::Time response_time, | 60 base::Time response_time, |
| 61 int status) { | 61 int status) { |
| 62 EXPECT_TRUE(send_headers_completed_); | 62 EXPECT_TRUE(send_headers_completed_); |
| 63 *response_ = response; | 63 *response_ = response; |
| 64 if (buf_) { | 64 if (buf_) { |
| 65 EXPECT_EQ(ERR_IO_PENDING, | 65 EXPECT_EQ(ERR_IO_PENDING, |
| 66 stream_->WriteStreamData(buf_.get(), buf_->size(), | 66 stream_->WriteStreamData(buf_.get(), buf_->size(), |
| 67 spdy::DATA_FLAG_NONE)); | 67 spdy::DATA_FLAG_NONE)); |
| 68 } | 68 } |
| 69 return status; | 69 return status; |
| 70 } | 70 } |
| 71 virtual void OnDataReceived(const char* buffer, int bytes) { | 71 virtual void OnDataReceived(const char* buffer, int bytes) { |
| 72 received_data_ += std::string(buffer, bytes); | 72 received_data_ += std::string(buffer, bytes); |
| 73 } | 73 } |
| 74 virtual void OnDataSent(int length) { | 74 virtual void OnDataSent(int length) { |
| 75 data_sent_ += length; | 75 data_sent_ += length; |
| 76 } | 76 } |
| 77 virtual void OnClose(int status) { | 77 virtual void OnClose(int status) { |
| 78 closed_ = true; | 78 closed_ = true; |
| 79 CompletionCallback* callback = callback_; | 79 CompletionCallback* callback = callback_; |
| 80 callback_ = NULL; | 80 callback_ = NULL; |
| 81 callback->Run(OK); | 81 callback->Run(OK); |
| 82 } | 82 } |
| 83 virtual void set_chunk_callback(net::ChunkCallback *) {} |
| 83 | 84 |
| 84 bool send_headers_completed() const { return send_headers_completed_; } | 85 bool send_headers_completed() const { return send_headers_completed_; } |
| 85 const linked_ptr<spdy::SpdyHeaderBlock>& response() const { | 86 const linked_ptr<spdy::SpdyHeaderBlock>& response() const { |
| 86 return response_; | 87 return response_; |
| 87 } | 88 } |
| 88 const std::string& received_data() const { return received_data_; } | 89 const std::string& received_data() const { return received_data_; } |
| 89 int data_sent() const { return data_sent_; } | 90 int data_sent() const { return data_sent_; } |
| 90 bool closed() const { return closed_; } | 91 bool closed() const { return closed_; } |
| 91 | 92 |
| 92 private: | 93 private: |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 stream->OnHeaders(headers); | 271 stream->OnHeaders(headers); |
| 271 | 272 |
| 272 stream->set_response_received(); | 273 stream->set_response_received(); |
| 273 EXPECT_TRUE(stream->response_received()); | 274 EXPECT_TRUE(stream->response_received()); |
| 274 EXPECT_TRUE(stream->HasUrl()); | 275 EXPECT_TRUE(stream->HasUrl()); |
| 275 EXPECT_EQ(kStreamUrl, stream->GetUrl().spec()); | 276 EXPECT_EQ(kStreamUrl, stream->GetUrl().spec()); |
| 276 } | 277 } |
| 277 | 278 |
| 278 | 279 |
| 279 } // namespace net | 280 } // namespace net |
| OLD | NEW |