| 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_session.h" | 5 #include "net/spdy/spdy_session.h" |
| 6 | 6 |
| 7 #include "net/base/host_cache.h" | 7 #include "net/base/host_cache.h" |
| 8 #include "net/base/ip_endpoint.h" | 8 #include "net/base/ip_endpoint.h" |
| 9 #include "net/base/net_log_unittest.h" | 9 #include "net/base/net_log_unittest.h" |
| 10 #include "net/spdy/spdy_io_buffer.h" | 10 #include "net/spdy/spdy_io_buffer.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 return OK; | 36 return OK; |
| 37 } | 37 } |
| 38 virtual int OnSendBodyComplete(int status, bool* eof) OVERRIDE { | 38 virtual int OnSendBodyComplete(int status, bool* eof) OVERRIDE { |
| 39 return OK; | 39 return OK; |
| 40 } | 40 } |
| 41 virtual int OnResponseReceived(const SpdyHeaderBlock& response, | 41 virtual int OnResponseReceived(const SpdyHeaderBlock& response, |
| 42 base::Time response_time, | 42 base::Time response_time, |
| 43 int status) OVERRIDE { | 43 int status) OVERRIDE { |
| 44 return OK; | 44 return OK; |
| 45 } | 45 } |
| 46 virtual void OnHeadersSent() OVERRIDE {} |
| 46 virtual int OnDataReceived(const char* data, int length) OVERRIDE { | 47 virtual int OnDataReceived(const char* data, int length) OVERRIDE { |
| 47 return OK; | 48 return OK; |
| 48 } | 49 } |
| 49 virtual void OnDataSent(int length) OVERRIDE {} | 50 virtual void OnDataSent(int length) OVERRIDE {} |
| 50 virtual void OnClose(int status) OVERRIDE { | 51 virtual void OnClose(int status) OVERRIDE { |
| 51 stream_->Close(); | 52 stream_->Close(); |
| 52 } | 53 } |
| 53 private: | 54 private: |
| 54 SpdyStream* stream_; | 55 SpdyStream* stream_; |
| 55 }; | 56 }; |
| 56 | 57 |
| 57 | 58 |
| 58 class TestSpdyStreamDelegate : public net::SpdyStream::Delegate { | 59 class TestSpdyStreamDelegate : public SpdyStream::Delegate { |
| 59 public: | 60 public: |
| 60 explicit TestSpdyStreamDelegate(const CompletionCallback& callback) | 61 explicit TestSpdyStreamDelegate(const CompletionCallback& callback) |
| 61 : callback_(callback) {} | 62 : callback_(callback) {} |
| 62 virtual ~TestSpdyStreamDelegate() {} | 63 virtual ~TestSpdyStreamDelegate() {} |
| 63 | 64 |
| 64 virtual bool OnSendHeadersComplete(int status) { return true; } | 65 virtual bool OnSendHeadersComplete(int status) OVERRIDE { return true; } |
| 65 | 66 |
| 66 virtual int OnSendBody() { | 67 virtual int OnSendBody() OVERRIDE { |
| 67 return ERR_UNEXPECTED; | 68 return ERR_UNEXPECTED; |
| 68 } | 69 } |
| 69 | 70 |
| 70 virtual int OnSendBodyComplete(int /*status*/, bool* /*eof*/) { | 71 virtual int OnSendBodyComplete(int /*status*/, bool* /*eof*/) OVERRIDE { |
| 71 return ERR_UNEXPECTED; | 72 return ERR_UNEXPECTED; |
| 72 } | 73 } |
| 73 | 74 |
| 74 virtual int OnResponseReceived(const SpdyHeaderBlock& response, | 75 virtual int OnResponseReceived(const SpdyHeaderBlock& response, |
| 75 base::Time response_time, | 76 base::Time response_time, |
| 76 int status) { | 77 int status) OVERRIDE { |
| 77 return status; | 78 return status; |
| 78 } | 79 } |
| 79 | 80 |
| 80 virtual int OnDataReceived(const char* buffer, int bytes) { | 81 virtual void OnHeadersSent() OVERRIDE {} |
| 82 virtual int OnDataReceived(const char* buffer, int bytes) OVERRIDE { |
| 81 return OK; | 83 return OK; |
| 82 } | 84 } |
| 83 | 85 |
| 84 virtual void OnDataSent(int length) { | 86 virtual void OnDataSent(int length) OVERRIDE {} |
| 85 } | |
| 86 | 87 |
| 87 virtual void OnClose(int status) { | 88 virtual void OnClose(int status) OVERRIDE { |
| 88 CompletionCallback callback = callback_; | 89 CompletionCallback callback = callback_; |
| 89 callback_.Reset(); | 90 callback_.Reset(); |
| 90 callback.Run(OK); | 91 callback.Run(OK); |
| 91 } | 92 } |
| 92 | 93 |
| 93 private: | 94 private: |
| 94 CompletionCallback callback_; | 95 CompletionCallback callback_; |
| 95 }; | 96 }; |
| 96 | 97 |
| 97 } // namespace | 98 } // namespace |
| (...skipping 1586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1684 session->CloseSessionOnError(ERR_ABORTED, true, ""); | 1685 session->CloseSessionOnError(ERR_ABORTED, true, ""); |
| 1685 | 1686 |
| 1686 EXPECT_TRUE(spdy_stream1->closed()); | 1687 EXPECT_TRUE(spdy_stream1->closed()); |
| 1687 EXPECT_TRUE(spdy_stream2->closed()); | 1688 EXPECT_TRUE(spdy_stream2->closed()); |
| 1688 | 1689 |
| 1689 spdy_stream1 = NULL; | 1690 spdy_stream1 = NULL; |
| 1690 spdy_stream2 = NULL; | 1691 spdy_stream2 = NULL; |
| 1691 } | 1692 } |
| 1692 | 1693 |
| 1693 } // namespace net | 1694 } // namespace net |
| OLD | NEW |