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

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

Issue 2806052: Remove the net_log member from HttpAuthController. (Closed)
Patch Set: Created 10 years, 5 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
« no previous file with comments | « no previous file | net/http/http_auth_controller.cc » ('j') | net/http/http_proxy_client_socket.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_AUTH_CONTROLLER_H_ 5 #ifndef NET_HTTP_HTTP_AUTH_CONTROLLER_H_
6 #define NET_HTTP_HTTP_AUTH_CONTROLLER_H_ 6 #define NET_HTTP_HTTP_AUTH_CONTROLLER_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/ref_counted.h" 11 #include "base/ref_counted.h"
12 #include "base/scoped_ptr.h" 12 #include "base/scoped_ptr.h"
13 #include "googleurl/src/gurl.h" 13 #include "googleurl/src/gurl.h"
14 #include "net/base/completion_callback.h" 14 #include "net/base/completion_callback.h"
15 #include "net/base/net_log.h" 15 #include "net/base/net_log.h"
16 #include "net/http/http_auth.h" 16 #include "net/http/http_auth.h"
17 17
18 namespace net { 18 namespace net {
19 19
20 class AuthChallengeInfo; 20 class AuthChallengeInfo;
21 class HostResolver; 21 class HostResolver;
22 class HttpAuthHandler;
22 class HttpNetworkSession; 23 class HttpNetworkSession;
23 class HttpRequestHeaders; 24 class HttpRequestHeaders;
24 struct HttpRequestInfo; 25 struct HttpRequestInfo;
25 26
26 class HttpAuthController : public base::RefCounted<HttpAuthController> { 27 class HttpAuthController : public base::RefCounted<HttpAuthController> {
27 public: 28 public:
28 // The arguments are self explanatory except possibly for |auth_url|, which 29 // The arguments are self explanatory except possibly for |auth_url|, which
29 // should be both the auth target and auth path in a single url argument. 30 // should be both the auth target and auth path in a single url argument.
30 HttpAuthController(HttpAuth::Target target, const GURL& auth_url, 31 HttpAuthController(HttpAuth::Target target, const GURL& auth_url,
31 scoped_refptr<HttpNetworkSession> session, 32 scoped_refptr<HttpNetworkSession> session);
32 const BoundNetLog& net_log);
33 33
34 // Generate an authentication token for |target| if necessary. The return 34 // Generate an authentication token for |target| if necessary. The return
35 // value is a net error code. |OK| will be returned both in the case that 35 // value is a net error code. |OK| will be returned both in the case that
36 // a token is correctly generated synchronously, as well as when no tokens 36 // a token is correctly generated synchronously, as well as when no tokens
37 // were necessary. 37 // were necessary.
38 int MaybeGenerateAuthToken(const HttpRequestInfo* request, 38 int MaybeGenerateAuthToken(const HttpRequestInfo* request,
39 CompletionCallback* callback); 39 CompletionCallback* callback,
40 const BoundNetLog& net_log);
40 41
41 // Adds either the proxy auth header, or the origin server auth header, 42 // Adds either the proxy auth header, or the origin server auth header,
42 // as specified by |target_|. 43 // as specified by |target_|.
43 void AddAuthorizationHeader(HttpRequestHeaders* authorization_headers); 44 void AddAuthorizationHeader(HttpRequestHeaders* authorization_headers);
44 45
45 // Checks for and handles HTTP status code 401 or 407. 46 // Checks for and handles HTTP status code 401 or 407.
46 // |HandleAuthChallenge()| returns OK on success, or a network error code 47 // |HandleAuthChallenge()| returns OK on success, or a network error code
47 // otherwise. It may also populate |auth_info_|. 48 // otherwise. It may also populate |auth_info_|.
48 int HandleAuthChallenge(scoped_refptr<HttpResponseHeaders> headers, 49 int HandleAuthChallenge(scoped_refptr<HttpResponseHeaders> headers,
49 bool do_not_send_server_auth, 50 bool do_not_send_server_auth,
50 bool establishing_tunnel); 51 bool establishing_tunnel,
52 const BoundNetLog& net_log);
51 53
52 // Store the supplied credentials and prepare to restart the auth. 54 // Store the supplied credentials and prepare to restart the auth.
53 void ResetAuth(const std::wstring& username, const std::wstring& password); 55 void ResetAuth(const std::wstring& username, const std::wstring& password);
54 56
55 bool HaveAuthHandler() const { 57 bool HaveAuthHandler() const {
56 return handler_.get() != NULL; 58 return handler_.get() != NULL;
57 } 59 }
58 60
59 bool HaveAuth() const { 61 bool HaveAuth() const {
60 return handler_.get() && !identity_.invalid; 62 return handler_.get() && !identity_.invalid;
61 } 63 }
62 64
63 scoped_refptr<AuthChallengeInfo> auth_info() { 65 scoped_refptr<AuthChallengeInfo> auth_info() {
64 return auth_info_; 66 return auth_info_;
65 } 67 }
66 68
67 void set_net_log(const BoundNetLog& net_log) {
68 net_log_ = net_log;
69 }
70
71 private: 69 private:
72 friend class base::RefCounted<HttpAuthController>; 70 friend class base::RefCounted<HttpAuthController>;
73 ~HttpAuthController(); 71 ~HttpAuthController();
74 72
75 // Searches the auth cache for an entry that encompasses the request's path. 73 // Searches the auth cache for an entry that encompasses the request's path.
76 // If such an entry is found, updates |identity_| and |handler_| with the 74 // If such an entry is found, updates |identity_| and |handler_| with the
77 // cache entry's data and returns true. 75 // cache entry's data and returns true.
78 bool SelectPreemptiveAuth(); 76 bool SelectPreemptiveAuth(const BoundNetLog& net_log);
79 77
80 // Invalidates any auth cache entries after authentication has failed. 78 // Invalidates any auth cache entries after authentication has failed.
81 // The identity that was rejected is |identity_|. 79 // The identity that was rejected is |identity_|.
82 void InvalidateRejectedAuthFromCache(); 80 void InvalidateRejectedAuthFromCache();
83 81
84 // Sets |identity_| to the next identity that the transaction should try. It 82 // Sets |identity_| to the next identity that the transaction should try. It
85 // chooses candidates by searching the auth cache and the URL for a 83 // chooses candidates by searching the auth cache and the URL for a
86 // username:password. Returns true if an identity was found. 84 // username:password. Returns true if an identity was found.
87 bool SelectNextAuthIdentityToTry(); 85 bool SelectNextAuthIdentityToTry();
88 86
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 // True if we've used the username/password embedded in the URL. This 121 // True if we've used the username/password embedded in the URL. This
124 // makes sure we use the embedded identity only once for the transaction, 122 // makes sure we use the embedded identity only once for the transaction,
125 // preventing an infinite auth restart loop. 123 // preventing an infinite auth restart loop.
126 bool embedded_identity_used_; 124 bool embedded_identity_used_;
127 125
128 // True if default credentials have already been tried for this transaction 126 // True if default credentials have already been tried for this transaction
129 // in response to an HTTP authentication challenge. 127 // in response to an HTTP authentication challenge.
130 bool default_credentials_used_; 128 bool default_credentials_used_;
131 129
132 scoped_refptr<HttpNetworkSession> session_; 130 scoped_refptr<HttpNetworkSession> session_;
133
134 BoundNetLog net_log_;
135 }; 131 };
136 132
137 } // namespace net 133 } // namespace net
138 134
139 #endif // NET_HTTP_HTTP_AUTH_CONTROLLER_H_ 135 #endif // NET_HTTP_HTTP_AUTH_CONTROLLER_H_
OLDNEW
« no previous file with comments | « no previous file | net/http/http_auth_controller.cc » ('j') | net/http/http_proxy_client_socket.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698