summaryrefslogtreecommitdiffstats
path: root/net/spdy/spdy_stream_test_util.h
blob: 605901493bebb2740a74f693c56fc74178046fea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef NET_SPDY_SPDY_STREAM_TEST_UTIL_H_
#define NET_SPDY_SPDY_STREAM_TEST_UTIL_H_

#include "base/memory/linked_ptr.h"
#include "base/memory/ref_counted.h"
#include "net/base/completion_callback.h"
#include "net/spdy/spdy_stream.h"

namespace net {

namespace test {

class TestSpdyStreamDelegate : public SpdyStream::Delegate {
 public:
  TestSpdyStreamDelegate(SpdyStream* stream,
                         SpdyHeaderBlock* headers,
                         IOBufferWithSize* buf,
                         const CompletionCallback& callback);
  virtual ~TestSpdyStreamDelegate();

  virtual bool OnSendHeadersComplete(int status) OVERRIDE;
  virtual int OnSendBody() OVERRIDE;
  virtual int OnSendBodyComplete(int status, bool* eof) OVERRIDE;
  virtual int OnResponseReceived(const SpdyHeaderBlock& response,
                                 base::Time response_time,
                                 int status) OVERRIDE;
  virtual void OnHeadersSent() OVERRIDE;
  virtual int OnDataReceived(const char* buffer, int bytes) OVERRIDE;
  virtual void OnDataSent(int length) OVERRIDE;
  virtual void OnClose(int status) OVERRIDE;

  bool send_headers_completed() const { return send_headers_completed_; }
  const linked_ptr<SpdyHeaderBlock>& response() const {
    return response_;
  }
  const std::string& received_data() const { return received_data_; }
  int headers_sent() const { return headers_sent_; }
  int data_sent() const { return data_sent_; }
  bool closed() const {  return closed_; }

 private:
  SpdyStream* stream_;
  scoped_ptr<SpdyHeaderBlock> headers_;
  scoped_refptr<IOBufferWithSize> buf_;
  CompletionCallback callback_;
  bool send_headers_completed_;
  linked_ptr<SpdyHeaderBlock> response_;
  std::string received_data_;
  int headers_sent_;
  int data_sent_;
  bool closed_;

};

} // namespace test

} // namespace net

#endif // NET_SPDY_SPDY_STREAM_TEST_UTIL_H_