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
3 // found in the LICENSE file.
5 #ifndef NET_SPDY_SPDY_STREAM_TEST_UTIL_H_
6 #define NET_SPDY_SPDY_STREAM_TEST_UTIL_H_
8 #include "base/memory/linked_ptr.h"
9 #include "base/memory/ref_counted.h"
10 #include "net/base/completion_callback.h"
11 #include "net/spdy/spdy_stream.h"
17 class TestSpdyStreamDelegate
: public SpdyStream::Delegate
{
19 TestSpdyStreamDelegate(SpdyStream
* stream
,
20 SpdyHeaderBlock
* headers
,
21 IOBufferWithSize
* buf
,
22 const CompletionCallback
& callback
);
23 virtual ~TestSpdyStreamDelegate();
25 virtual bool OnSendHeadersComplete(int status
) OVERRIDE
;
26 virtual int OnSendBody() OVERRIDE
;
27 virtual int OnSendBodyComplete(int status
, bool* eof
) OVERRIDE
;
28 virtual int OnResponseReceived(const SpdyHeaderBlock
& response
,
29 base::Time response_time
,
31 virtual void OnHeadersSent() OVERRIDE
;
32 virtual int OnDataReceived(const char* buffer
, int bytes
) OVERRIDE
;
33 virtual void OnDataSent(int length
) OVERRIDE
;
34 virtual void OnClose(int status
) OVERRIDE
;
36 bool send_headers_completed() const { return send_headers_completed_
; }
37 const linked_ptr
<SpdyHeaderBlock
>& response() const {
40 const std::string
& received_data() const { return received_data_
; }
41 int headers_sent() const { return headers_sent_
; }
42 int data_sent() const { return data_sent_
; }
43 bool closed() const { return closed_
; }
47 scoped_ptr
<SpdyHeaderBlock
> headers_
;
48 scoped_refptr
<IOBufferWithSize
> buf_
;
49 CompletionCallback callback_
;
50 bool send_headers_completed_
;
51 linked_ptr
<SpdyHeaderBlock
> response_
;
52 std::string received_data_
;
63 #endif // NET_SPDY_SPDY_STREAM_TEST_UTIL_H_