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

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

Issue 2898573002: Refactor client cert private key handling. (Closed)
Patch Set: rebase Created 3 years, 6 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_cache_transaction.h" 5 #include "net/http/http_cache_transaction.h"
6 6
7 #include "build/build_config.h" // For OS_POSIX 7 #include "build/build_config.h" // For OS_POSIX
8 8
9 #if defined(OS_POSIX) 9 #if defined(OS_POSIX)
10 #include <unistd.h> 10 #include <unistd.h>
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 296
297 int rv = RestartNetworkRequest(); 297 int rv = RestartNetworkRequest();
298 298
299 if (rv == ERR_IO_PENDING) 299 if (rv == ERR_IO_PENDING)
300 callback_ = callback; 300 callback_ = callback;
301 301
302 return rv; 302 return rv;
303 } 303 }
304 304
305 int HttpCache::Transaction::RestartWithCertificate( 305 int HttpCache::Transaction::RestartWithCertificate(
306 X509Certificate* client_cert, 306 scoped_refptr<X509Certificate> client_cert,
307 SSLPrivateKey* client_private_key, 307 scoped_refptr<SSLPrivateKey> client_private_key,
308 const CompletionCallback& callback) { 308 const CompletionCallback& callback) {
309 DCHECK(!callback.is_null()); 309 DCHECK(!callback.is_null());
310 310
311 // Ensure that we only have one asynchronous call at a time. 311 // Ensure that we only have one asynchronous call at a time.
312 DCHECK(callback_.is_null()); 312 DCHECK(callback_.is_null());
313 313
314 if (!cache_.get()) 314 if (!cache_.get())
315 return ERR_UNEXPECTED; 315 return ERR_UNEXPECTED;
316 316
317 int rv = 317 int rv = RestartNetworkRequestWithCertificate(std::move(client_cert),
318 RestartNetworkRequestWithCertificate(client_cert, client_private_key); 318 std::move(client_private_key));
319 319
320 if (rv == ERR_IO_PENDING) 320 if (rv == ERR_IO_PENDING)
321 callback_ = callback; 321 callback_ = callback;
322 322
323 return rv; 323 return rv;
324 } 324 }
325 325
326 int HttpCache::Transaction::RestartWithAuth( 326 int HttpCache::Transaction::RestartWithAuth(
327 const AuthCredentials& credentials, 327 const AuthCredentials& credentials,
328 const CompletionCallback& callback) { 328 const CompletionCallback& callback) {
(...skipping 2018 matching lines...) Expand 10 before | Expand all | Expand 10 after
2347 DCHECK_EQ(STATE_NONE, next_state_); 2347 DCHECK_EQ(STATE_NONE, next_state_);
2348 2348
2349 next_state_ = STATE_SEND_REQUEST_COMPLETE; 2349 next_state_ = STATE_SEND_REQUEST_COMPLETE;
2350 int rv = network_trans_->RestartIgnoringLastError(io_callback_); 2350 int rv = network_trans_->RestartIgnoringLastError(io_callback_);
2351 if (rv != ERR_IO_PENDING) 2351 if (rv != ERR_IO_PENDING)
2352 return DoLoop(rv); 2352 return DoLoop(rv);
2353 return rv; 2353 return rv;
2354 } 2354 }
2355 2355
2356 int HttpCache::Transaction::RestartNetworkRequestWithCertificate( 2356 int HttpCache::Transaction::RestartNetworkRequestWithCertificate(
2357 X509Certificate* client_cert, 2357 scoped_refptr<X509Certificate> client_cert,
2358 SSLPrivateKey* client_private_key) { 2358 scoped_refptr<SSLPrivateKey> client_private_key) {
2359 DCHECK(mode_ & WRITE || mode_ == NONE); 2359 DCHECK(mode_ & WRITE || mode_ == NONE);
2360 DCHECK(network_trans_.get()); 2360 DCHECK(network_trans_.get());
2361 DCHECK_EQ(STATE_NONE, next_state_); 2361 DCHECK_EQ(STATE_NONE, next_state_);
2362 2362
2363 next_state_ = STATE_SEND_REQUEST_COMPLETE; 2363 next_state_ = STATE_SEND_REQUEST_COMPLETE;
2364 int rv = network_trans_->RestartWithCertificate( 2364 int rv = network_trans_->RestartWithCertificate(
2365 client_cert, client_private_key, io_callback_); 2365 std::move(client_cert), std::move(client_private_key), io_callback_);
2366 if (rv != ERR_IO_PENDING) 2366 if (rv != ERR_IO_PENDING)
2367 return DoLoop(rv); 2367 return DoLoop(rv);
2368 return rv; 2368 return rv;
2369 } 2369 }
2370 2370
2371 int HttpCache::Transaction::RestartNetworkRequestWithAuth( 2371 int HttpCache::Transaction::RestartNetworkRequestWithAuth(
2372 const AuthCredentials& credentials) { 2372 const AuthCredentials& credentials) {
2373 DCHECK(mode_ & WRITE || mode_ == NONE); 2373 DCHECK(mode_ & WRITE || mode_ == NONE);
2374 DCHECK(network_trans_.get()); 2374 DCHECK(network_trans_.get());
2375 DCHECK_EQ(STATE_NONE, next_state_); 2375 DCHECK_EQ(STATE_NONE, next_state_);
(...skipping 748 matching lines...) Expand 10 before | Expand all | Expand 10 after
3124 } 3124 }
3125 3125
3126 void HttpCache::Transaction::TransitionToState(State state) { 3126 void HttpCache::Transaction::TransitionToState(State state) {
3127 // Ensure that the state is only set once per Do* state. 3127 // Ensure that the state is only set once per Do* state.
3128 DCHECK(in_do_loop_); 3128 DCHECK(in_do_loop_);
3129 DCHECK_EQ(STATE_UNSET, next_state_) << "Next state is " << state; 3129 DCHECK_EQ(STATE_UNSET, next_state_) << "Next state is " << state;
3130 next_state_ = state; 3130 next_state_ = state;
3131 } 3131 }
3132 3132
3133 } // namespace net 3133 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698