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 IOBufferWithSize* buf, | 20 IOBufferWithSize* buf, |
21 const CompletionCallback& callback); | 21 const CompletionCallback& callback); |
22 virtual ~TestSpdyStreamDelegate(); | 22 virtual ~TestSpdyStreamDelegate(); |
23 | 23 |
24 virtual bool OnSendHeadersComplete(int status) OVERRIDE; | 24 virtual bool OnSendHeadersComplete(int status) OVERRIDE; |
25 virtual int OnSendBody() OVERRIDE; | 25 virtual int OnSendBody() OVERRIDE; |
26 virtual int OnSendBodyComplete(int status, bool* eof) OVERRIDE; | 26 virtual int OnSendBodyComplete(int status, bool* eof) OVERRIDE; |
27 virtual int OnResponseReceived(const SpdyHeaderBlock& response, | 27 virtual int OnResponseReceived(const SpdyHeaderBlock& response, |
28 base::Time response_time, | 28 base::Time response_time, |
29 int status) OVERRIDE; | 29 int status) OVERRIDE; |
30 virtual void OnDataReceived(const char* buffer, int bytes) OVERRIDE; | 30 virtual int OnDataReceived(const char* buffer, int bytes) OVERRIDE; |
31 virtual void OnDataSent(int length) OVERRIDE; | 31 virtual void OnDataSent(int length) OVERRIDE; |
32 virtual void OnClose(int status) OVERRIDE; | 32 virtual void OnClose(int status) OVERRIDE; |
33 | 33 |
34 bool send_headers_completed() const { return send_headers_completed_; } | 34 bool send_headers_completed() const { return send_headers_completed_; } |
35 const linked_ptr<SpdyHeaderBlock>& response() const { | 35 const linked_ptr<SpdyHeaderBlock>& response() const { |
36 return response_; | 36 return response_; |
37 } | 37 } |
38 const std::string& received_data() const { return received_data_; } | 38 const std::string& received_data() const { return received_data_; } |
39 int data_sent() const { return data_sent_; } | 39 int data_sent() const { return data_sent_; } |
40 bool closed() const { return closed_; } | 40 bool closed() const { return closed_; } |
41 | 41 |
42 private: | 42 private: |
43 SpdyStream* stream_; | 43 SpdyStream* stream_; |
44 scoped_refptr<IOBufferWithSize> buf_; | 44 scoped_refptr<IOBufferWithSize> buf_; |
45 CompletionCallback callback_; | 45 CompletionCallback callback_; |
46 bool send_headers_completed_; | 46 bool send_headers_completed_; |
47 linked_ptr<SpdyHeaderBlock> response_; | 47 linked_ptr<SpdyHeaderBlock> response_; |
48 std::string received_data_; | 48 std::string received_data_; |
49 int data_sent_; | 49 int data_sent_; |
50 bool closed_; | 50 bool closed_; |
51 | 51 |
52 }; | 52 }; |
53 | 53 |
54 } // namespace test | 54 } // namespace test |
55 | 55 |
56 } // namespace net | 56 } // namespace net |
57 | 57 |
58 #endif // NET_SPDY_SPDY_STREAM_TEST_UTIL_H_ | 58 #endif // NET_SPDY_SPDY_STREAM_TEST_UTIL_H_ |
OLD | NEW |