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