Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Side by Side Diff: net/http/http_network_transaction.h

Issue 87073: Extend the use of IOBuffers to the code underneath... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/base/tcp_client_socket_win.cc ('k') | net/http/http_network_transaction.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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_NETWORK_TRANSACTION_H_ 5 #ifndef NET_HTTP_HTTP_NETWORK_TRANSACTION_H_
6 #define NET_HTTP_HTTP_NETWORK_TRANSACTION_H_ 6 #define NET_HTTP_HTTP_NETWORK_TRANSACTION_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/ref_counted.h" 10 #include "base/ref_counted.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 } 48 }
49 49
50 virtual int Read(IOBuffer* buf, int buf_len, CompletionCallback* callback); 50 virtual int Read(IOBuffer* buf, int buf_len, CompletionCallback* callback);
51 virtual const HttpResponseInfo* GetResponseInfo() const; 51 virtual const HttpResponseInfo* GetResponseInfo() const;
52 virtual LoadState GetLoadState() const; 52 virtual LoadState GetLoadState() const;
53 virtual uint64 GetUploadProgress() const; 53 virtual uint64 GetUploadProgress() const;
54 54
55 private: 55 private:
56 FRIEND_TEST(HttpNetworkTransactionTest, ResetStateForRestart); 56 FRIEND_TEST(HttpNetworkTransactionTest, ResetStateForRestart);
57 57
58 // This version of IOBuffer lets us use a string as the real storage and
59 // "move" the data pointer inside the string before using it to do actual IO.
60 class RequestHeaders : public net::IOBuffer {
61 public:
62 RequestHeaders() : net::IOBuffer() {}
63 ~RequestHeaders() { data_ = NULL; }
64
65 void SetDataOffset(size_t offset) {
66 data_ = const_cast<char*>(headers_.data()) + offset;
67 }
68
69 // This is intentionally a public member.
70 std::string headers_;
71 };
72
73 // This version of IOBuffer lets us use a malloc'ed buffer as the real storage
74 // and "move" the data pointer inside the buffer before using it to do actual
75 // IO.
76 class ResponseHeaders : public net::IOBuffer {
77 public:
78 ResponseHeaders() : net::IOBuffer() {}
79 ~ResponseHeaders() { data_ = NULL; }
80
81 void set_data(size_t offset) { data_ = headers_.get() + offset; }
82 char* headers() { return headers_.get(); }
83 void Reset() { headers_.reset(); }
84 void Realloc(size_t new_size);
85
86 private:
87 scoped_ptr_malloc<char> headers_;
88 };
89
58 void BuildRequestHeaders(); 90 void BuildRequestHeaders();
59 void BuildTunnelRequest(); 91 void BuildTunnelRequest();
60 void DoCallback(int result); 92 void DoCallback(int result);
61 void OnIOComplete(int result); 93 void OnIOComplete(int result);
62 94
63 // Runs the state transition loop. 95 // Runs the state transition loop.
64 int DoLoop(int result); 96 int DoLoop(int result);
65 97
66 // Each of these methods corresponds to a State value. Those with an input 98 // Each of these methods corresponds to a State value. Those with an input
67 // argument receive the result from the previous state. If a method returns 99 // argument receive the result from the previous state. If a method returns
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 // 297 //
266 // TODO(wtc): this is similar to the |ignore_ok_result_| member of the 298 // TODO(wtc): this is similar to the |ignore_ok_result_| member of the
267 // SSLClientSocketWin class. We may want to add an internal error code, say 299 // SSLClientSocketWin class. We may want to add an internal error code, say
268 // ERR_EOF, to indicate a connection closure, so that 0 simply means 0 bytes 300 // ERR_EOF, to indicate a connection closure, so that 0 simply means 0 bytes
269 // or OK. Note that we already have an ERR_CONNECTION_CLOSED error code, 301 // or OK. Note that we already have an ERR_CONNECTION_CLOSED error code,
270 // but it isn't really being used. 302 // but it isn't really being used.
271 bool reading_body_from_socket_; 303 bool reading_body_from_socket_;
272 304
273 SSLConfig ssl_config_; 305 SSLConfig ssl_config_;
274 306
275 std::string request_headers_; 307 scoped_refptr<RequestHeaders> request_headers_;
276 size_t request_headers_bytes_sent_; 308 size_t request_headers_bytes_sent_;
277 scoped_ptr<UploadDataStream> request_body_stream_; 309 scoped_ptr<UploadDataStream> request_body_stream_;
310 scoped_refptr<IOBuffer> write_buffer_;
278 311
279 // The read buffer may be larger than it is full. The 'capacity' indicates 312 // The read buffer may be larger than it is full. The 'capacity' indicates
280 // the allocation size of the buffer, and the 'len' indicates how much data 313 // the allocation size of the buffer, and the 'len' indicates how much data
281 // is in the buffer already. The 'body offset' indicates the offset of the 314 // is in the buffer already. The 'body offset' indicates the offset of the
282 // start of the response body within the read buffer. 315 // start of the response body within the read buffer.
283 scoped_ptr_malloc<char> header_buf_; 316 scoped_refptr<ResponseHeaders> header_buf_;
284 int header_buf_capacity_; 317 int header_buf_capacity_;
285 int header_buf_len_; 318 int header_buf_len_;
286 int header_buf_body_offset_; 319 int header_buf_body_offset_;
287 320
288 // The number of bytes by which the header buffer is grown when it reaches 321 // The number of bytes by which the header buffer is grown when it reaches
289 // capacity. 322 // capacity.
290 enum { kHeaderBufInitialSize = 4096 }; 323 enum { kHeaderBufInitialSize = 4096 };
291 324
292 // |kMaxHeaderBufSize| is the number of bytes that the response headers can 325 // |kMaxHeaderBufSize| is the number of bytes that the response headers can
293 // grow to. If the body start is not found within this range of the 326 // grow to. If the body start is not found within this range of the
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 STATE_DRAIN_BODY_FOR_AUTH_RESTART, 378 STATE_DRAIN_BODY_FOR_AUTH_RESTART,
346 STATE_DRAIN_BODY_FOR_AUTH_RESTART_COMPLETE, 379 STATE_DRAIN_BODY_FOR_AUTH_RESTART_COMPLETE,
347 STATE_NONE 380 STATE_NONE
348 }; 381 };
349 State next_state_; 382 State next_state_;
350 }; 383 };
351 384
352 } // namespace net 385 } // namespace net
353 386
354 #endif // NET_HTTP_HTTP_NETWORK_TRANSACTION_H_ 387 #endif // NET_HTTP_HTTP_NETWORK_TRANSACTION_H_
OLDNEW
« no previous file with comments | « net/base/tcp_client_socket_win.cc ('k') | net/http/http_network_transaction.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698