Chromium Code Reviews| 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 <stdint.h> | |
| 9 | |
| 10 #include "base/macros.h" | |
| 11 #include "base/memory/scoped_ptr.h" | |
| 12 #include "base/memory/weak_ptr.h" | |
| 13 #include "net/http/bidirectional_stream_job.h" | |
| 14 #include "net/http/bidirectional_stream_request_info.h" | |
| 15 #include "net/http/http_request_info.h" | |
| 16 #include "net/spdy/spdy_read_queue.h" | |
| 17 #include "net/spdy/spdy_session.h" | |
| 18 #include "net/spdy/spdy_stream.h" | |
| 19 | |
| 20 namespace base { | |
| 21 class Timer; | |
| 22 } // namespace base | |
| 23 | |
| 24 namespace net { | |
| 25 | |
| 26 class BoundNetLog; | |
| 27 class IOBuffer; | |
| 28 class SpdyHeaderBlock; | |
| 29 | |
| 30 class NET_EXPORT_PRIVATE BidirectionalStreamSpdyJob | |
| 31 : public BidirectionalStreamJob, | |
| 32 public SpdyStream::Delegate { | |
| 33 public: | |
| 34 explicit BidirectionalStreamSpdyJob( | |
| 35 const base::WeakPtr<SpdySession>& spdy_session); | |
| 36 | |
| 37 ~BidirectionalStreamSpdyJob() override; | |
| 38 | |
| 39 // BidirectionalStreamJob implementation: | |
| 40 void Start(const BidirectionalStreamRequestInfo& request_info, | |
| 41 RequestPriority priority, | |
|
mef
2015/12/15 22:59:40
nit: any particular reason why priority is not a p
xunjieli
2015/12/16 00:26:09
Done.
| |
| 42 const BoundNetLog& net_log, | |
| 43 BidirectionalStreamJob::Delegate* delegate, | |
| 44 scoped_ptr<base::Timer> timer) override; | |
| 45 int ReadData(IOBuffer* buf, int buf_len) override; | |
| 46 void SendData(IOBuffer* data, int length, bool end_stream) override; | |
| 47 void Cancel() override; | |
| 48 NextProto GetProtocol() const override; | |
| 49 int64_t GetTotalReceivedBytes() const override; | |
| 50 int64_t GetTotalSentBytes() const override; | |
| 51 | |
| 52 // SpdyStream::Delegate implementation: | |
| 53 void OnRequestHeadersSent() override; | |
| 54 SpdyResponseHeadersStatus OnResponseHeadersUpdated( | |
| 55 const SpdyHeaderBlock& response_headers) override; | |
| 56 void OnDataReceived(scoped_ptr<SpdyBuffer> buffer) override; | |
| 57 void OnDataSent() override; | |
| 58 void OnTrailers(const SpdyHeaderBlock& trailers) override; | |
| 59 void OnClose(int status) override; | |
| 60 | |
| 61 private: | |
| 62 void SendRequestHeaders(); | |
| 63 void OnStreamInitialized(int rv); | |
| 64 void ScheduleBufferedRead(); | |
| 65 void DoBufferedRead(); | |
| 66 bool ShouldWaitForMoreBufferedData() const; | |
| 67 | |
| 68 const base::WeakPtr<SpdySession> spdy_session_; | |
| 69 scoped_ptr<base::Timer> timer_; | |
| 70 bool stream_closed_; | |
| 71 int closed_stream_status_; | |
| 72 bool more_read_data_pending_; | |
|
mef
2015/12/15 22:59:40
move close to other read-related fields like data_
xunjieli
2015/12/16 00:26:09
Done.
| |
| 73 | |
| 74 BidirectionalStreamRequestInfo request_info_; | |
|
mef
2015/12/15 22:59:40
Here is another copy of BidirectionalStreamRequest
xunjieli
2015/12/16 00:26:09
Done.
| |
| 75 // Buffers the data as it arrives asynchronously from the stream. | |
| 76 SpdyReadQueue data_queue_; | |
|
mef
2015/12/15 22:59:40
optional nit: maybe call this read_data_queue_?
xunjieli
2015/12/16 00:26:09
Done.
| |
| 77 // User provided read buffer for ReadData() response. | |
| 78 scoped_refptr<IOBuffer> read_buffer_; | |
| 79 int read_buffer_len_; | |
| 80 | |
| 81 BidirectionalStreamJob::Delegate* delegate_; | |
| 82 SpdyStreamRequest stream_request_; | |
| 83 base::WeakPtr<SpdyStream> stream_; | |
| 84 NextProto negotiated_protocol_; | |
| 85 // After |stream_| has been closed, this keeps track of the total number of | |
|
mef
2015/12/15 22:59:40
move these together with closed_stream_ and closed
xunjieli
2015/12/16 00:26:09
Done. Good idea.
| |
| 86 // bytes received over the network for |stream_| while it was open. | |
| 87 int64_t closed_stream_received_bytes_; | |
| 88 // After |stream_| has been closed, this keeps track of the total number of | |
| 89 // bytes sent over the network for |stream_| while it was open. | |
| 90 int64_t closed_stream_sent_bytes_; | |
| 91 | |
| 92 base::WeakPtrFactory<BidirectionalStreamSpdyJob> weak_factory_; | |
| 93 | |
| 94 DISALLOW_COPY_AND_ASSIGN(BidirectionalStreamSpdyJob); | |
| 95 }; | |
| 96 | |
| 97 } // namespace net | |
| 98 | |
| 99 #endif // NET_SPDY_BIDIRECTIONAL_STREAM_SPDY_JOB_H_ | |
| OLD | NEW |