Chromium Code Reviews| 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 "base/memory/ref_counted.h" | 5 #include "base/memory/ref_counted.h" |
| 6 #include "net/base/completion_callback.h" | 6 #include "net/base/completion_callback.h" |
| 7 #include "net/base/net_log_unittest.h" | 7 #include "net/base/net_log_unittest.h" |
| 8 #include "net/spdy/buffered_spdy_framer.h" | 8 #include "net/spdy/buffered_spdy_framer.h" |
| 9 #include "net/spdy/spdy_stream.h" | 9 #include "net/spdy/spdy_stream.h" |
| 10 #include "net/spdy/spdy_http_utils.h" | 10 #include "net/spdy/spdy_http_utils.h" |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 40 } | 40 } |
| 41 virtual int OnSendBody() { | 41 virtual int OnSendBody() { |
| 42 ADD_FAILURE() << "OnSendBody should not be called"; | 42 ADD_FAILURE() << "OnSendBody should not be called"; |
| 43 return ERR_UNEXPECTED; | 43 return ERR_UNEXPECTED; |
| 44 } | 44 } |
| 45 virtual int OnSendBodyComplete(int /*status*/, bool* /*eof*/) { | 45 virtual int OnSendBodyComplete(int /*status*/, bool* /*eof*/) { |
| 46 ADD_FAILURE() << "OnSendBodyComplete should not be called"; | 46 ADD_FAILURE() << "OnSendBodyComplete should not be called"; |
| 47 return ERR_UNEXPECTED; | 47 return ERR_UNEXPECTED; |
| 48 } | 48 } |
| 49 | 49 |
| 50 virtual int OnSendChunkedBody() { | |
| 51 ADD_FAILURE() << "OnSendChunkedBody should not be called"; | |
| 52 return ERR_UNEXPECTED; | |
| 53 } | |
| 54 virtual int OnSendChunkedBodyComplete(int /*status*/, bool* /*eof*/) { | |
| 55 ADD_FAILURE() << "OnSendChunkedBodyComplete should not be called"; | |
| 56 return ERR_UNEXPECTED; | |
| 57 } | |
| 58 | |
| 50 virtual int OnResponseReceived(const SpdyHeaderBlock& response, | 59 virtual int OnResponseReceived(const SpdyHeaderBlock& response, |
| 51 base::Time response_time, | 60 base::Time response_time, |
| 52 int status) { | 61 int status) { |
| 53 EXPECT_TRUE(send_headers_completed_); | 62 EXPECT_TRUE(send_headers_completed_); |
| 54 *response_ = response; | 63 *response_ = response; |
| 55 if (buf_) { | 64 if (buf_) { |
| 56 EXPECT_EQ(ERR_IO_PENDING, | 65 EXPECT_EQ(ERR_IO_PENDING, |
| 57 stream_->WriteStreamData(buf_.get(), buf_->size(), | 66 stream_->WriteStreamData(buf_.get(), buf_->size(), |
| 58 DATA_FLAG_NONE)); | 67 DATA_FLAG_NONE)); |
| 59 } | 68 } |
| 60 return status; | 69 return status; |
| 61 } | 70 } |
| 62 virtual void OnDataReceived(const char* buffer, int bytes) { | 71 virtual void OnDataReceived(const char* buffer, int bytes) { |
| 63 received_data_ += std::string(buffer, bytes); | 72 received_data_ += std::string(buffer, bytes); |
| 64 } | 73 } |
| 65 virtual void OnDataSent(int length) { | 74 virtual void OnDataSent(int length) { |
| 66 data_sent_ += length; | 75 data_sent_ += length; |
| 67 } | 76 } |
| 68 virtual void OnClose(int status) { | 77 virtual void OnClose(int status) { |
| 69 closed_ = true; | 78 closed_ = true; |
| 70 CompletionCallback callback = callback_; | 79 CompletionCallback callback = callback_; |
| 71 callback_.Reset(); | 80 callback_.Reset(); |
| 72 callback.Run(OK); | 81 callback.Run(OK); |
| 73 } | 82 } |
| 74 virtual void set_chunk_callback(net::ChunkCallback *) {} | 83 virtual void set_chunk_callback(net::ChunkCallback *) {} |
| 84 virtual bool IsRequestBodyChunked() { return false; } | |
|
Ryan Hamilton
2012/07/02 22:34:32
Should we add a test where this returns true?
ramant (doing other things)
2012/07/04 21:04:33
Deleted this code (because it is not needed).
| |
| 75 | 85 |
| 76 bool send_headers_completed() const { return send_headers_completed_; } | 86 bool send_headers_completed() const { return send_headers_completed_; } |
| 77 const linked_ptr<SpdyHeaderBlock>& response() const { | 87 const linked_ptr<SpdyHeaderBlock>& response() const { |
| 78 return response_; | 88 return response_; |
| 79 } | 89 } |
| 80 const std::string& received_data() const { return received_data_; } | 90 const std::string& received_data() const { return received_data_; } |
| 81 int data_sent() const { return data_sent_; } | 91 int data_sent() const { return data_sent_; } |
| 82 bool closed() const { return closed_; } | 92 bool closed() const { return closed_; } |
| 83 | 93 |
| 84 private: | 94 private: |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 429 entries, 0, | 439 entries, 0, |
| 430 net::NetLog::TYPE_SPDY_STREAM_ERROR, | 440 net::NetLog::TYPE_SPDY_STREAM_ERROR, |
| 431 net::NetLog::PHASE_NONE); | 441 net::NetLog::PHASE_NONE); |
| 432 | 442 |
| 433 int stream_id2; | 443 int stream_id2; |
| 434 ASSERT_TRUE(entries[pos].GetIntegerValue("stream_id", &stream_id2)); | 444 ASSERT_TRUE(entries[pos].GetIntegerValue("stream_id", &stream_id2)); |
| 435 EXPECT_EQ(static_cast<int>(stream_id), stream_id2); | 445 EXPECT_EQ(static_cast<int>(stream_id), stream_id2); |
| 436 } | 446 } |
| 437 | 447 |
| 438 } // namespace net | 448 } // namespace net |
| OLD | NEW |