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

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

Issue 2351513002: net: rename BoundNetLog to NetLogWithSource (Closed)
Patch Set: one more fix, content bound_net_log_ Created 4 years, 2 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "net/http/http_auth_controller.h" 5 #include "net/http/http_auth_controller.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/metrics/histogram_macros.h" 9 #include "base/metrics/histogram_macros.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 default_credentials_used_(false), 135 default_credentials_used_(false),
136 http_auth_cache_(http_auth_cache), 136 http_auth_cache_(http_auth_cache),
137 http_auth_handler_factory_(http_auth_handler_factory) { 137 http_auth_handler_factory_(http_auth_handler_factory) {
138 } 138 }
139 139
140 HttpAuthController::~HttpAuthController() { 140 HttpAuthController::~HttpAuthController() {
141 DCHECK(CalledOnValidThread()); 141 DCHECK(CalledOnValidThread());
142 } 142 }
143 143
144 int HttpAuthController::MaybeGenerateAuthToken( 144 int HttpAuthController::MaybeGenerateAuthToken(
145 const HttpRequestInfo* request, const CompletionCallback& callback, 145 const HttpRequestInfo* request,
146 const BoundNetLog& net_log) { 146 const CompletionCallback& callback,
147 const NetLogWithSource& net_log) {
147 DCHECK(CalledOnValidThread()); 148 DCHECK(CalledOnValidThread());
148 bool needs_auth = HaveAuth() || SelectPreemptiveAuth(net_log); 149 bool needs_auth = HaveAuth() || SelectPreemptiveAuth(net_log);
149 if (!needs_auth) 150 if (!needs_auth)
150 return OK; 151 return OK;
151 const AuthCredentials* credentials = NULL; 152 const AuthCredentials* credentials = NULL;
152 if (identity_.source != HttpAuth::IDENT_SRC_DEFAULT_CREDENTIALS) 153 if (identity_.source != HttpAuth::IDENT_SRC_DEFAULT_CREDENTIALS)
153 credentials = &identity_.credentials; 154 credentials = &identity_.credentials;
154 DCHECK(auth_token_.empty()); 155 DCHECK(auth_token_.empty());
155 DCHECK(callback_.is_null()); 156 DCHECK(callback_.is_null());
156 int rv = handler_->GenerateAuthToken( 157 int rv = handler_->GenerateAuthToken(
157 credentials, request, 158 credentials, request,
158 base::Bind(&HttpAuthController::OnIOComplete, base::Unretained(this)), 159 base::Bind(&HttpAuthController::OnIOComplete, base::Unretained(this)),
159 &auth_token_); 160 &auth_token_);
160 if (DisableOnAuthHandlerResult(rv)) 161 if (DisableOnAuthHandlerResult(rv))
161 rv = OK; 162 rv = OK;
162 if (rv == ERR_IO_PENDING) 163 if (rv == ERR_IO_PENDING)
163 callback_ = callback; 164 callback_ = callback;
164 else 165 else
165 OnIOComplete(rv); 166 OnIOComplete(rv);
166 return rv; 167 return rv;
167 } 168 }
168 169
169 bool HttpAuthController::SelectPreemptiveAuth(const BoundNetLog& net_log) { 170 bool HttpAuthController::SelectPreemptiveAuth(const NetLogWithSource& net_log) {
170 DCHECK(CalledOnValidThread()); 171 DCHECK(CalledOnValidThread());
171 DCHECK(!HaveAuth()); 172 DCHECK(!HaveAuth());
172 DCHECK(identity_.invalid); 173 DCHECK(identity_.invalid);
173 174
174 // Don't do preemptive authorization if the URL contains a username:password, 175 // Don't do preemptive authorization if the URL contains a username:password,
175 // since we must first be challenged in order to use the URL's identity. 176 // since we must first be challenged in order to use the URL's identity.
176 if (auth_url_.has_username()) 177 if (auth_url_.has_username())
177 return false; 178 return false;
178 179
179 // SelectPreemptiveAuth() is on the critical path for each request, so it 180 // SelectPreemptiveAuth() is on the critical path for each request, so it
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 HttpAuth::GetAuthorizationHeaderName(target_), auth_token_); 215 HttpAuth::GetAuthorizationHeaderName(target_), auth_token_);
215 auth_token_.clear(); 216 auth_token_.clear();
216 } 217 }
217 } 218 }
218 219
219 int HttpAuthController::HandleAuthChallenge( 220 int HttpAuthController::HandleAuthChallenge(
220 scoped_refptr<HttpResponseHeaders> headers, 221 scoped_refptr<HttpResponseHeaders> headers,
221 const SSLInfo& ssl_info, 222 const SSLInfo& ssl_info,
222 bool do_not_send_server_auth, 223 bool do_not_send_server_auth,
223 bool establishing_tunnel, 224 bool establishing_tunnel,
224 const BoundNetLog& net_log) { 225 const NetLogWithSource& net_log) {
225 DCHECK(CalledOnValidThread()); 226 DCHECK(CalledOnValidThread());
226 DCHECK(headers.get()); 227 DCHECK(headers.get());
227 DCHECK(auth_origin_.is_valid()); 228 DCHECK(auth_origin_.is_valid());
228 229
229 // Give the existing auth handler first try at the authentication headers. 230 // Give the existing auth handler first try at the authentication headers.
230 // This will also evict the entry in the HttpAuthCache if the previous 231 // This will also evict the entry in the HttpAuthCache if the previous
231 // challenge appeared to be rejected, or is using a stale nonce in the Digest 232 // challenge appeared to be rejected, or is using a stale nonce in the Digest
232 // case. 233 // case.
233 if (HaveAuth()) { 234 if (HaveAuth()) {
234 std::string challenge_used; 235 std::string challenge_used;
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 DCHECK(CalledOnValidThread()); 526 DCHECK(CalledOnValidThread());
526 disabled_schemes_.insert(scheme); 527 disabled_schemes_.insert(scheme);
527 } 528 }
528 529
529 void HttpAuthController::DisableEmbeddedIdentity() { 530 void HttpAuthController::DisableEmbeddedIdentity() {
530 DCHECK(CalledOnValidThread()); 531 DCHECK(CalledOnValidThread());
531 embedded_identity_used_ = true; 532 embedded_identity_used_ = true;
532 } 533 }
533 534
534 } // namespace net 535 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698