| 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 #ifndef NET_HTTP_HTTP_STREAM_PARSER_H_ | 5 #ifndef NET_HTTP_HTTP_STREAM_PARSER_H_ |
| 6 #define NET_HTTP_HTTP_STREAM_PARSER_H_ | 6 #define NET_HTTP_HTTP_STREAM_PARSER_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| 11 #include <memory> | 11 #include <memory> |
| 12 #include <string> | 12 #include <string> |
| 13 | 13 |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
| 16 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
| 17 #include "base/strings/string_piece.h" | 17 #include "base/strings/string_piece.h" |
| 18 #include "crypto/ec_private_key.h" | 18 #include "crypto/ec_private_key.h" |
| 19 #include "net/base/completion_callback.h" | 19 #include "net/base/completion_callback.h" |
| 20 #include "net/base/net_errors.h" | 20 #include "net/base/net_errors.h" |
| 21 #include "net/base/net_export.h" | 21 #include "net/base/net_export.h" |
| 22 #include "net/base/upload_progress.h" | |
| 23 #include "net/log/net_log.h" | 22 #include "net/log/net_log.h" |
| 24 | 23 |
| 25 namespace net { | 24 namespace net { |
| 26 | 25 |
| 27 class ClientSocketHandle; | 26 class ClientSocketHandle; |
| 28 class DrainableIOBuffer; | 27 class DrainableIOBuffer; |
| 29 class GrowableIOBuffer; | 28 class GrowableIOBuffer; |
| 30 class HttpChunkedDecoder; | 29 class HttpChunkedDecoder; |
| 31 struct HttpRequestInfo; | 30 struct HttpRequestInfo; |
| 32 class HttpRequestHeaders; | 31 class HttpRequestHeaders; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 HttpResponseInfo* response, | 64 HttpResponseInfo* response, |
| 66 const CompletionCallback& callback); | 65 const CompletionCallback& callback); |
| 67 | 66 |
| 68 int ReadResponseHeaders(const CompletionCallback& callback); | 67 int ReadResponseHeaders(const CompletionCallback& callback); |
| 69 | 68 |
| 70 int ReadResponseBody(IOBuffer* buf, int buf_len, | 69 int ReadResponseBody(IOBuffer* buf, int buf_len, |
| 71 const CompletionCallback& callback); | 70 const CompletionCallback& callback); |
| 72 | 71 |
| 73 void Close(bool not_reusable); | 72 void Close(bool not_reusable); |
| 74 | 73 |
| 75 // Returns the progress of uploading. When data is chunked, size is set to | |
| 76 // zero, but position will not be. | |
| 77 UploadProgress GetUploadProgress() const; | |
| 78 | |
| 79 bool IsResponseBodyComplete() const; | 74 bool IsResponseBodyComplete() const; |
| 80 | 75 |
| 81 bool CanFindEndOfResponse() const; | 76 bool CanFindEndOfResponse() const; |
| 82 | 77 |
| 83 bool IsMoreDataBuffered() const; | 78 bool IsMoreDataBuffered() const; |
| 84 | 79 |
| 85 bool IsConnectionReused() const; | 80 bool IsConnectionReused() const; |
| 86 | 81 |
| 87 void SetConnectionReused(); | 82 void SetConnectionReused(); |
| 88 | 83 |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 | 192 |
| 198 // Examine the parsed headers to try to determine the response body size. | 193 // Examine the parsed headers to try to determine the response body size. |
| 199 void CalculateResponseBodySize(); | 194 void CalculateResponseBodySize(); |
| 200 | 195 |
| 201 // Uploads statistics about status line compliance with RFC 7230. | 196 // Uploads statistics about status line compliance with RFC 7230. |
| 202 void ValidateStatusLine(const std::string& status_line); | 197 void ValidateStatusLine(const std::string& status_line); |
| 203 | 198 |
| 204 // Check if buffers used to send the request are empty. | 199 // Check if buffers used to send the request are empty. |
| 205 bool SendRequestBuffersEmpty(); | 200 bool SendRequestBuffersEmpty(); |
| 206 | 201 |
| 202 // Sets request_ to null. |
| 203 void ResetRequestInfo(); |
| 204 |
| 207 // Next state of the request, when the current one completes. | 205 // Next state of the request, when the current one completes. |
| 208 State io_state_; | 206 State io_state_; |
| 209 | 207 |
| 210 // The request to send. | 208 // Null when read state machine is invoked. This is to allow the stream |
| 209 // to be shared for reading and to possibly outlive request_'s owner. |
| 211 const HttpRequestInfo* request_; | 210 const HttpRequestInfo* request_; |
| 212 | 211 |
| 213 // The request header data. May include a merged request body. | 212 // The request header data. May include a merged request body. |
| 214 scoped_refptr<DrainableIOBuffer> request_headers_; | 213 scoped_refptr<DrainableIOBuffer> request_headers_; |
| 215 | 214 |
| 216 // Size of just the request headers. May be less than the length of | 215 // Size of just the request headers. May be less than the length of |
| 217 // |request_headers_| if the body was merged with the headers. | 216 // |request_headers_| if the body was merged with the headers. |
| 218 int request_headers_length_; | 217 int request_headers_length_; |
| 219 | 218 |
| 220 // True if HTTP/0.9 should be permitted on non-default ports. | 219 // True if HTTP/0.9 should be permitted on non-default ports. |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 int upload_error_; | 291 int upload_error_; |
| 293 | 292 |
| 294 base::WeakPtrFactory<HttpStreamParser> weak_ptr_factory_; | 293 base::WeakPtrFactory<HttpStreamParser> weak_ptr_factory_; |
| 295 | 294 |
| 296 DISALLOW_COPY_AND_ASSIGN(HttpStreamParser); | 295 DISALLOW_COPY_AND_ASSIGN(HttpStreamParser); |
| 297 }; | 296 }; |
| 298 | 297 |
| 299 } // namespace net | 298 } // namespace net |
| 300 | 299 |
| 301 #endif // NET_HTTP_HTTP_STREAM_PARSER_H_ | 300 #endif // NET_HTTP_HTTP_STREAM_PARSER_H_ |
| OLD | NEW |