OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 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. |
| 4 |
| 5 #ifndef NET_SPDY_BIDIRECTIONAL_SPDY_STREAM_H_ |
| 6 #define NET_SPDY_BIDIRECTIONAL_SPDY_STREAM_H_ |
| 7 |
| 8 #include "base/macros.h" |
| 9 #include "base/memory/weak_ptr.h" |
| 10 #include "net/http/bidirectional_stream.h" |
| 11 #include "net/http/http_request_info.h" |
| 12 #include "net/spdy/spdy_read_queue.h" |
| 13 #include "net/spdy/spdy_session.h" |
| 14 #include "net/spdy/spdy_stream.h" |
| 15 |
| 16 namespace net { |
| 17 |
| 18 struct HttpRequestInfo; |
| 19 class IOBuffer; |
| 20 |
| 21 class NET_EXPORT_PRIVATE BidirectionalSpdyStream : public BidirectionalStream, |
| 22 public SpdyStream::Delegate { |
| 23 public: |
| 24 BidirectionalSpdyStream(const base::WeakPtr<SpdySession>& spdy_session); |
| 25 ~BidirectionalSpdyStream() override; |
| 26 |
| 27 // BidirectionalStream implementation: |
| 28 |
| 29 void Start(const HttpRequestInfo* request_info, |
| 30 RequestPriority priority, |
| 31 const BoundNetLog& net_log, |
| 32 BidirectionalStream::Delegate* delegate) override; |
| 33 |
| 34 int ReadData(IOBuffer* buf, int buf_len) override; |
| 35 |
| 36 void SendData(IOBuffer* data, int length, bool end_stream) override; |
| 37 |
| 38 void Cancel() override; |
| 39 |
| 40 // SpdyStream::Delegate implementation: |
| 41 |
| 42 void OnRequestHeadersSent() override; |
| 43 |
| 44 SpdyResponseHeadersStatus OnResponseHeadersUpdated( |
| 45 const SpdyHeaderBlock& response_headers) override; |
| 46 |
| 47 void OnDataReceived(scoped_ptr<SpdyBuffer> buffer) override; |
| 48 |
| 49 void OnDataSent() override; |
| 50 |
| 51 void OnTrailers(const SpdyHeaderBlock& trailers) override; |
| 52 |
| 53 void OnClose(int status) override; |
| 54 |
| 55 private: |
| 56 void SendRequestHeaders(); |
| 57 void OnStreamInitialized(int rv); |
| 58 void ScheduleBufferedRead(); |
| 59 void DoBufferedRead(); |
| 60 bool ShouldWaitForMoreBufferedData() const; |
| 61 |
| 62 const base::WeakPtr<SpdySession> spdy_session_; |
| 63 bool stream_closed_; |
| 64 int closed_stream_status_; |
| 65 bool buffered_read_callback_pending_; |
| 66 bool more_read_data_pending_; |
| 67 |
| 68 const HttpRequestInfo* request_info_; |
| 69 // Buffers the data as it arrives asynchronously from the stream. |
| 70 SpdyReadQueue data_queue_; |
| 71 // User provided buffer for ReadData() response. |
| 72 scoped_refptr<IOBuffer> user_buffer_; |
| 73 int user_buffer_len_; |
| 74 |
| 75 BidirectionalStream::Delegate* delegate_; |
| 76 SpdyStreamRequest stream_request_; |
| 77 base::WeakPtr<SpdyStream> stream_; |
| 78 |
| 79 base::WeakPtrFactory<BidirectionalSpdyStream> weak_factory_; |
| 80 |
| 81 DISALLOW_COPY_AND_ASSIGN(BidirectionalSpdyStream); |
| 82 }; |
| 83 |
| 84 } // namespace net |
| 85 |
| 86 #endif // NET_SPDY_BIDIRECTIONAL_SPDY_STREAM_H_ |
OLD | NEW |