Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/string_piece.h" | |
| 12 #include "net/base/completion_callback.h" | 13 #include "net/base/completion_callback.h" |
| 13 #include "net/base/net_log.h" | 14 #include "net/base/net_log.h" |
| 14 #include "net/base/upload_data_stream.h" | 15 #include "net/base/upload_data_stream.h" |
| 15 #include "net/http/http_chunked_decoder.h" | 16 #include "net/http/http_chunked_decoder.h" |
| 16 | 17 |
| 17 namespace net { | 18 namespace net { |
| 18 | 19 |
| 19 class ClientSocketHandle; | 20 class ClientSocketHandle; |
| 20 class DrainableIOBuffer; | 21 class DrainableIOBuffer; |
| 21 class GrowableIOBuffer; | 22 class GrowableIOBuffer; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 70 | 71 |
| 71 bool IsConnectionReusable() const; | 72 bool IsConnectionReusable() const; |
| 72 | 73 |
| 73 void GetSSLInfo(SSLInfo* ssl_info); | 74 void GetSSLInfo(SSLInfo* ssl_info); |
| 74 | 75 |
| 75 void GetSSLCertRequestInfo(SSLCertRequestInfo* cert_request_info); | 76 void GetSSLCertRequestInfo(SSLCertRequestInfo* cert_request_info); |
| 76 | 77 |
| 77 // ChunkCallback methods. | 78 // ChunkCallback methods. |
| 78 virtual void OnChunkAvailable() OVERRIDE; | 79 virtual void OnChunkAvailable() OVERRIDE; |
| 79 | 80 |
| 81 // Encodes the given |payload| in the chunked format to |output|. | |
| 82 // Returns the number of bytes written to |output|. |output_size| should | |
| 83 // be large enough to store the encoded chunk, which is payload.size() + | |
| 84 // kChunkHeaderFooterSize. Returns -1 if |output_size| is not large | |
|
wtc
2012/01/18 22:49:24
Instead of -1, you can return a network error code
satorux1
2012/01/18 23:42:30
Good idea. I chose to use ERR_FAILED.
satorux1
2012/01/18 23:44:02
Changed it to ERR_INVALID_ARGUMENT as it sounded a
| |
| 85 // enough. | |
| 86 // | |
| 87 // The output will look like: "HEX\r\n[payload]\r\n". | |
|
wtc
2012/01/18 22:49:24
Nit: should explain what HEX is. For example,
w
satorux1
2012/01/18 23:42:30
Good idea. Done.
| |
| 88 static int EncodeChunk(const base::StringPiece& payload, | |
| 89 char* output, | |
| 90 size_t output_size); | |
| 91 | |
| 92 // The number of extra bytes required to encode a chunk. | |
| 93 static const int kChunkHeaderFooterSize; | |
|
wtc
2012/01/18 22:49:24
This constant should have the type size_t.
satorux1
2012/01/18 23:42:30
Done.
| |
| 94 | |
| 80 private: | 95 private: |
| 81 // FOO_COMPLETE states implement the second half of potentially asynchronous | 96 // FOO_COMPLETE states implement the second half of potentially asynchronous |
| 82 // operations and don't necessarily mean that FOO is complete. | 97 // operations and don't necessarily mean that FOO is complete. |
| 83 enum State { | 98 enum State { |
| 84 STATE_NONE, | 99 STATE_NONE, |
| 85 STATE_SENDING_HEADERS, | 100 STATE_SENDING_HEADERS, |
| 86 STATE_SENDING_BODY, | 101 STATE_SENDING_BODY, |
| 87 STATE_REQUEST_SENT, | 102 STATE_REQUEST_SENT, |
| 88 STATE_READ_HEADERS, | 103 STATE_READ_HEADERS, |
| 89 STATE_READ_HEADERS_COMPLETE, | 104 STATE_READ_HEADERS_COMPLETE, |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 198 size_t chunk_length_; | 213 size_t chunk_length_; |
| 199 size_t chunk_length_without_encoding_; | 214 size_t chunk_length_without_encoding_; |
| 200 bool sent_last_chunk_; | 215 bool sent_last_chunk_; |
| 201 | 216 |
| 202 DISALLOW_COPY_AND_ASSIGN(HttpStreamParser); | 217 DISALLOW_COPY_AND_ASSIGN(HttpStreamParser); |
| 203 }; | 218 }; |
| 204 | 219 |
| 205 } // namespace net | 220 } // namespace net |
| 206 | 221 |
| 207 #endif // NET_HTTP_HTTP_STREAM_PARSER_H_ | 222 #endif // NET_HTTP_HTTP_STREAM_PARSER_H_ |
| OLD | NEW |