Chromium Code Reviews| Index: net/quic/bidirectional_stream_quic_job.h |
| diff --git a/net/quic/bidirectional_stream_quic_job.h b/net/quic/bidirectional_stream_quic_job.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..4d2b1336ef72da7e79a11e18a6983429a42413ca |
| --- /dev/null |
| +++ b/net/quic/bidirectional_stream_quic_job.h |
| @@ -0,0 +1,119 @@ |
| +// Copyright 2016 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_QUIC_BIDIRECTIONAL_STREAM_QUIC_JOB_H_ |
| +#define NET_QUIC_BIDIRECTIONAL_STREAM_QUIC_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/net_features.h" |
| +#include "net/quic/quic_chromium_client_session.h" |
| +#include "net/quic/quic_chromium_client_stream.h" |
| + |
| +#if !BUILDFLAG(ENABLE_BIDIRECTIONAL_STREAM) |
| +#error Only include this if ENABLE_BIDIRECTIONAL_STREAM is defined |
| +#endif |
|
Ryan Hamilton
2016/02/27 00:21:14
I am really not a fan of this conditional compilat
xunjieli
2016/02/29 15:21:37
We used build flag to exclude bidirectional stream
|
| + |
| +namespace base { |
| +class Timer; |
| +} // namespace base |
| + |
| +namespace net { |
| + |
| +class BoundNetLog; |
| +class IOBuffer; |
| +class SpdyHeaderBlock; |
| + |
| +class NET_EXPORT_PRIVATE BidirectionalStreamQuicJob |
| + : public BidirectionalStreamJob, |
|
Ryan Hamilton
2016/02/27 00:21:14
It doesn't seem like BidirectionalStreamJob really
xunjieli
2016/02/29 15:21:37
Done. I agree. I have changed the naming for new f
|
| + public QuicChromiumClientStream::Delegate, |
| + public QuicChromiumClientSession::Observer { |
| + public: |
| + explicit BidirectionalStreamQuicJob( |
| + const base::WeakPtr<QuicChromiumClientSession>& session); |
| + |
| + ~BidirectionalStreamQuicJob() override; |
| + |
| + // BidirectionalStreamJob implementation: |
| + void Start(const BidirectionalStreamRequestInfo* request_info, |
| + 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; |
| + |
| + private: |
| + // QuicChromiumClientStream::Delegate implementation: |
| + void OnHeadersAvailable(const SpdyHeaderBlock& headers, |
| + size_t frame_len) override; |
| + void OnDataAvailable() override; |
| + void OnClose(QuicErrorCode error) override; |
| + void OnError(int error) override; |
| + bool HasSendHeadersComplete() override; |
| + |
| + // QuicChromiumClientSession::Observer implementation: |
| + void OnCryptoHandshakeConfirmed() override; |
| + void OnSessionClosed(int error) override; |
| + |
| + void OnStreamReady(int rv); |
| + void OnSendDataComplete(int rv); |
| + void OnReadDataComplete(int rv); |
| + |
| + // Helper method to send request headers. |
| + void SendRequestHeaders(); |
| + // Notifies the delegate of an error. |
| + void NotifyError(int error); |
| + // Resets the stream and ensures that |delegate_| won't be called back. |
| + void ResetStream(); |
| + |
| + base::WeakPtr<QuicChromiumClientSession> session_; |
| + bool was_handshake_confirmed_; // True if the crypto handshake succeeded. |
| + QuicChromiumClientSession::StreamRequest stream_request_; |
| + QuicChromiumClientStream* stream_; // Non-owning. |
| + |
| + const BidirectionalStreamRequestInfo* request_info_; |
| + BidirectionalStreamJob::Delegate* delegate_; |
| + // Saves the response status if the stream is explicitly closed via OnError |
| + // or OnClose with an error. Once all buffered data has been returned, this |
| + // will be used as the final response. |
| + int response_status_; |
| + |
| + // The protocol that is negotiated. |
| + NextProto negotiated_protocol_; |
| + // User provided read buffer for ReadData() response. |
| + scoped_refptr<IOBuffer> read_buffer_; |
| + int read_buffer_len_; |
| + |
| + // Number of bytes received by the headers stream on behalf of this stream. |
| + int64_t headers_bytes_received_; |
| + // Number of bytes sent by the headers stream on behalf of this stream. |
| + int64_t headers_bytes_sent_; |
| + // After |stream_| has been closed, this keeps track of the total number of |
| + // 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_; |
| + // Indicates whether initial headers have been sent. |
| + bool has_sent_headers_; |
| + // Indicates whether initial headers have been received. |
| + bool has_received_headers_; |
| + |
| + base::WeakPtrFactory<BidirectionalStreamQuicJob> weak_factory_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(BidirectionalStreamQuicJob); |
| +}; |
| + |
| +} // namespace net |
| + |
| +#endif // NET_QUIC_BIDIRECTIONAL_STREAM_QUIC_JOB_H_ |