OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // HttpStreamBase is an interface for reading and writing data to an | 5 // HttpStreamBase is an interface for reading and writing data to an |
6 // HTTP-like stream that keeps the client agnostic of the actual underlying | 6 // HTTP-like stream that keeps the client agnostic of the actual underlying |
7 // transport layer. This provides an abstraction for HttpStream and | 7 // transport layer. This provides an abstraction for HttpStream and |
8 // WebSocketHandshakeStreamBase. | 8 // WebSocketHandshakeStreamBase. |
9 | 9 |
10 #ifndef NET_HTTP_HTTP_STREAM_BASE_H_ | 10 #ifndef NET_HTTP_HTTP_STREAM_BASE_H_ |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 // Reads response body data, up to |buf_len| bytes. |buf_len| should be a | 66 // Reads response body data, up to |buf_len| bytes. |buf_len| should be a |
67 // reasonable size (<2MB). The number of bytes read is returned, or an | 67 // reasonable size (<2MB). The number of bytes read is returned, or an |
68 // error is returned upon failure. 0 indicates that the request has been | 68 // error is returned upon failure. 0 indicates that the request has been |
69 // fully satisfied and there is no more data to read. | 69 // fully satisfied and there is no more data to read. |
70 // ERR_CONNECTION_CLOSED is returned when the connection has been closed | 70 // ERR_CONNECTION_CLOSED is returned when the connection has been closed |
71 // prematurely. ERR_IO_PENDING is returned if the operation could not be | 71 // prematurely. ERR_IO_PENDING is returned if the operation could not be |
72 // completed synchronously, in which case the result will be passed to the | 72 // completed synchronously, in which case the result will be passed to the |
73 // callback when available. If the operation is not completed immediately, | 73 // callback when available. If the operation is not completed immediately, |
74 // the socket acquires a reference to the provided buffer until the callback | 74 // the socket acquires a reference to the provided buffer until the callback |
75 // is invoked or the socket is destroyed. | 75 // is invoked or the socket is destroyed. |
76 virtual int ReadResponseBody(IOBuffer* buf, int buf_len, | 76 virtual int ReadResponseBody(IOBuffer* buf, |
| 77 int buf_len, |
77 const CompletionCallback& callback) = 0; | 78 const CompletionCallback& callback) = 0; |
78 | 79 |
79 // Closes the stream. | 80 // Closes the stream. |
80 // |not_reusable| indicates if the stream can be used for further requests. | 81 // |not_reusable| indicates if the stream can be used for further requests. |
81 // In the case of HTTP, where we re-use the byte-stream (e.g. the connection) | 82 // In the case of HTTP, where we re-use the byte-stream (e.g. the connection) |
82 // this means we need to close the connection; in the case of SPDY, where the | 83 // this means we need to close the connection; in the case of SPDY, where the |
83 // underlying stream is never reused, it has no effect. | 84 // underlying stream is never reused, it has no effect. |
84 // TODO(mbelshe): We should figure out how to fold the not_reusable flag | 85 // TODO(mbelshe): We should figure out how to fold the not_reusable flag |
85 // into the stream implementation itself so that the caller | 86 // into the stream implementation itself so that the caller |
86 // does not need to pass it at all. We might also be able to | 87 // does not need to pass it at all. We might also be able to |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 // Called when the priority of the parent transaction changes. | 148 // Called when the priority of the parent transaction changes. |
148 virtual void SetPriority(RequestPriority priority) = 0; | 149 virtual void SetPriority(RequestPriority priority) = 0; |
149 | 150 |
150 private: | 151 private: |
151 DISALLOW_COPY_AND_ASSIGN(HttpStreamBase); | 152 DISALLOW_COPY_AND_ASSIGN(HttpStreamBase); |
152 }; | 153 }; |
153 | 154 |
154 } // namespace net | 155 } // namespace net |
155 | 156 |
156 #endif // NET_HTTP_HTTP_STREAM_BASE_H_ | 157 #endif // NET_HTTP_HTTP_STREAM_BASE_H_ |
OLD | NEW |