| 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/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 explicit ClosingDelegate(const base::WeakPtr<SpdyStream>& stream); | 25 explicit ClosingDelegate(const base::WeakPtr<SpdyStream>& stream); |
| 26 virtual ~ClosingDelegate(); | 26 virtual ~ClosingDelegate(); |
| 27 | 27 |
| 28 // SpdyStream::Delegate implementation. | 28 // SpdyStream::Delegate implementation. |
| 29 virtual SpdySendStatus OnSendHeadersComplete() OVERRIDE; | 29 virtual SpdySendStatus OnSendHeadersComplete() OVERRIDE; |
| 30 virtual void OnSendBody() OVERRIDE; | 30 virtual void OnSendBody() OVERRIDE; |
| 31 virtual SpdySendStatus OnSendBodyComplete() OVERRIDE; | 31 virtual SpdySendStatus OnSendBodyComplete() OVERRIDE; |
| 32 virtual int OnResponseReceived(const SpdyHeaderBlock& response, | 32 virtual int OnResponseReceived(const SpdyHeaderBlock& response, |
| 33 base::Time response_time, | 33 base::Time response_time, |
| 34 int status) OVERRIDE; | 34 int status) OVERRIDE; |
| 35 virtual void OnHeadersSent() OVERRIDE; | |
| 36 virtual int OnDataReceived(scoped_ptr<SpdyBuffer> buffer) OVERRIDE; | 35 virtual int OnDataReceived(scoped_ptr<SpdyBuffer> buffer) OVERRIDE; |
| 37 virtual void OnDataSent() OVERRIDE; | 36 virtual void OnDataSent() OVERRIDE; |
| 38 virtual void OnClose(int status) OVERRIDE; | 37 virtual void OnClose(int status) OVERRIDE; |
| 39 | 38 |
| 40 // Returns whether or not the stream is closed. | 39 // Returns whether or not the stream is closed. |
| 41 bool StreamIsClosed() const { return !stream_; } | 40 bool StreamIsClosed() const { return !stream_; } |
| 42 | 41 |
| 43 private: | 42 private: |
| 44 base::WeakPtr<SpdyStream> stream_; | 43 base::WeakPtr<SpdyStream> stream_; |
| 45 }; | 44 }; |
| 46 | 45 |
| 47 // Base class with shared functionality for test delegate | 46 // Base class with shared functionality for test delegate |
| 48 // implementations below. | 47 // implementations below. |
| 49 class StreamDelegateBase : public SpdyStream::Delegate { | 48 class StreamDelegateBase : public SpdyStream::Delegate { |
| 50 public: | 49 public: |
| 51 explicit StreamDelegateBase(const base::WeakPtr<SpdyStream>& stream); | 50 explicit StreamDelegateBase(const base::WeakPtr<SpdyStream>& stream); |
| 52 virtual ~StreamDelegateBase(); | 51 virtual ~StreamDelegateBase(); |
| 53 | 52 |
| 54 virtual SpdySendStatus OnSendHeadersComplete() OVERRIDE; | 53 virtual SpdySendStatus OnSendHeadersComplete() OVERRIDE; |
| 55 virtual void OnSendBody() = 0; | 54 virtual void OnSendBody() = 0; |
| 56 virtual SpdySendStatus OnSendBodyComplete() = 0; | 55 virtual SpdySendStatus OnSendBodyComplete() = 0; |
| 57 virtual int OnResponseReceived(const SpdyHeaderBlock& response, | 56 virtual int OnResponseReceived(const SpdyHeaderBlock& response, |
| 58 base::Time response_time, | 57 base::Time response_time, |
| 59 int status) OVERRIDE; | 58 int status) OVERRIDE; |
| 60 virtual void OnHeadersSent() OVERRIDE; | |
| 61 virtual int OnDataReceived(scoped_ptr<SpdyBuffer> buffer) OVERRIDE; | 59 virtual int OnDataReceived(scoped_ptr<SpdyBuffer> buffer) OVERRIDE; |
| 62 virtual void OnDataSent() OVERRIDE; | 60 virtual void OnDataSent() OVERRIDE; |
| 63 virtual void OnClose(int status) OVERRIDE; | 61 virtual void OnClose(int status) OVERRIDE; |
| 64 | 62 |
| 65 // Waits for the stream to be closed and returns the status passed | 63 // Waits for the stream to be closed and returns the status passed |
| 66 // to OnClose(). | 64 // to OnClose(). |
| 67 int WaitForClose(); | 65 int WaitForClose(); |
| 68 | 66 |
| 69 // Drains all data from the underlying read queue and returns it as | 67 // Drains all data from the underlying read queue and returns it as |
| 70 // a string. | 68 // a string. |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 | 132 |
| 135 private: | 133 private: |
| 136 scoped_refptr<StringIOBuffer> buf_; | 134 scoped_refptr<StringIOBuffer> buf_; |
| 137 }; | 135 }; |
| 138 | 136 |
| 139 } // namespace test | 137 } // namespace test |
| 140 | 138 |
| 141 } // namespace net | 139 } // namespace net |
| 142 | 140 |
| 143 #endif // NET_SPDY_SPDY_STREAM_TEST_UTIL_H_ | 141 #endif // NET_SPDY_SPDY_STREAM_TEST_UTIL_H_ |
| OLD | NEW |