Chromium Code Reviews| 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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 115 virtual bool IsConnectionReused() const = 0; | 115 virtual bool IsConnectionReused() const = 0; |
| 116 virtual void SetConnectionReused() = 0; | 116 virtual void SetConnectionReused() = 0; |
| 117 | 117 |
| 118 // Checks whether the current state of the underlying connection | 118 // Checks whether the current state of the underlying connection |
| 119 // allows it to be reused. | 119 // allows it to be reused. |
| 120 virtual bool IsConnectionReusable() const = 0; | 120 virtual bool IsConnectionReusable() const = 0; |
| 121 | 121 |
| 122 // Get the total number of bytes received from network for this stream. | 122 // Get the total number of bytes received from network for this stream. |
| 123 virtual int64 GetTotalReceivedBytes() const = 0; | 123 virtual int64 GetTotalReceivedBytes() const = 0; |
| 124 | 124 |
| 125 // Get the total number of body bytes received from network for this stream. | |
| 126 virtual int64 GetReceivedBodyLength() const = 0; | |
|
mmenke
2014/07/22 14:57:41
Why are these in the HttpStreamBase class, and not
jonnyr
2014/07/23 08:43:05
I could not do this in HttpNetworkTransaction sinc
mmenke
2014/07/23 15:08:40
I'm not following why this doesn't work. In HttpN
| |
| 127 | |
| 125 // Populates the connection establishment part of |load_timing_info|, and | 128 // Populates the connection establishment part of |load_timing_info|, and |
| 126 // socket ID. |load_timing_info| must have all null times when called. | 129 // socket ID. |load_timing_info| must have all null times when called. |
| 127 // Returns false and does nothing if there is no underlying connection, either | 130 // Returns false and does nothing if there is no underlying connection, either |
| 128 // because one has yet to be assigned to the stream, or because the underlying | 131 // because one has yet to be assigned to the stream, or because the underlying |
| 129 // socket has been closed. | 132 // socket has been closed. |
| 130 // | 133 // |
| 131 // In practice, this means that this function will always succeed any time | 134 // In practice, this means that this function will always succeed any time |
| 132 // between when the full headers have been received and the stream has been | 135 // between when the full headers have been received and the stream has been |
| 133 // closed. | 136 // closed. |
| 134 virtual bool GetLoadTimingInfo(LoadTimingInfo* load_timing_info) const = 0; | 137 virtual bool GetLoadTimingInfo(LoadTimingInfo* load_timing_info) const = 0; |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 149 | 152 |
| 150 // In the case of an HTTP error or redirect, flush the response body (usually | 153 // In the case of an HTTP error or redirect, flush the response body (usually |
| 151 // a simple error or "this page has moved") so that we can re-use the | 154 // a simple error or "this page has moved") so that we can re-use the |
| 152 // underlying connection. This stream is responsible for deleting itself when | 155 // underlying connection. This stream is responsible for deleting itself when |
| 153 // draining is complete. | 156 // draining is complete. |
| 154 virtual void Drain(HttpNetworkSession* session) = 0; | 157 virtual void Drain(HttpNetworkSession* session) = 0; |
| 155 | 158 |
| 156 // Called when the priority of the parent transaction changes. | 159 // Called when the priority of the parent transaction changes. |
| 157 virtual void SetPriority(RequestPriority priority) = 0; | 160 virtual void SetPriority(RequestPriority priority) = 0; |
| 158 | 161 |
| 162 // If restarting a request where a part of the body has already been | |
| 163 // received, set where we should start reading from, previous content length | |
| 164 // and hash of previous response. | |
| 165 virtual void SetRestartInfo(int64 read_offset, const void* hash, | |
| 166 size_t hash_length) = 0; | |
| 167 | |
| 168 // If restarting a request where a part of the body has already been received, | |
| 169 // retrieve the hash so that this can be verified on retry. | |
| 170 virtual void GetHash(void* output, size_t hash_length) = 0; | |
| 171 | |
| 159 private: | 172 private: |
| 160 DISALLOW_COPY_AND_ASSIGN(HttpStreamBase); | 173 DISALLOW_COPY_AND_ASSIGN(HttpStreamBase); |
| 161 }; | 174 }; |
| 162 | 175 |
| 163 } // namespace net | 176 } // namespace net |
| 164 | 177 |
| 165 #endif // NET_HTTP_HTTP_STREAM_BASE_H_ | 178 #endif // NET_HTTP_HTTP_STREAM_BASE_H_ |
| OLD | NEW |