OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef NET_QUIC_CHROMIUM_BIDIRECTIONAL_STREAM_QUIC_IMPL_H_ | 5 #ifndef NET_QUIC_CHROMIUM_BIDIRECTIONAL_STREAM_QUIC_IMPL_H_ |
6 #define NET_QUIC_CHROMIUM_BIDIRECTIONAL_STREAM_QUIC_IMPL_H_ | 6 #define NET_QUIC_CHROMIUM_BIDIRECTIONAL_STREAM_QUIC_IMPL_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
(...skipping 11 matching lines...) Expand all Loading... |
22 namespace base { | 22 namespace base { |
23 class Timer; | 23 class Timer; |
24 } // namespace base | 24 } // namespace base |
25 | 25 |
26 namespace net { | 26 namespace net { |
27 | 27 |
28 struct BidirectionalStreamRequestInfo; | 28 struct BidirectionalStreamRequestInfo; |
29 class IOBuffer; | 29 class IOBuffer; |
30 | 30 |
31 class NET_EXPORT_PRIVATE BidirectionalStreamQuicImpl | 31 class NET_EXPORT_PRIVATE BidirectionalStreamQuicImpl |
32 : public BidirectionalStreamImpl, | 32 : public BidirectionalStreamImpl { |
33 public QuicChromiumClientStream::Delegate { | |
34 public: | 33 public: |
35 explicit BidirectionalStreamQuicImpl( | 34 explicit BidirectionalStreamQuicImpl( |
36 std::unique_ptr<QuicChromiumClientSession::Handle> session); | 35 std::unique_ptr<QuicChromiumClientSession::Handle> session); |
37 | 36 |
38 ~BidirectionalStreamQuicImpl() override; | 37 ~BidirectionalStreamQuicImpl() override; |
39 | 38 |
40 // BidirectionalStreamImpl implementation: | 39 // BidirectionalStreamImpl implementation: |
41 void Start(const BidirectionalStreamRequestInfo* request_info, | 40 void Start(const BidirectionalStreamRequestInfo* request_info, |
42 const NetLogWithSource& net_log, | 41 const NetLogWithSource& net_log, |
43 bool send_request_headers_automatically, | 42 bool send_request_headers_automatically, |
44 BidirectionalStreamImpl::Delegate* delegate, | 43 BidirectionalStreamImpl::Delegate* delegate, |
45 std::unique_ptr<base::Timer> timer) override; | 44 std::unique_ptr<base::Timer> timer) override; |
46 void SendRequestHeaders() override; | 45 void SendRequestHeaders() override; |
47 int ReadData(IOBuffer* buffer, int buffer_len) override; | 46 int ReadData(IOBuffer* buffer, int buffer_len) override; |
48 void SendData(const scoped_refptr<IOBuffer>& data, | 47 void SendData(const scoped_refptr<IOBuffer>& data, |
49 int length, | 48 int length, |
50 bool end_stream) override; | 49 bool end_stream) override; |
51 void SendvData(const std::vector<scoped_refptr<IOBuffer>>& buffers, | 50 void SendvData(const std::vector<scoped_refptr<IOBuffer>>& buffers, |
52 const std::vector<int>& lengths, | 51 const std::vector<int>& lengths, |
53 bool end_stream) override; | 52 bool end_stream) override; |
54 NextProto GetProtocol() const override; | 53 NextProto GetProtocol() const override; |
55 int64_t GetTotalReceivedBytes() const override; | 54 int64_t GetTotalReceivedBytes() const override; |
56 int64_t GetTotalSentBytes() const override; | 55 int64_t GetTotalSentBytes() const override; |
57 bool GetLoadTimingInfo(LoadTimingInfo* load_timing_info) const override; | 56 bool GetLoadTimingInfo(LoadTimingInfo* load_timing_info) const override; |
58 | 57 |
59 private: | 58 private: |
60 // QuicChromiumClientStream::Delegate implementation: | 59 int WriteHeaders(); |
61 void OnClose() override; | |
62 void OnError(int error) override; | |
63 | |
64 // Write headers to the stream and returns true on success. Posts a task to | |
65 // notify the delegate asynchronously and returns false on failure | |
66 bool WriteHeaders(); | |
67 | |
68 void OnStreamReady(int rv); | 60 void OnStreamReady(int rv); |
69 void OnSendDataComplete(int rv); | 61 void OnSendDataComplete(int rv); |
70 void ReadInitialHeaders(); | 62 void ReadInitialHeaders(); |
71 void OnReadInitialHeadersComplete(int rv); | 63 void OnReadInitialHeadersComplete(int rv); |
72 void ReadTrailingHeaders(); | 64 void ReadTrailingHeaders(); |
73 void OnReadTrailingHeadersComplete(int rv); | 65 void OnReadTrailingHeadersComplete(int rv); |
74 void OnReadDataComplete(int rv); | 66 void OnReadDataComplete(int rv); |
75 | 67 |
76 // Notifies the delegate of an error, clears |stream_| and |delegate_|, | 68 // Notifies the delegate of an error, clears |stream_| and |delegate_|, |
77 // and cancels any pending callbacks. | 69 // and cancels any pending callbacks. |
(...skipping 20 matching lines...) Expand all Loading... |
98 // will be used as the final response. | 90 // will be used as the final response. |
99 int response_status_; | 91 int response_status_; |
100 | 92 |
101 // The protocol that is negotiated. | 93 // The protocol that is negotiated. |
102 NextProto negotiated_protocol_; | 94 NextProto negotiated_protocol_; |
103 // Connect timing information for this stream. Populated when headers are | 95 // Connect timing information for this stream. Populated when headers are |
104 // received. | 96 // received. |
105 LoadTimingInfo::ConnectTiming connect_timing_; | 97 LoadTimingInfo::ConnectTiming connect_timing_; |
106 | 98 |
107 SpdyHeaderBlock initial_headers_; | 99 SpdyHeaderBlock initial_headers_; |
| 100 bool expect_trailers_; // True if trailers are expected to arrive. |
108 SpdyHeaderBlock trailing_headers_; | 101 SpdyHeaderBlock trailing_headers_; |
109 | 102 |
110 // User provided read buffer for ReadData() response. | 103 // User provided read buffer for ReadData() response. |
111 scoped_refptr<IOBuffer> read_buffer_; | 104 scoped_refptr<IOBuffer> read_buffer_; |
112 int read_buffer_len_; | 105 int read_buffer_len_; |
113 | 106 |
114 // Number of bytes received by the headers stream on behalf of this stream. | 107 // Number of bytes received by the headers stream on behalf of this stream. |
115 int64_t headers_bytes_received_; | 108 int64_t headers_bytes_received_; |
116 // Number of bytes sent by the headers stream on behalf of this stream. | 109 // Number of bytes sent by the headers stream on behalf of this stream. |
117 int64_t headers_bytes_sent_; | 110 int64_t headers_bytes_sent_; |
(...skipping 20 matching lines...) Expand all Loading... |
138 bool may_invoke_callbacks_; | 131 bool may_invoke_callbacks_; |
139 | 132 |
140 base::WeakPtrFactory<BidirectionalStreamQuicImpl> weak_factory_; | 133 base::WeakPtrFactory<BidirectionalStreamQuicImpl> weak_factory_; |
141 | 134 |
142 DISALLOW_COPY_AND_ASSIGN(BidirectionalStreamQuicImpl); | 135 DISALLOW_COPY_AND_ASSIGN(BidirectionalStreamQuicImpl); |
143 }; | 136 }; |
144 | 137 |
145 } // namespace net | 138 } // namespace net |
146 | 139 |
147 #endif // NET_QUIC_CHROMIUM_BIDIRECTIONAL_STREAM_QUIC_IMPL_H_ | 140 #endif // NET_QUIC_CHROMIUM_BIDIRECTIONAL_STREAM_QUIC_IMPL_H_ |
OLD | NEW |