| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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_HTTP_BIDIRECTIONAL_STREAM_IMPL_H_ | 5 #ifndef NET_HTTP_BIDIRECTIONAL_STREAM_IMPL_H_ |
| 6 #define NET_HTTP_BIDIRECTIONAL_STREAM_IMPL_H_ | 6 #define NET_HTTP_BIDIRECTIONAL_STREAM_IMPL_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 class NET_EXPORT_PRIVATE Delegate { | 36 class NET_EXPORT_PRIVATE Delegate { |
| 37 public: | 37 public: |
| 38 Delegate(); | 38 Delegate(); |
| 39 | 39 |
| 40 // Called when the stream is ready for reading and writing. | 40 // Called when the stream is ready for reading and writing. |
| 41 // The delegate may call BidirectionalStreamImpl::ReadData to start reading, | 41 // The delegate may call BidirectionalStreamImpl::ReadData to start reading, |
| 42 // call BidirectionalStreamImpl::SendData to send data, | 42 // call BidirectionalStreamImpl::SendData to send data, |
| 43 // or call BidirectionalStreamImpl::Cancel to cancel the stream. | 43 // or call BidirectionalStreamImpl::Cancel to cancel the stream. |
| 44 // The delegate should not call BidirectionalStreamImpl::Cancel | 44 // The delegate should not call BidirectionalStreamImpl::Cancel |
| 45 // during this callback. | 45 // during this callback. |
| 46 virtual void OnStreamReady() = 0; | 46 // |request_headers_sent| if true, request headers have been sent. If false, |
| 47 // SendRequestHeaders() needs to be explicitly called. |
| 48 virtual void OnStreamReady(bool request_headers_sent) = 0; |
| 47 | 49 |
| 48 // Called when response headers are received. | 50 // Called when response headers are received. |
| 49 // This is called at most once for the lifetime of a stream. | 51 // This is called at most once for the lifetime of a stream. |
| 50 // The delegate may call BidirectionalStreamImpl::ReadData to start | 52 // The delegate may call BidirectionalStreamImpl::ReadData to start |
| 51 // reading, call BidirectionalStreamImpl::SendData to send data, | 53 // reading, call BidirectionalStreamImpl::SendData to send data, |
| 52 // or call BidirectionalStreamImpl::Cancel to cancel the stream. | 54 // or call BidirectionalStreamImpl::Cancel to cancel the stream. |
| 53 virtual void OnHeadersReceived(const SpdyHeaderBlock& response_headers) = 0; | 55 virtual void OnHeadersReceived(const SpdyHeaderBlock& response_headers) = 0; |
| 54 | 56 |
| 55 // Called when read is completed asynchronously. |bytes_read| specifies how | 57 // Called when read is completed asynchronously. |bytes_read| specifies how |
| 56 // much data is available. | 58 // much data is available. |
| (...skipping 26 matching lines...) Expand all Loading... |
| 83 DISALLOW_COPY_AND_ASSIGN(Delegate); | 85 DISALLOW_COPY_AND_ASSIGN(Delegate); |
| 84 }; | 86 }; |
| 85 | 87 |
| 86 BidirectionalStreamImpl(); | 88 BidirectionalStreamImpl(); |
| 87 | 89 |
| 88 // |this| should not be destroyed during Delegate::OnHeadersSent or | 90 // |this| should not be destroyed during Delegate::OnHeadersSent or |
| 89 // Delegate::OnDataSent. | 91 // Delegate::OnDataSent. |
| 90 virtual ~BidirectionalStreamImpl(); | 92 virtual ~BidirectionalStreamImpl(); |
| 91 | 93 |
| 92 // Starts the BidirectionalStreamImpl and sends request headers. | 94 // Starts the BidirectionalStreamImpl and sends request headers. |
| 95 // |send_request_headers_automatically| if true, request headers will be sent |
| 96 // automatically when stream is negotiated. If false, request headers will be |
| 97 // sent only when SendRequestHeaders() is invoked or with next |
| 98 // SendData/SendvData. |
| 93 virtual void Start(const BidirectionalStreamRequestInfo* request_info, | 99 virtual void Start(const BidirectionalStreamRequestInfo* request_info, |
| 94 const BoundNetLog& net_log, | 100 const BoundNetLog& net_log, |
| 95 bool disable_auto_flush, | 101 bool send_request_headers_automatically, |
| 96 BidirectionalStreamImpl::Delegate* delegate, | 102 BidirectionalStreamImpl::Delegate* delegate, |
| 97 std::unique_ptr<base::Timer> timer) = 0; | 103 std::unique_ptr<base::Timer> timer) = 0; |
| 98 | 104 |
| 105 // Sends request headers to server. |
| 106 // When |send_request_headers_automatically_| is |
| 107 // false and OnStreamReady() is invoked with request_headers_sent = false, |
| 108 // headers will be combined with next SendData/SendvData unless this |
| 109 // method is called first, in which case headers will be sent separately |
| 110 // without delay. |
| 111 // (This method cannot be called when |send_request_headers_automatically_| is |
| 112 // true nor when OnStreamReady() is invoked with request_headers_sent = true, |
| 113 // since headers have been sent by the stream when stream is negotiated |
| 114 // successfully.) |
| 115 virtual void SendRequestHeaders() = 0; |
| 116 |
| 99 // Reads at most |buf_len| bytes into |buf|. Returns the number of bytes read, | 117 // Reads at most |buf_len| bytes into |buf|. Returns the number of bytes read, |
| 100 // ERR_IO_PENDING if the read is to be completed asynchronously, or an error | 118 // ERR_IO_PENDING if the read is to be completed asynchronously, or an error |
| 101 // code if any error occurred. If returns 0, there is no more data to read. | 119 // code if any error occurred. If returns 0, there is no more data to read. |
| 102 // This should not be called before Delegate::OnHeadersReceived is invoked, | 120 // This should not be called before Delegate::OnHeadersReceived is invoked, |
| 103 // and should not be called again unless it returns with number greater than | 121 // and should not be called again unless it returns with number greater than |
| 104 // 0 or until Delegate::OnDataRead is invoked. | 122 // 0 or until Delegate::OnDataRead is invoked. |
| 105 virtual int ReadData(IOBuffer* buf, int buf_len) = 0; | 123 virtual int ReadData(IOBuffer* buf, int buf_len) = 0; |
| 106 | 124 |
| 107 // Sends data. This should not be called be called before | 125 // Sends data. This should not be called be called before |
| 108 // Delegate::OnHeadersSent is invoked, and should not be called again until | 126 // Delegate::OnHeadersSent is invoked, and should not be called again until |
| (...skipping 26 matching lines...) Expand all Loading... |
| 135 // not associated with any stream, and are not included in this value. | 153 // not associated with any stream, and are not included in this value. |
| 136 virtual int64_t GetTotalSentBytes() const = 0; | 154 virtual int64_t GetTotalSentBytes() const = 0; |
| 137 | 155 |
| 138 private: | 156 private: |
| 139 DISALLOW_COPY_AND_ASSIGN(BidirectionalStreamImpl); | 157 DISALLOW_COPY_AND_ASSIGN(BidirectionalStreamImpl); |
| 140 }; | 158 }; |
| 141 | 159 |
| 142 } // namespace net | 160 } // namespace net |
| 143 | 161 |
| 144 #endif // NET_HTTP_BIDIRECTIONAL_STREAM_IMPL_H_ | 162 #endif // NET_HTTP_BIDIRECTIONAL_STREAM_IMPL_H_ |
| OLD | NEW |