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

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

Issue 100001: Refactor HttpNetworkTransaction to remove side effects in some member functions. (Closed)
Patch Set: Use request_headers directly instead of swapping. 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
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 void BuildRequestHeaders();
59 void BuildTunnelRequest();
60 void DoCallback(int result); 58 void DoCallback(int result);
61 void OnIOComplete(int result); 59 void OnIOComplete(int result);
62 60
63 // Runs the state transition loop. 61 // Runs the state transition loop.
64 int DoLoop(int result); 62 int DoLoop(int result);
65 63
66 // Each of these methods corresponds to a State value. Those with an input 64 // 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 65 // argument receive the result from the previous state. If a method returns
68 // ERR_IO_PENDING, then the result from OnIOComplete will be passed to the 66 // ERR_IO_PENDING, then the result from OnIOComplete will be passed to the
69 // next state method as the result arg. 67 // next state method as the result arg.
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 // Called to possibly recover from an SSL handshake error. Sets next_state_ 110 // Called to possibly recover from an SSL handshake error. Sets next_state_
113 // and returns OK if recovering from the error. Otherwise, the same error 111 // and returns OK if recovering from the error. Otherwise, the same error
114 // code is returned. 112 // code is returned.
115 int HandleSSLHandshakeError(int error); 113 int HandleSSLHandshakeError(int error);
116 114
117 // Called to possibly recover from the given error. Sets next_state_ and 115 // Called to possibly recover from the given error. Sets next_state_ and
118 // returns OK if recovering from the error. Otherwise, the same error code 116 // returns OK if recovering from the error. Otherwise, the same error code
119 // is returned. 117 // is returned.
120 int HandleIOError(int error); 118 int HandleIOError(int error);
121 119
122 // Called when we reached EOF or got an error. If we should resend the 120 // Called when we reached EOF or got an error. Returns true if we should
123 // request, sets next_state_ and returns true. Otherwise, does nothing and 121 // resend the request.
124 // returns false. 122 bool ShouldResendRequest() const;
125 bool ShouldResendRequest(); 123
124 // Resets the connection and the request headers for resend. Called when
125 // ShouldResendRequest() is true.
126 void ResetConnectionAndRequestForResend();
126 127
127 // Called when we encounter a network error that could be resolved by trying 128 // Called when we encounter a network error that could be resolved by trying
128 // a new proxy configuration. If there is another proxy configuration to try 129 // a new proxy configuration. If there is another proxy configuration to try
129 // then this method sets next_state_ appropriately and returns either OK or 130 // then this method sets next_state_ appropriately and returns either OK or
130 // ERR_IO_PENDING depending on whether or not the new proxy configuration is 131 // ERR_IO_PENDING depending on whether or not the new proxy configuration is
131 // available synchronously or asynchronously. Otherwise, the given error 132 // available synchronously or asynchronously. Otherwise, the given error
132 // code is simply returned. 133 // code is simply returned.
133 int ReconsiderProxyAfterError(int error); 134 int ReconsiderProxyAfterError(int error);
134 135
135 // Decides the policy when the connection is closed before the end of headers 136 // Decides the policy when the connection is closed before the end of headers
(...skipping 12 matching lines...) Expand all
148 void PrepareForAuthRestart(HttpAuth::Target target); 149 void PrepareForAuthRestart(HttpAuth::Target target);
149 150
150 // Called when we don't need to drain the response body or have drained it. 151 // Called when we don't need to drain the response body or have drained it.
151 // Resets |connection_| unless |keep_alive| is true, then calls 152 // Resets |connection_| unless |keep_alive| is true, then calls
152 // ResetStateForRestart. Sets |next_state_| appropriately. 153 // ResetStateForRestart. Sets |next_state_| appropriately.
153 void DidDrainBodyForAuthRestart(bool keep_alive); 154 void DidDrainBodyForAuthRestart(bool keep_alive);
154 155
155 // Resets the members of the transaction so it can be restarted. 156 // Resets the members of the transaction so it can be restarted.
156 void ResetStateForRestart(); 157 void ResetStateForRestart();
157 158
158 // Attach any credentials needed for the proxy server or origin server. 159 // Returns true if we should try to add a Proxy-Authorization header
159 void ApplyAuth(); 160 bool ShouldApplyProxyAuth() const;
160 161
161 // Helper used by ApplyAuth(). Adds either the proxy auth header, or the 162 // Returns true if we should try to add an Authorization header.
162 // origin server auth header, as specified by |target| 163 bool ShouldApplyServerAuth() const;
163 void AddAuthorizationHeader(HttpAuth::Target target); 164
165 // Builds either the proxy auth header, or the origin server auth header,
166 // as specified by |target|.
167 std::string BuildAuthorizationHeader(HttpAuth::Target target) const;
164 168
165 // Returns a log message for all the response headers related to the auth 169 // Returns a log message for all the response headers related to the auth
166 // challenge. 170 // challenge.
167 std::string AuthChallengeLogMessage() const; 171 std::string AuthChallengeLogMessage() const;
168 172
169 // Handles HTTP status code 401 or 407. 173 // Handles HTTP status code 401 or 407.
170 // HandleAuthChallenge() returns a network error code, or OK on success. 174 // HandleAuthChallenge() returns a network error code, or OK on success.
171 // May update |pending_auth_target_| or |response_.auth_challenge|. 175 // May update |pending_auth_target_| or |response_.auth_challenge|.
172 int HandleAuthChallenge(); 176 int HandleAuthChallenge();
173 177
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 STATE_DRAIN_BODY_FOR_AUTH_RESTART, 349 STATE_DRAIN_BODY_FOR_AUTH_RESTART,
346 STATE_DRAIN_BODY_FOR_AUTH_RESTART_COMPLETE, 350 STATE_DRAIN_BODY_FOR_AUTH_RESTART_COMPLETE,
347 STATE_NONE 351 STATE_NONE
348 }; 352 };
349 State next_state_; 353 State next_state_;
350 }; 354 };
351 355
352 } // namespace net 356 } // namespace net
353 357
354 #endif // NET_HTTP_HTTP_NETWORK_TRANSACTION_H_ 358 #endif // NET_HTTP_HTTP_NETWORK_TRANSACTION_H_
OLDNEW
« no previous file with comments | « no previous file | net/http/http_network_transaction.cc » ('j') | net/http/http_network_transaction.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698