OLD | NEW |
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" |
11 #include "base/scoped_ptr.h" | 11 #include "base/scoped_ptr.h" |
12 #include "base/time.h" | 12 #include "base/time.h" |
13 #include "net/base/address_list.h" | 13 #include "net/base/address_list.h" |
14 #include "net/base/client_socket_handle.h" | 14 #include "net/base/client_socket_handle.h" |
15 #include "net/base/client_socket_pool.h" | |
16 #include "net/base/host_resolver.h" | 15 #include "net/base/host_resolver.h" |
17 #include "net/base/load_flags.h" | |
18 #include "net/base/load_states.h" | |
19 #include "net/base/ssl_config_service.h" | 16 #include "net/base/ssl_config_service.h" |
20 #include "net/http/http_auth.h" | 17 #include "net/http/http_auth.h" |
21 #include "net/http/http_auth_handler.h" | 18 #include "net/http/http_auth_handler.h" |
22 #include "net/http/http_response_info.h" | 19 #include "net/http/http_response_info.h" |
23 #include "net/http/http_transaction.h" | 20 #include "net/http/http_transaction.h" |
24 #include "net/proxy/proxy_service.h" | 21 #include "net/proxy/proxy_service.h" |
25 #include "testing/gtest/include/gtest/gtest_prod.h" | 22 #include "testing/gtest/include/gtest/gtest_prod.h" |
26 | 23 |
27 namespace net { | 24 namespace net { |
28 | 25 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 | 80 |
84 void set_data(size_t offset) { data_ = headers_.get() + offset; } | 81 void set_data(size_t offset) { data_ = headers_.get() + offset; } |
85 char* headers() { return headers_.get(); } | 82 char* headers() { return headers_.get(); } |
86 void Reset() { headers_.reset(); } | 83 void Reset() { headers_.reset(); } |
87 void Realloc(size_t new_size); | 84 void Realloc(size_t new_size); |
88 | 85 |
89 private: | 86 private: |
90 scoped_ptr_malloc<char> headers_; | 87 scoped_ptr_malloc<char> headers_; |
91 }; | 88 }; |
92 | 89 |
93 enum State { | |
94 STATE_RESOLVE_PROXY, | |
95 STATE_RESOLVE_PROXY_COMPLETE, | |
96 STATE_INIT_CONNECTION, | |
97 STATE_INIT_CONNECTION_COMPLETE, | |
98 STATE_SSL_CONNECT, | |
99 STATE_SSL_CONNECT_COMPLETE, | |
100 STATE_WRITE_HEADERS, | |
101 STATE_WRITE_HEADERS_COMPLETE, | |
102 STATE_WRITE_BODY, | |
103 STATE_WRITE_BODY_COMPLETE, | |
104 STATE_READ_HEADERS, | |
105 STATE_READ_HEADERS_COMPLETE, | |
106 STATE_READ_BODY, | |
107 STATE_READ_BODY_COMPLETE, | |
108 STATE_DRAIN_BODY_FOR_AUTH_RESTART, | |
109 STATE_DRAIN_BODY_FOR_AUTH_RESTART_COMPLETE, | |
110 STATE_NONE | |
111 }; | |
112 | |
113 void DoCallback(int result); | 90 void DoCallback(int result); |
114 void OnIOComplete(int result); | 91 void OnIOComplete(int result); |
115 | 92 |
116 // Runs the state transition loop. | 93 // Runs the state transition loop. |
117 int DoLoop(int result); | 94 int DoLoop(int result); |
118 | 95 |
119 // Each of these methods corresponds to a State value. Those with an input | 96 // Each of these methods corresponds to a State value. Those with an input |
120 // argument receive the result from the previous state. If a method returns | 97 // argument receive the result from the previous state. If a method returns |
121 // ERR_IO_PENDING, then the result from OnIOComplete will be passed to the | 98 // ERR_IO_PENDING, then the result from OnIOComplete will be passed to the |
122 // next state method as the result arg. | 99 // next state method as the result arg. |
123 int DoResolveProxy(); | 100 int DoResolveProxy(); |
124 int DoResolveProxyComplete(int result); | 101 int DoResolveProxyComplete(int result); |
125 int DoInitConnection(); | 102 int DoInitConnection(); |
126 int DoInitConnectionComplete(int result); | 103 int DoInitConnectionComplete(int result); |
| 104 int DoResolveHost(); |
| 105 int DoResolveHostComplete(int result); |
| 106 int DoTCPConnect(); |
| 107 int DoTCPConnectComplete(int result); |
127 int DoSSLConnect(); | 108 int DoSSLConnect(); |
128 int DoSSLConnectComplete(int result); | 109 int DoSSLConnectComplete(int result); |
129 int DoWriteHeaders(); | 110 int DoWriteHeaders(); |
130 int DoWriteHeadersComplete(int result); | 111 int DoWriteHeadersComplete(int result); |
131 int DoWriteBody(); | 112 int DoWriteBody(); |
132 int DoWriteBodyComplete(int result); | 113 int DoWriteBodyComplete(int result); |
133 int DoReadHeaders(); | 114 int DoReadHeaders(); |
134 int DoReadHeadersComplete(int result); | 115 int DoReadHeadersComplete(int result); |
135 int DoReadBody(); | 116 int DoReadBody(); |
136 int DoReadBodyComplete(int result); | 117 int DoReadBodyComplete(int result); |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 | 355 |
375 // The time the Start method was called. | 356 // The time the Start method was called. |
376 base::Time start_time_; | 357 base::Time start_time_; |
377 | 358 |
378 // The time the Connect() method was called (if it got called). | 359 // The time the Connect() method was called (if it got called). |
379 base::Time connect_start_time_; | 360 base::Time connect_start_time_; |
380 | 361 |
381 // The time the host resolution started (if it indeed got started). | 362 // The time the host resolution started (if it indeed got started). |
382 base::Time host_resolution_start_time_; | 363 base::Time host_resolution_start_time_; |
383 | 364 |
384 // The next state in the state machine. | 365 enum State { |
| 366 STATE_RESOLVE_PROXY, |
| 367 STATE_RESOLVE_PROXY_COMPLETE, |
| 368 STATE_INIT_CONNECTION, |
| 369 STATE_INIT_CONNECTION_COMPLETE, |
| 370 STATE_RESOLVE_HOST, |
| 371 STATE_RESOLVE_HOST_COMPLETE, |
| 372 STATE_TCP_CONNECT, |
| 373 STATE_TCP_CONNECT_COMPLETE, |
| 374 STATE_SSL_CONNECT, |
| 375 STATE_SSL_CONNECT_COMPLETE, |
| 376 STATE_WRITE_HEADERS, |
| 377 STATE_WRITE_HEADERS_COMPLETE, |
| 378 STATE_WRITE_BODY, |
| 379 STATE_WRITE_BODY_COMPLETE, |
| 380 STATE_READ_HEADERS, |
| 381 STATE_READ_HEADERS_COMPLETE, |
| 382 STATE_READ_BODY, |
| 383 STATE_READ_BODY_COMPLETE, |
| 384 STATE_DRAIN_BODY_FOR_AUTH_RESTART, |
| 385 STATE_DRAIN_BODY_FOR_AUTH_RESTART_COMPLETE, |
| 386 STATE_NONE |
| 387 }; |
385 State next_state_; | 388 State next_state_; |
386 }; | 389 }; |
387 | 390 |
388 } // namespace net | 391 } // namespace net |
389 | 392 |
390 #endif // NET_HTTP_HTTP_NETWORK_TRANSACTION_H_ | 393 #endif // NET_HTTP_HTTP_NETWORK_TRANSACTION_H_ |
OLD | NEW |