Chromium Code Reviews| Index: net/spdy/bidirectional_stream_spdy_job.h |
| diff --git a/net/spdy/bidirectional_stream_spdy_job.h b/net/spdy/bidirectional_stream_spdy_job.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..3cfd4415da95dd146f102db6bc67fabd21264466 |
| --- /dev/null |
| +++ b/net/spdy/bidirectional_stream_spdy_job.h |
| @@ -0,0 +1,99 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef NET_SPDY_BIDIRECTIONAL_STREAM_SPDY_JOB_H_ |
| +#define NET_SPDY_BIDIRECTIONAL_STREAM_SPDY_JOB_H_ |
| + |
| +#include <stdint.h> |
| + |
| +#include "base/macros.h" |
| +#include "base/memory/scoped_ptr.h" |
| +#include "base/memory/weak_ptr.h" |
| +#include "net/http/bidirectional_stream_job.h" |
| +#include "net/http/bidirectional_stream_request_info.h" |
| +#include "net/http/http_request_info.h" |
| +#include "net/spdy/spdy_read_queue.h" |
| +#include "net/spdy/spdy_session.h" |
| +#include "net/spdy/spdy_stream.h" |
| + |
| +namespace base { |
| +class Timer; |
| +} // namespace base |
| + |
| +namespace net { |
| + |
| +class BoundNetLog; |
| +class IOBuffer; |
| +class SpdyHeaderBlock; |
| + |
| +class NET_EXPORT_PRIVATE BidirectionalStreamSpdyJob |
| + : public BidirectionalStreamJob, |
| + public SpdyStream::Delegate { |
| + public: |
| + explicit BidirectionalStreamSpdyJob( |
| + const base::WeakPtr<SpdySession>& spdy_session); |
| + |
| + ~BidirectionalStreamSpdyJob() override; |
| + |
| + // BidirectionalStreamJob implementation: |
| + void Start(const BidirectionalStreamRequestInfo& request_info, |
| + 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.
|
| + const BoundNetLog& net_log, |
| + BidirectionalStreamJob::Delegate* delegate, |
| + scoped_ptr<base::Timer> timer) override; |
| + int ReadData(IOBuffer* buf, int buf_len) override; |
| + void SendData(IOBuffer* data, int length, bool end_stream) override; |
| + void Cancel() override; |
| + NextProto GetProtocol() const override; |
| + int64_t GetTotalReceivedBytes() const override; |
| + int64_t GetTotalSentBytes() const override; |
| + |
| + // SpdyStream::Delegate implementation: |
| + void OnRequestHeadersSent() override; |
| + SpdyResponseHeadersStatus OnResponseHeadersUpdated( |
| + const SpdyHeaderBlock& response_headers) override; |
| + void OnDataReceived(scoped_ptr<SpdyBuffer> buffer) override; |
| + void OnDataSent() override; |
| + void OnTrailers(const SpdyHeaderBlock& trailers) override; |
| + void OnClose(int status) override; |
| + |
| + private: |
| + void SendRequestHeaders(); |
| + void OnStreamInitialized(int rv); |
| + void ScheduleBufferedRead(); |
| + void DoBufferedRead(); |
| + bool ShouldWaitForMoreBufferedData() const; |
| + |
| + const base::WeakPtr<SpdySession> spdy_session_; |
| + scoped_ptr<base::Timer> timer_; |
| + bool stream_closed_; |
| + int closed_stream_status_; |
| + 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.
|
| + |
| + BidirectionalStreamRequestInfo request_info_; |
|
mef
2015/12/15 22:59:40
Here is another copy of BidirectionalStreamRequest
xunjieli
2015/12/16 00:26:09
Done.
|
| + // Buffers the data as it arrives asynchronously from the stream. |
| + 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.
|
| + // User provided read buffer for ReadData() response. |
| + scoped_refptr<IOBuffer> read_buffer_; |
| + int read_buffer_len_; |
| + |
| + BidirectionalStreamJob::Delegate* delegate_; |
| + SpdyStreamRequest stream_request_; |
| + base::WeakPtr<SpdyStream> stream_; |
| + NextProto negotiated_protocol_; |
| + // 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.
|
| + // bytes received over the network for |stream_| while it was open. |
| + int64_t closed_stream_received_bytes_; |
| + // After |stream_| has been closed, this keeps track of the total number of |
| + // bytes sent over the network for |stream_| while it was open. |
| + int64_t closed_stream_sent_bytes_; |
| + |
| + base::WeakPtrFactory<BidirectionalStreamSpdyJob> weak_factory_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(BidirectionalStreamSpdyJob); |
| +}; |
| + |
| +} // namespace net |
| + |
| +#endif // NET_SPDY_BIDIRECTIONAL_STREAM_SPDY_JOB_H_ |