| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "net/base/completion_callback.h" | 12 #include "net/base/completion_callback.h" |
| 13 #include "net/base/net_log.h" | 13 #include "net/base/net_log.h" |
| 14 #include "net/base/upload_data_stream.h" | 14 #include "net/base/upload_data_stream.h" |
| 15 #include "net/http/http_chunked_decoder.h" | 15 #include "net/http/http_chunked_decoder.h" |
| 16 | 16 |
| 17 namespace net { | 17 namespace net { |
| 18 | 18 |
| 19 class ClientSocketHandle; | 19 class ClientSocketHandle; |
| 20 class DrainableIOBuffer; | 20 class DrainableIOBuffer; |
| 21 class GrowableIOBuffer; | 21 class GrowableIOBuffer; |
| 22 struct HttpRequestInfo; | 22 struct HttpRequestInfo; |
| 23 class HttpRequestHeaders; | 23 class HttpRequestHeaders; |
| 24 class HttpResponseInfo; | 24 class HttpResponseInfo; |
| 25 class IOBuffer; | 25 class IOBuffer; |
| 26 class SSLCertRequestInfo; | 26 class SSLCertRequestInfo; |
| 27 class SSLInfo; | 27 class SSLInfo; |
| 28 | 28 |
| 29 class HttpStreamParser { | 29 class HttpStreamParser : public UploadDataStream::ChunkCallback { |
| 30 public: | 30 public: |
| 31 // Any data in |read_buffer| will be used before reading from the socket | 31 // Any data in |read_buffer| will be used before reading from the socket |
| 32 // and any data left over after parsing the stream will be put into | 32 // and any data left over after parsing the stream will be put into |
| 33 // |read_buffer|. The left over data will start at offset 0 and the | 33 // |read_buffer|. The left over data will start at offset 0 and the |
| 34 // buffer's offset will be set to the first free byte. |read_buffer| may | 34 // buffer's offset will be set to the first free byte. |read_buffer| may |
| 35 // have its capacity changed. | 35 // have its capacity changed. |
| 36 HttpStreamParser(ClientSocketHandle* connection, | 36 HttpStreamParser(ClientSocketHandle* connection, |
| 37 const HttpRequestInfo* request, | 37 const HttpRequestInfo* request, |
| 38 GrowableIOBuffer* read_buffer, | 38 GrowableIOBuffer* read_buffer, |
| 39 const BoundNetLog& net_log); | 39 const BoundNetLog& net_log); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 64 bool IsMoreDataBuffered() const; | 64 bool IsMoreDataBuffered() const; |
| 65 | 65 |
| 66 bool IsConnectionReused() const; | 66 bool IsConnectionReused() const; |
| 67 | 67 |
| 68 void SetConnectionReused(); | 68 void SetConnectionReused(); |
| 69 | 69 |
| 70 void GetSSLInfo(SSLInfo* ssl_info); | 70 void GetSSLInfo(SSLInfo* ssl_info); |
| 71 | 71 |
| 72 void GetSSLCertRequestInfo(SSLCertRequestInfo* cert_request_info); | 72 void GetSSLCertRequestInfo(SSLCertRequestInfo* cert_request_info); |
| 73 | 73 |
| 74 // UploadDataStream::ChunkCallback methods. |
| 75 virtual void OnChunkAvailable(); |
| 76 |
| 74 private: | 77 private: |
| 75 // FOO_COMPLETE states implement the second half of potentially asynchronous | 78 // FOO_COMPLETE states implement the second half of potentially asynchronous |
| 76 // operations and don't necessarily mean that FOO is complete. | 79 // operations and don't necessarily mean that FOO is complete. |
| 77 enum State { | 80 enum State { |
| 78 STATE_NONE, | 81 STATE_NONE, |
| 79 STATE_SENDING_HEADERS, | 82 STATE_SENDING_HEADERS, |
| 80 STATE_SENDING_BODY, | 83 STATE_SENDING_BODY, |
| 81 STATE_REQUEST_SENT, | 84 STATE_REQUEST_SENT, |
| 82 STATE_READ_HEADERS, | 85 STATE_READ_HEADERS, |
| 83 STATE_READ_HEADERS_COMPLETE, | 86 STATE_READ_HEADERS_COMPLETE, |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 | 188 |
| 186 // Callback to be used when doing IO. | 189 // Callback to be used when doing IO. |
| 187 CompletionCallbackImpl<HttpStreamParser> io_callback_; | 190 CompletionCallbackImpl<HttpStreamParser> io_callback_; |
| 188 | 191 |
| 189 DISALLOW_COPY_AND_ASSIGN(HttpStreamParser); | 192 DISALLOW_COPY_AND_ASSIGN(HttpStreamParser); |
| 190 }; | 193 }; |
| 191 | 194 |
| 192 } // namespace net | 195 } // namespace net |
| 193 | 196 |
| 194 #endif // NET_HTTP_HTTP_STREAM_PARSER_H_ | 197 #endif // NET_HTTP_HTTP_STREAM_PARSER_H_ |
| OLD | NEW |