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 #ifndef NET_SPDY_SPDY_STREAM_TEST_UTIL_H_ | 5 #ifndef NET_SPDY_SPDY_STREAM_TEST_UTIL_H_ |
6 #define NET_SPDY_SPDY_STREAM_TEST_UTIL_H_ | 6 #define NET_SPDY_SPDY_STREAM_TEST_UTIL_H_ |
7 | 7 |
8 #include "base/memory/linked_ptr.h" | 8 #include "base/memory/linked_ptr.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "net/base/completion_callback.h" | 10 #include "net/base/completion_callback.h" |
11 #include "net/spdy/spdy_stream.h" | 11 #include "net/spdy/spdy_stream.h" |
12 | 12 |
13 namespace net { | 13 namespace net { |
14 | 14 |
15 namespace test { | 15 namespace test { |
16 | 16 |
17 class TestSpdyStreamDelegate : public SpdyStream::Delegate { | 17 class TestSpdyStreamDelegate : public SpdyStream::Delegate { |
18 public: | 18 public: |
19 TestSpdyStreamDelegate(SpdyStream* stream, | 19 TestSpdyStreamDelegate(SpdyStream* stream, |
| 20 SpdyHeaderBlock* headers, |
20 IOBufferWithSize* buf, | 21 IOBufferWithSize* buf, |
21 const CompletionCallback& callback); | 22 const CompletionCallback& callback); |
22 virtual ~TestSpdyStreamDelegate(); | 23 virtual ~TestSpdyStreamDelegate(); |
23 | 24 |
24 virtual bool OnSendHeadersComplete(int status) OVERRIDE; | 25 virtual bool OnSendHeadersComplete(int status) OVERRIDE; |
25 virtual int OnSendBody() OVERRIDE; | 26 virtual int OnSendBody() OVERRIDE; |
26 virtual int OnSendBodyComplete(int status, bool* eof) OVERRIDE; | 27 virtual int OnSendBodyComplete(int status, bool* eof) OVERRIDE; |
27 virtual int OnResponseReceived(const SpdyHeaderBlock& response, | 28 virtual int OnResponseReceived(const SpdyHeaderBlock& response, |
28 base::Time response_time, | 29 base::Time response_time, |
29 int status) OVERRIDE; | 30 int status) OVERRIDE; |
30 virtual void OnDataReceived(const char* buffer, int bytes) OVERRIDE; | 31 virtual void OnDataReceived(const char* buffer, int bytes) OVERRIDE; |
31 virtual void OnDataSent(int length) OVERRIDE; | 32 virtual void OnDataSent(int length) OVERRIDE; |
32 virtual void OnClose(int status) OVERRIDE; | 33 virtual void OnClose(int status) OVERRIDE; |
33 | 34 |
34 bool send_headers_completed() const { return send_headers_completed_; } | 35 bool send_headers_completed() const { return send_headers_completed_; } |
35 const linked_ptr<SpdyHeaderBlock>& response() const { | 36 const linked_ptr<SpdyHeaderBlock>& response() const { |
36 return response_; | 37 return response_; |
37 } | 38 } |
38 const std::string& received_data() const { return received_data_; } | 39 const std::string& received_data() const { return received_data_; } |
39 int data_sent() const { return data_sent_; } | 40 int data_sent() const { return data_sent_; } |
40 bool closed() const { return closed_; } | 41 bool closed() const { return closed_; } |
41 | 42 |
42 private: | 43 private: |
43 SpdyStream* stream_; | 44 SpdyStream* stream_; |
| 45 scoped_ptr<SpdyHeaderBlock> headers_; |
44 scoped_refptr<IOBufferWithSize> buf_; | 46 scoped_refptr<IOBufferWithSize> buf_; |
45 CompletionCallback callback_; | 47 CompletionCallback callback_; |
46 bool send_headers_completed_; | 48 bool send_headers_completed_; |
47 linked_ptr<SpdyHeaderBlock> response_; | 49 linked_ptr<SpdyHeaderBlock> response_; |
48 std::string received_data_; | 50 std::string received_data_; |
49 int data_sent_; | 51 int data_sent_; |
50 bool closed_; | 52 bool closed_; |
51 | 53 |
52 }; | 54 }; |
53 | 55 |
54 } // namespace test | 56 } // namespace test |
55 | 57 |
56 } // namespace net | 58 } // namespace net |
57 | 59 |
58 #endif // NET_SPDY_SPDY_STREAM_TEST_UTIL_H_ | 60 #endif // NET_SPDY_SPDY_STREAM_TEST_UTIL_H_ |
OLD | NEW |