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 void OnDataReceived(const char* data, int length) OVERRIDE {} | 47 virtual void OnDataReceived(const char* data, int length) OVERRIDE {} |
47 virtual void OnDataSent(int length) OVERRIDE {} | 48 virtual void OnDataSent(int length) OVERRIDE {} |
48 virtual void OnClose(int status) OVERRIDE { | 49 virtual void OnClose(int status) OVERRIDE { |
49 stream_->Close(); | 50 stream_->Close(); |
50 } | 51 } |
51 private: | 52 private: |
52 SpdyStream* stream_; | 53 SpdyStream* stream_; |
53 }; | 54 }; |
54 | 55 |
55 } // namespace | 56 } // namespace |
56 | 57 |
57 // TODO(cbentzel): Expose compression setter/getter in public SpdySession | 58 // TODO(cbentzel): Expose compression setter/getter in public SpdySession |
58 // interface rather than going through all these contortions. | 59 // interface rather than going through all these contortions. |
59 class SpdySessionSpdy2Test : public PlatformTest { | 60 class SpdySessionSpdy2Test : public PlatformTest { |
60 protected: | 61 protected: |
61 virtual void SetUp() { | 62 virtual void SetUp() { |
62 SpdySession::set_default_protocol(kProtoSPDY2); | 63 SpdySession::set_default_protocol(kProtoSPDY2); |
63 } | 64 } |
64 | 65 |
65 private: | 66 private: |
66 SpdyTestStateHelper spdy_state_; | 67 SpdyTestStateHelper spdy_state_; |
67 }; | 68 }; |
68 | 69 |
69 class TestSpdyStreamDelegate : public net::SpdyStream::Delegate { | 70 class TestSpdyStreamDelegate : public net::SpdyStream::Delegate { |
70 public: | 71 public: |
71 explicit TestSpdyStreamDelegate(const CompletionCallback& callback) | 72 explicit TestSpdyStreamDelegate(const CompletionCallback& callback) |
72 : callback_(callback) {} | 73 : callback_(callback) {} |
73 virtual ~TestSpdyStreamDelegate() {} | 74 virtual ~TestSpdyStreamDelegate() {} |
74 | 75 |
75 virtual bool OnSendHeadersComplete(int status) { return true; } | 76 virtual bool OnSendHeadersComplete(int status) OVERRIDE { return true; } |
76 | 77 |
77 virtual int OnSendBody() { | 78 virtual int OnSendBody() OVERRIDE { |
78 return ERR_UNEXPECTED; | 79 return ERR_UNEXPECTED; |
79 } | 80 } |
80 | 81 |
81 virtual int OnSendBodyComplete(int /*status*/, bool* /*eof*/) { | 82 virtual int OnSendBodyComplete(int /*status*/, bool* /*eof*/) OVERRIDE { |
82 return ERR_UNEXPECTED; | 83 return ERR_UNEXPECTED; |
83 } | 84 } |
84 | 85 |
85 virtual int OnResponseReceived(const SpdyHeaderBlock& response, | 86 virtual int OnResponseReceived(const SpdyHeaderBlock& response, |
86 base::Time response_time, | 87 base::Time response_time, |
87 int status) { | 88 int status) OVERRIDE { |
88 return status; | 89 return status; |
89 } | 90 } |
90 | 91 |
91 virtual void OnDataReceived(const char* buffer, int bytes) { | 92 virtual void OnHeadersSent() OVERRIDE {} |
92 } | 93 virtual void OnDataReceived(const char* buffer, int bytes) OVERRIDE {} |
93 | 94 |
94 virtual void OnDataSent(int length) { | 95 virtual void OnDataSent(int length) OVERRIDE {} |
95 } | |
96 | 96 |
97 virtual void OnClose(int status) { | 97 virtual void OnClose(int status) OVERRIDE { |
98 CompletionCallback callback = callback_; | 98 CompletionCallback callback = callback_; |
99 callback_.Reset(); | 99 callback_.Reset(); |
100 callback.Run(OK); | 100 callback.Run(OK); |
101 } | 101 } |
102 | 102 |
103 private: | 103 private: |
104 CompletionCallback callback_; | 104 CompletionCallback callback_; |
105 }; | 105 }; |
106 | 106 |
107 // Test the SpdyIOBuffer class. | 107 // Test the SpdyIOBuffer class. |
(...skipping 1403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1511 session->CloseSessionOnError(ERR_ABORTED, true, ""); | 1511 session->CloseSessionOnError(ERR_ABORTED, true, ""); |
1512 | 1512 |
1513 EXPECT_TRUE(spdy_stream1->closed()); | 1513 EXPECT_TRUE(spdy_stream1->closed()); |
1514 EXPECT_TRUE(spdy_stream2->closed()); | 1514 EXPECT_TRUE(spdy_stream2->closed()); |
1515 | 1515 |
1516 spdy_stream1 = NULL; | 1516 spdy_stream1 = NULL; |
1517 spdy_stream2 = NULL; | 1517 spdy_stream2 = NULL; |
1518 } | 1518 } |
1519 | 1519 |
1520 } // namespace net | 1520 } // namespace net |
OLD | NEW |