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

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

Issue 2101014: Eliminate the establishing_tunnel_ internal state and move to explicit... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 virtual uint64 GetUploadProgress() const; 76 virtual uint64 GetUploadProgress() const;
77 77
78 private: 78 private:
79 FRIEND_TEST(HttpNetworkTransactionTest, ResetStateForRestart); 79 FRIEND_TEST(HttpNetworkTransactionTest, ResetStateForRestart);
80 80
81 enum State { 81 enum State {
82 STATE_RESOLVE_PROXY, 82 STATE_RESOLVE_PROXY,
83 STATE_RESOLVE_PROXY_COMPLETE, 83 STATE_RESOLVE_PROXY_COMPLETE,
84 STATE_INIT_CONNECTION, 84 STATE_INIT_CONNECTION,
85 STATE_INIT_CONNECTION_COMPLETE, 85 STATE_INIT_CONNECTION_COMPLETE,
86 STATE_TUNNEL_SEND_REQUEST,
87 STATE_TUNNEL_SEND_REQUEST_COMPLETE,
88 STATE_TUNNEL_READ_HEADERS,
89 STATE_TUNNEL_READ_HEADERS_COMPLETE,
86 STATE_SSL_CONNECT, 90 STATE_SSL_CONNECT,
87 STATE_SSL_CONNECT_COMPLETE, 91 STATE_SSL_CONNECT_COMPLETE,
88 STATE_SEND_REQUEST, 92 STATE_SEND_REQUEST,
89 STATE_SEND_REQUEST_COMPLETE, 93 STATE_SEND_REQUEST_COMPLETE,
90 STATE_READ_HEADERS, 94 STATE_READ_HEADERS,
91 STATE_READ_HEADERS_COMPLETE, 95 STATE_READ_HEADERS_COMPLETE,
92 STATE_RESOLVE_CANONICAL_NAME, 96 STATE_RESOLVE_CANONICAL_NAME,
93 STATE_RESOLVE_CANONICAL_NAME_COMPLETE, 97 STATE_RESOLVE_CANONICAL_NAME_COMPLETE,
94 STATE_READ_BODY, 98 STATE_READ_BODY,
95 STATE_READ_BODY_COMPLETE, 99 STATE_READ_BODY_COMPLETE,
(...skipping 21 matching lines...) Expand all
117 int DoLoop(int result); 121 int DoLoop(int result);
118 122
119 // Each of these methods corresponds to a State value. Those with an input 123 // 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 124 // 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 125 // ERR_IO_PENDING, then the result from OnIOComplete will be passed to the
122 // next state method as the result arg. 126 // next state method as the result arg.
123 int DoResolveProxy(); 127 int DoResolveProxy();
124 int DoResolveProxyComplete(int result); 128 int DoResolveProxyComplete(int result);
125 int DoInitConnection(); 129 int DoInitConnection();
126 int DoInitConnectionComplete(int result); 130 int DoInitConnectionComplete(int result);
131 int DoTunnelSendRequest();
132 int DoTunnelSendRequestComplete(int result);
133 int DoTunnelReadHeaders();
134 int DoTunnelReadHeadersComplete(int result);
127 int DoSSLConnect(); 135 int DoSSLConnect();
128 int DoSSLConnectComplete(int result); 136 int DoSSLConnectComplete(int result);
129 int DoSendRequest(); 137 int DoSendRequest();
130 int DoSendRequestComplete(int result); 138 int DoSendRequestComplete(int result);
131 int DoReadHeaders(); 139 int DoReadHeaders();
132 int DoReadHeadersComplete(int result); 140 int DoReadHeadersComplete(int result);
133 int DoResolveCanonicalName(); 141 int DoResolveCanonicalName();
134 int DoResolveCanonicalNameComplete(int result); 142 int DoResolveCanonicalNameComplete(int result);
135 int DoReadBody(); 143 int DoReadBody();
136 int DoReadBodyComplete(int result); 144 int DoReadBodyComplete(int result);
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 void PrepareForAuthRestart(HttpAuth::Target target); 212 void PrepareForAuthRestart(HttpAuth::Target target);
205 213
206 // Called when we don't need to drain the response body or have drained it. 214 // Called when we don't need to drain the response body or have drained it.
207 // Resets |connection_| unless |keep_alive| is true, then calls 215 // Resets |connection_| unless |keep_alive| is true, then calls
208 // ResetStateForRestart. Sets |next_state_| appropriately. 216 // ResetStateForRestart. Sets |next_state_| appropriately.
209 void DidDrainBodyForAuthRestart(bool keep_alive); 217 void DidDrainBodyForAuthRestart(bool keep_alive);
210 218
211 // Resets the members of the transaction so it can be restarted. 219 // Resets the members of the transaction so it can be restarted.
212 void ResetStateForRestart(); 220 void ResetStateForRestart();
213 221
222 // Clear the state used to setup the tunnel.
223 void ClearTunnelState();
224
214 // Returns true if we should try to add a Proxy-Authorization header 225 // Returns true if we should try to add a Proxy-Authorization header
215 bool ShouldApplyProxyAuth() const; 226 bool ShouldApplyProxyAuth() const;
216 227
217 // Returns true if we should try to add an Authorization header. 228 // Returns true if we should try to add an Authorization header.
218 bool ShouldApplyServerAuth() const; 229 bool ShouldApplyServerAuth() const;
219 230
220 // Adds either the proxy auth header, or the origin server auth header, 231 // Adds either the proxy auth header, or the origin server auth header,
221 // as specified by |target|. 232 // as specified by |target|.
222 void AddAuthorizationHeader( 233 void AddAuthorizationHeader(
223 HttpAuth::Target target, HttpRequestHeaders* authorization_headers) const; 234 HttpAuth::Target target, HttpRequestHeaders* authorization_headers) const;
224 235
225 // Returns a log message for all the response headers related to the auth 236 // Returns a log message for all the response headers related to the auth
226 // challenge. 237 // challenge.
227 std::string AuthChallengeLogMessage() const; 238 std::string AuthChallengeLogMessage() const;
228 239
229 // Handles HTTP status code 401 or 407. 240 // Handles HTTP status code 401 or 407.
230 // HandleAuthChallenge() returns a network error code, or OK on success. 241 // HandleAuthChallenge() returns a network error code, or OK on success.
231 // May update |pending_auth_target_| or |response_.auth_challenge|. 242 // May update |pending_auth_target_| or |response_.auth_challenge|.
232 int HandleAuthChallenge(); 243 int HandleAuthChallenge(bool establishing_tunnel);
233 244
234 // Populates response_.auth_challenge with the challenge information, so that 245 // Populates response_.auth_challenge with the challenge information, so that
235 // URLRequestHttpJob can prompt for a username/password. 246 // URLRequestHttpJob can prompt for a username/password.
236 void PopulateAuthChallenge(HttpAuth::Target target, 247 void PopulateAuthChallenge(HttpAuth::Target target,
237 const GURL& auth_origin); 248 const GURL& auth_origin);
238 249
239 // Invalidates any auth cache entries after authentication has failed. 250 // Invalidates any auth cache entries after authentication has failed.
240 // The identity that was rejected is auth_identity_[target]. 251 // The identity that was rejected is auth_identity_[target].
241 void InvalidateRejectedAuthFromCache(HttpAuth::Target target, 252 void InvalidateRejectedAuthFromCache(HttpAuth::Target target,
242 const GURL& auth_origin); 253 const GURL& auth_origin);
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 // True if we've validated the headers that the stream parser has returned. 326 // True if we've validated the headers that the stream parser has returned.
316 bool headers_valid_; 327 bool headers_valid_;
317 328
318 // True if we've logged the time of the first response byte. Used to 329 // True if we've logged the time of the first response byte. Used to
319 // prevent logging across authentication activity where we see multiple 330 // prevent logging across authentication activity where we see multiple
320 // responses. 331 // responses.
321 bool logged_response_time; 332 bool logged_response_time;
322 333
323 bool using_ssl_; // True if handling a HTTPS request 334 bool using_ssl_; // True if handling a HTTPS request
324 335
325 // True while establishing a tunnel. This allows the HTTP CONNECT
326 // request/response to reuse the STATE_SEND_REQUEST,
327 // STATE_SEND_REQUEST_COMPLETE, STATE_READ_HEADERS, and
328 // STATE_READ_HEADERS_COMPLETE states and allows us to tell them apart from
329 // the real request/response of the transaction.
330 bool establishing_tunnel_;
331
332 // True if this network transaction is using SPDY instead of HTTP. 336 // True if this network transaction is using SPDY instead of HTTP.
333 bool using_spdy_; 337 bool using_spdy_;
334 338
335 AlternateProtocolMode alternate_protocol_mode_; 339 AlternateProtocolMode alternate_protocol_mode_;
336 340
337 // Only valid if |alternate_protocol_mode_| == kUsingAlternateProtocol. 341 // Only valid if |alternate_protocol_mode_| == kUsingAlternateProtocol.
338 HttpAlternateProtocols::Protocol alternate_protocol_; 342 HttpAlternateProtocols::Protocol alternate_protocol_;
339 343
340 // True if we've used the username/password embedded in the URL. This 344 // True if we've used the username/password embedded in the URL. This
341 // makes sure we use the embedded identity only once for the transaction, 345 // makes sure we use the embedded identity only once for the transaction,
(...skipping 29 matching lines...) Expand all
371 // The hostname and port of the endpoint. This is not necessarily the one 375 // The hostname and port of the endpoint. This is not necessarily the one
372 // specified by the URL, due to Alternate-Protocol or fixed testing ports. 376 // specified by the URL, due to Alternate-Protocol or fixed testing ports.
373 HostPortPair endpoint_; 377 HostPortPair endpoint_;
374 378
375 DISALLOW_COPY_AND_ASSIGN(HttpNetworkTransaction); 379 DISALLOW_COPY_AND_ASSIGN(HttpNetworkTransaction);
376 }; 380 };
377 381
378 } // namespace net 382 } // namespace net
379 383
380 #endif // NET_HTTP_HTTP_NETWORK_TRANSACTION_H_ 384 #endif // NET_HTTP_HTTP_NETWORK_TRANSACTION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698