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 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "net/base/io_buffer.h" | 11 #include "net/base/io_buffer.h" |
12 #include "net/base/load_log.h" | 12 #include "net/base/net_log.h" |
13 #include "net/base/upload_data_stream.h" | 13 #include "net/base/upload_data_stream.h" |
14 #include "net/http/http_chunked_decoder.h" | 14 #include "net/http/http_chunked_decoder.h" |
15 #include "net/http/http_response_info.h" | 15 #include "net/http/http_response_info.h" |
16 #include "net/socket/client_socket_handle.h" | 16 #include "net/socket/client_socket_handle.h" |
17 | 17 |
18 namespace net { | 18 namespace net { |
19 | 19 |
20 class ClientSocketHandle; | 20 class ClientSocketHandle; |
21 class HttpRequestInfo; | 21 class HttpRequestInfo; |
22 | 22 |
23 class HttpStreamParser { | 23 class HttpStreamParser { |
24 public: | 24 public: |
25 // Any data in |read_buffer| will be used before reading from the socket | 25 // Any data in |read_buffer| will be used before reading from the socket |
26 // and any data left over after parsing the stream will be put into | 26 // and any data left over after parsing the stream will be put into |
27 // |read_buffer|. The left over data will start at offset 0 and the | 27 // |read_buffer|. The left over data will start at offset 0 and the |
28 // buffer's offset will be set to the first free byte. |read_buffer| may | 28 // buffer's offset will be set to the first free byte. |read_buffer| may |
29 // have its capacity changed. | 29 // have its capacity changed. |
30 HttpStreamParser(ClientSocketHandle* connection, | 30 HttpStreamParser(ClientSocketHandle* connection, |
31 GrowableIOBuffer* read_buffer, | 31 GrowableIOBuffer* read_buffer, |
32 LoadLog* load_log); | 32 const BoundNetLog& net_log); |
33 ~HttpStreamParser() {} | 33 ~HttpStreamParser() {} |
34 | 34 |
35 // These functions implement the interface described in HttpStream with | 35 // These functions implement the interface described in HttpStream with |
36 // some additional functionality | 36 // some additional functionality |
37 int SendRequest(const HttpRequestInfo* request, const std::string& headers, | 37 int SendRequest(const HttpRequestInfo* request, const std::string& headers, |
38 UploadDataStream* request_body, HttpResponseInfo* response, | 38 UploadDataStream* request_body, HttpResponseInfo* response, |
39 CompletionCallback* callback); | 39 CompletionCallback* callback); |
40 | 40 |
41 int ReadResponseHeaders(CompletionCallback* callback); | 41 int ReadResponseHeaders(CompletionCallback* callback); |
42 | 42 |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 | 155 |
156 // In the client callback, the client can do anything, including | 156 // In the client callback, the client can do anything, including |
157 // destroying this class, so any pending callback must be issued | 157 // destroying this class, so any pending callback must be issued |
158 // after everything else is done. When it is time to issue the client | 158 // after everything else is done. When it is time to issue the client |
159 // callback, move it from |user_callback_| to |scheduled_callback_|. | 159 // callback, move it from |user_callback_| to |scheduled_callback_|. |
160 CompletionCallback* scheduled_callback_; | 160 CompletionCallback* scheduled_callback_; |
161 | 161 |
162 // The underlying socket. | 162 // The underlying socket. |
163 ClientSocketHandle* const connection_; | 163 ClientSocketHandle* const connection_; |
164 | 164 |
165 scoped_refptr<LoadLog> load_log_; | 165 BoundNetLog net_log_; |
166 | 166 |
167 // Callback to be used when doing IO. | 167 // Callback to be used when doing IO. |
168 CompletionCallbackImpl<HttpStreamParser> io_callback_; | 168 CompletionCallbackImpl<HttpStreamParser> io_callback_; |
169 | 169 |
170 DISALLOW_COPY_AND_ASSIGN(HttpStreamParser); | 170 DISALLOW_COPY_AND_ASSIGN(HttpStreamParser); |
171 }; | 171 }; |
172 | 172 |
173 } // namespace net | 173 } // namespace net |
174 | 174 |
175 #endif // NET_HTTP_HTTP_STREAM_PARSER_H_ | 175 #endif // NET_HTTP_HTTP_STREAM_PARSER_H_ |
OLD | NEW |