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

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

Issue 8340026: Use AuthCredentials throughout the network stack instead of username/password. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fix comments Created 9 years, 1 month 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 | « net/http/http_cache_transaction.h ('k') | net/http/http_network_transaction.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_cache_transaction.h" 5 #include "net/http/http_cache_transaction.h"
6 6
7 #include "build/build_config.h" 7 #include "build/build_config.h"
8 8
9 #if defined(OS_POSIX) 9 #if defined(OS_POSIX)
10 #include <unistd.h> 10 #include <unistd.h>
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 275
276 int rv = RestartNetworkRequestWithCertificate(client_cert); 276 int rv = RestartNetworkRequestWithCertificate(client_cert);
277 277
278 if (rv == ERR_IO_PENDING) 278 if (rv == ERR_IO_PENDING)
279 callback_ = callback; 279 callback_ = callback;
280 280
281 return rv; 281 return rv;
282 } 282 }
283 283
284 int HttpCache::Transaction::RestartWithAuth( 284 int HttpCache::Transaction::RestartWithAuth(
285 const string16& username, 285 const AuthCredentials& credentials,
286 const string16& password,
287 OldCompletionCallback* callback) { 286 OldCompletionCallback* callback) {
288 DCHECK(auth_response_.headers); 287 DCHECK(auth_response_.headers);
289 DCHECK(callback); 288 DCHECK(callback);
290 289
291 // Ensure that we only have one asynchronous call at a time. 290 // Ensure that we only have one asynchronous call at a time.
292 DCHECK(!callback_); 291 DCHECK(!callback_);
293 292
294 if (!cache_) 293 if (!cache_)
295 return ERR_UNEXPECTED; 294 return ERR_UNEXPECTED;
296 295
297 // Clear the intermediate response since we are going to start over. 296 // Clear the intermediate response since we are going to start over.
298 auth_response_ = HttpResponseInfo(); 297 auth_response_ = HttpResponseInfo();
299 298
300 int rv = RestartNetworkRequestWithAuth(username, password); 299 int rv = RestartNetworkRequestWithAuth(credentials);
301 300
302 if (rv == ERR_IO_PENDING) 301 if (rv == ERR_IO_PENDING)
303 callback_ = callback; 302 callback_ = callback;
304 303
305 return rv; 304 return rv;
306 } 305 }
307 306
308 bool HttpCache::Transaction::IsReadyToRestartForAuth() { 307 bool HttpCache::Transaction::IsReadyToRestartForAuth() {
309 if (!network_trans_.get()) 308 if (!network_trans_.get())
310 return false; 309 return false;
(...skipping 1362 matching lines...) Expand 10 before | Expand all | Expand 10 after
1673 DCHECK_EQ(STATE_NONE, next_state_); 1672 DCHECK_EQ(STATE_NONE, next_state_);
1674 1673
1675 next_state_ = STATE_SEND_REQUEST_COMPLETE; 1674 next_state_ = STATE_SEND_REQUEST_COMPLETE;
1676 int rv = network_trans_->RestartWithCertificate(client_cert, &io_callback_); 1675 int rv = network_trans_->RestartWithCertificate(client_cert, &io_callback_);
1677 if (rv != ERR_IO_PENDING) 1676 if (rv != ERR_IO_PENDING)
1678 return DoLoop(rv); 1677 return DoLoop(rv);
1679 return rv; 1678 return rv;
1680 } 1679 }
1681 1680
1682 int HttpCache::Transaction::RestartNetworkRequestWithAuth( 1681 int HttpCache::Transaction::RestartNetworkRequestWithAuth(
1683 const string16& username, 1682 const AuthCredentials& credentials) {
1684 const string16& password) {
1685 DCHECK(mode_ & WRITE || mode_ == NONE); 1683 DCHECK(mode_ & WRITE || mode_ == NONE);
1686 DCHECK(network_trans_.get()); 1684 DCHECK(network_trans_.get());
1687 DCHECK_EQ(STATE_NONE, next_state_); 1685 DCHECK_EQ(STATE_NONE, next_state_);
1688 1686
1689 next_state_ = STATE_SEND_REQUEST_COMPLETE; 1687 next_state_ = STATE_SEND_REQUEST_COMPLETE;
1690 int rv = network_trans_->RestartWithAuth(username, password, &io_callback_); 1688 int rv = network_trans_->RestartWithAuth(credentials, &io_callback_);
1691 if (rv != ERR_IO_PENDING) 1689 if (rv != ERR_IO_PENDING)
1692 return DoLoop(rv); 1690 return DoLoop(rv);
1693 return rv; 1691 return rv;
1694 } 1692 }
1695 1693
1696 bool HttpCache::Transaction::RequiresValidation() { 1694 bool HttpCache::Transaction::RequiresValidation() {
1697 // TODO(darin): need to do more work here: 1695 // TODO(darin): need to do more work here:
1698 // - make sure we have a matching request method 1696 // - make sure we have a matching request method
1699 // - watch out for cached responses that depend on authentication 1697 // - watch out for cached responses that depend on authentication
1700 // In playback mode, nothing requires validation. 1698 // In playback mode, nothing requires validation.
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
2060 return false; 2058 return false;
2061 2059
2062 return true; 2060 return true;
2063 } 2061 }
2064 2062
2065 void HttpCache::Transaction::OnIOComplete(int result) { 2063 void HttpCache::Transaction::OnIOComplete(int result) {
2066 DoLoop(result); 2064 DoLoop(result);
2067 } 2065 }
2068 2066
2069 } // namespace net 2067 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_cache_transaction.h ('k') | net/http/http_network_transaction.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698