| 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 13 matching lines...) Expand all Loading... |
| 24 public: | 24 public: |
| 25 explicit ClosingDelegate(const base::WeakPtr<SpdyStream>& stream); | 25 explicit ClosingDelegate(const base::WeakPtr<SpdyStream>& stream); |
| 26 ~ClosingDelegate() override; | 26 ~ClosingDelegate() override; |
| 27 | 27 |
| 28 // SpdyStream::Delegate implementation. | 28 // SpdyStream::Delegate implementation. |
| 29 void OnRequestHeadersSent() override; | 29 void OnRequestHeadersSent() override; |
| 30 SpdyResponseHeadersStatus OnResponseHeadersUpdated( | 30 SpdyResponseHeadersStatus OnResponseHeadersUpdated( |
| 31 const SpdyHeaderBlock& response_headers) override; | 31 const SpdyHeaderBlock& response_headers) override; |
| 32 void OnDataReceived(scoped_ptr<SpdyBuffer> buffer) override; | 32 void OnDataReceived(scoped_ptr<SpdyBuffer> buffer) override; |
| 33 void OnDataSent() override; | 33 void OnDataSent() override; |
| 34 void OnTrailers(const SpdyHeaderBlock& trailers) override; |
| 34 void OnClose(int status) override; | 35 void OnClose(int status) override; |
| 35 | 36 |
| 36 // Returns whether or not the stream is closed. | 37 // Returns whether or not the stream is closed. |
| 37 bool StreamIsClosed() const { return !stream_.get(); } | 38 bool StreamIsClosed() const { return !stream_.get(); } |
| 38 | 39 |
| 39 private: | 40 private: |
| 40 base::WeakPtr<SpdyStream> stream_; | 41 base::WeakPtr<SpdyStream> stream_; |
| 41 }; | 42 }; |
| 42 | 43 |
| 43 // Base class with shared functionality for test delegate | 44 // Base class with shared functionality for test delegate |
| 44 // implementations below. | 45 // implementations below. |
| 45 class StreamDelegateBase : public SpdyStream::Delegate { | 46 class StreamDelegateBase : public SpdyStream::Delegate { |
| 46 public: | 47 public: |
| 47 explicit StreamDelegateBase(const base::WeakPtr<SpdyStream>& stream); | 48 explicit StreamDelegateBase(const base::WeakPtr<SpdyStream>& stream); |
| 48 ~StreamDelegateBase() override; | 49 ~StreamDelegateBase() override; |
| 49 | 50 |
| 50 void OnRequestHeadersSent() override; | 51 void OnRequestHeadersSent() override; |
| 51 SpdyResponseHeadersStatus OnResponseHeadersUpdated( | 52 SpdyResponseHeadersStatus OnResponseHeadersUpdated( |
| 52 const SpdyHeaderBlock& response_headers) override; | 53 const SpdyHeaderBlock& response_headers) override; |
| 53 void OnDataReceived(scoped_ptr<SpdyBuffer> buffer) override; | 54 void OnDataReceived(scoped_ptr<SpdyBuffer> buffer) override; |
| 54 void OnDataSent() override; | 55 void OnDataSent() override; |
| 56 void OnTrailers(const SpdyHeaderBlock& trailers) override; |
| 55 void OnClose(int status) override; | 57 void OnClose(int status) override; |
| 56 | 58 |
| 57 // Waits for the stream to be closed and returns the status passed | 59 // Waits for the stream to be closed and returns the status passed |
| 58 // to OnClose(). | 60 // to OnClose(). |
| 59 int WaitForClose(); | 61 int WaitForClose(); |
| 60 | 62 |
| 61 // Drains all data from the underlying read queue and returns it as | 63 // Drains all data from the underlying read queue and returns it as |
| 62 // a string. | 64 // a string. |
| 63 std::string TakeReceivedData(); | 65 std::string TakeReceivedData(); |
| 64 | 66 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 | 131 |
| 130 SpdyResponseHeadersStatus OnResponseHeadersUpdated( | 132 SpdyResponseHeadersStatus OnResponseHeadersUpdated( |
| 131 const SpdyHeaderBlock& response_headers) override; | 133 const SpdyHeaderBlock& response_headers) override; |
| 132 }; | 134 }; |
| 133 | 135 |
| 134 } // namespace test | 136 } // namespace test |
| 135 | 137 |
| 136 } // namespace net | 138 } // namespace net |
| 137 | 139 |
| 138 #endif // NET_SPDY_SPDY_STREAM_TEST_UTIL_H_ | 140 #endif // NET_SPDY_SPDY_STREAM_TEST_UTIL_H_ |
| OLD | NEW |