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 "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 base { | |
| 17 class Timer; | |
| 18 } // namespace base | |
| 19 | |
| 20 namespace net { | |
| 21 | |
| 22 class BoundNetLog; | |
| 23 class IOBuffer; | |
| 24 class SpdyHeaderBlock; | |
| 25 | |
| 26 class NET_EXPORT_PRIVATE BidirectionalStreamSpdyJob | |
| 27 : public BidirectionalStreamJob, | |
| 28 public SpdyStream::Delegate { | |
| 29 public: | |
| 30 BidirectionalStreamSpdyJob(const base::WeakPtr<SpdySession>& spdy_session); | |
|
mmenke
2015/12/11 22:19:59
explicit
xunjieli
2015/12/11 23:48:41
Done.
| |
| 31 | |
| 32 // Constructor that accepts a Timer. This is used in tests. | |
| 33 BidirectionalStreamSpdyJob(const base::WeakPtr<SpdySession>& spdy_session, | |
| 34 scoped_ptr<base::Timer> timer); | |
|
mmenke
2015/12/11 22:19:59
Mention what the timer does?
xunjieli
2015/12/11 23:48:41
Done.
| |
| 35 ~BidirectionalStreamSpdyJob() override; | |
|
mmenke
2015/12/11 22:19:59
Seems weird to have a line break between the two c
xunjieli
2015/12/11 23:48:41
Done.
| |
| 36 | |
| 37 // BidirectionalStreamSpdyJob implementation: | |
| 38 | |
| 39 void Start(const HttpRequestInfo& request_info, | |
| 40 RequestPriority priority, | |
| 41 const BoundNetLog& net_log, | |
| 42 BidirectionalStreamJob::Delegate* delegate) override; | |
| 43 | |
| 44 int ReadData(IOBuffer* buf, int buf_len) override; | |
| 45 | |
| 46 void SendData(IOBuffer* data, int length, bool end_stream) override; | |
| 47 | |
| 48 void Cancel() override; | |
| 49 | |
| 50 NextProto GetProtocol() const override; | |
| 51 | |
| 52 int64_t GetTotalReceivedBytes() const override; | |
| 53 | |
| 54 int64_t GetTotalSentBytes() const override; | |
| 55 | |
| 56 // SpdyStream::Delegate implementation: | |
| 57 | |
| 58 void OnRequestHeadersSent() override; | |
| 59 | |
| 60 SpdyResponseHeadersStatus OnResponseHeadersUpdated( | |
| 61 const SpdyHeaderBlock& response_headers) override; | |
| 62 | |
| 63 void OnDataReceived(scoped_ptr<SpdyBuffer> buffer) override; | |
| 64 | |
| 65 void OnDataSent() override; | |
| 66 | |
| 67 void OnTrailers(const SpdyHeaderBlock& trailers) override; | |
| 68 | |
| 69 void OnClose(int status) override; | |
|
mmenke
2015/12/11 22:19:59
Generally no blank lines are put between different
xunjieli
2015/12/11 23:48:41
Done.
| |
| 70 | |
| 71 private: | |
| 72 void SendRequestHeaders(); | |
| 73 void OnStreamInitialized(int rv); | |
| 74 void ScheduleBufferedRead(); | |
| 75 void DoBufferedRead(); | |
| 76 bool ShouldWaitForMoreBufferedData() const; | |
| 77 | |
| 78 const base::WeakPtr<SpdySession> spdy_session_; | |
| 79 scoped_ptr<base::Timer> timer_; | |
| 80 bool stream_closed_; | |
| 81 int closed_stream_status_; | |
| 82 bool more_read_data_pending_; | |
| 83 | |
| 84 HttpRequestInfo request_info_; | |
| 85 // Buffers the data as it arrives asynchronously from the stream. | |
| 86 SpdyReadQueue data_queue_; | |
| 87 // User provided buffer for ReadData() response. | |
| 88 scoped_refptr<IOBuffer> user_buffer_; | |
| 89 int user_buffer_len_; | |
|
mmenke
2015/12/11 22:19:59
read_buffer_ / read_buffer_len_?
xunjieli
2015/12/11 23:48:41
Done.
| |
| 90 | |
| 91 BidirectionalStreamJob::Delegate* delegate_; | |
| 92 SpdyStreamRequest stream_request_; | |
| 93 base::WeakPtr<SpdyStream> stream_; | |
| 94 NextProto negotiated_protocol_; | |
| 95 // After |stream_| has been closed, this keeps track of the total number of | |
| 96 // bytes received over the network for |stream_| while it was open. | |
| 97 int64_t closed_stream_received_bytes_; | |
| 98 // After |stream_| has been closed, this keeps track of the total number of | |
| 99 // bytes sent over the network for |stream_| while it was open. | |
| 100 int64_t closed_stream_sent_bytes_; | |
|
mmenke
2015/12/11 22:19:59
include <stdint.h>
xunjieli
2015/12/11 23:48:41
Done.
| |
| 101 | |
| 102 base::WeakPtrFactory<BidirectionalStreamSpdyJob> weak_factory_; | |
| 103 | |
| 104 DISALLOW_COPY_AND_ASSIGN(BidirectionalStreamSpdyJob); | |
| 105 }; | |
| 106 | |
| 107 } // namespace net | |
| 108 | |
| 109 #endif // NET_SPDY_BIDIRECTIONAL_STREAM_SPDY_JOB_H_ | |
| OLD | NEW |