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

Side by Side Diff: net/socket/ssl_client_socket_unittest.cc

Issue 503113004: Remove implicit conversions from scoped_refptr to T* in net/socket/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 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 | « net/socket/ssl_client_socket_nss.cc ('k') | net/socket/ssl_server_socket_unittest.cc » ('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) 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/socket/ssl_client_socket.h" 5 #include "net/socket/ssl_client_socket.h"
6 6
7 #include "base/callback_helpers.h" 7 #include "base/callback_helpers.h"
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 int FakeBlockingStreamSocket::Write(IOBuffer* buf, 426 int FakeBlockingStreamSocket::Write(IOBuffer* buf,
427 int len, 427 int len,
428 const CompletionCallback& callback) { 428 const CompletionCallback& callback) {
429 DCHECK(buf); 429 DCHECK(buf);
430 DCHECK_LE(0, len); 430 DCHECK_LE(0, len);
431 431
432 if (!should_block_write_) 432 if (!should_block_write_)
433 return transport_->Write(buf, len, callback); 433 return transport_->Write(buf, len, callback);
434 434
435 // Schedule the write, but do nothing. 435 // Schedule the write, but do nothing.
436 DCHECK(!pending_write_buf_); 436 DCHECK(!pending_write_buf_.get());
437 DCHECK_EQ(-1, pending_write_len_); 437 DCHECK_EQ(-1, pending_write_len_);
438 DCHECK(pending_write_callback_.is_null()); 438 DCHECK(pending_write_callback_.is_null());
439 DCHECK(!callback.is_null()); 439 DCHECK(!callback.is_null());
440 pending_write_buf_ = buf; 440 pending_write_buf_ = buf;
441 pending_write_len_ = len; 441 pending_write_len_ = len;
442 pending_write_callback_ = callback; 442 pending_write_callback_ = callback;
443 443
444 // Stop the write loop, if any. 444 // Stop the write loop, if any.
445 if (write_loop_) 445 if (write_loop_)
446 write_loop_->Quit(); 446 write_loop_->Quit();
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 DCHECK(!should_block_write_); 482 DCHECK(!should_block_write_);
483 should_block_write_ = true; 483 should_block_write_ = true;
484 } 484 }
485 485
486 void FakeBlockingStreamSocket::UnblockWrite() { 486 void FakeBlockingStreamSocket::UnblockWrite() {
487 DCHECK(should_block_write_); 487 DCHECK(should_block_write_);
488 should_block_write_ = false; 488 should_block_write_ = false;
489 489
490 // Do nothing if UnblockWrite() was called after BlockWrite(), 490 // Do nothing if UnblockWrite() was called after BlockWrite(),
491 // without a Write() in between. 491 // without a Write() in between.
492 if (!pending_write_buf_) 492 if (!pending_write_buf_.get())
493 return; 493 return;
494 494
495 int rv = transport_->Write(pending_write_buf_, pending_write_len_, 495 int rv = transport_->Write(
496 pending_write_callback_); 496 pending_write_buf_.get(), pending_write_len_, pending_write_callback_);
497 pending_write_buf_ = NULL; 497 pending_write_buf_ = NULL;
498 pending_write_len_ = -1; 498 pending_write_len_ = -1;
499 if (rv == ERR_IO_PENDING) { 499 if (rv == ERR_IO_PENDING) {
500 pending_write_callback_.Reset(); 500 pending_write_callback_.Reset();
501 } else { 501 } else {
502 base::ResetAndReturn(&pending_write_callback_).Run(rv); 502 base::ResetAndReturn(&pending_write_callback_).Run(rv);
503 } 503 }
504 } 504 }
505 505
506 void FakeBlockingStreamSocket::WaitForWrite() { 506 void FakeBlockingStreamSocket::WaitForWrite() {
507 DCHECK(should_block_write_); 507 DCHECK(should_block_write_);
508 DCHECK(!write_loop_); 508 DCHECK(!write_loop_);
509 509
510 if (pending_write_buf_) 510 if (pending_write_buf_.get())
511 return; 511 return;
512 write_loop_.reset(new base::RunLoop); 512 write_loop_.reset(new base::RunLoop);
513 write_loop_->Run(); 513 write_loop_->Run();
514 write_loop_.reset(); 514 write_loop_.reset();
515 DCHECK(pending_write_buf_); 515 DCHECK(pending_write_buf_.get());
516 } 516 }
517 517
518 void FakeBlockingStreamSocket::OnReadCompleted(int result) { 518 void FakeBlockingStreamSocket::OnReadCompleted(int result) {
519 DCHECK_EQ(ERR_IO_PENDING, pending_read_result_); 519 DCHECK_EQ(ERR_IO_PENDING, pending_read_result_);
520 DCHECK(!pending_read_callback_.is_null()); 520 DCHECK(!pending_read_callback_.is_null());
521 521
522 if (should_block_read_) { 522 if (should_block_read_) {
523 // Store the result so that the callback can be invoked once Unblock() is 523 // Store the result so that the callback can be invoked once Unblock() is
524 // called. 524 // called.
525 pending_read_result_ = result; 525 pending_read_result_ = result;
(...skipping 1812 matching lines...) Expand 10 before | Expand all | Expand 10 after
2338 verify_result.verified_cert = X509Certificate::CreateFromHandle( 2338 verify_result.verified_cert = X509Certificate::CreateFromHandle(
2339 certs[0]->os_cert_handle(), temp_intermediates); 2339 certs[0]->os_cert_handle(), temp_intermediates);
2340 2340
2341 // Add a rule that maps the server cert (A) to the chain of A->B->C2 2341 // Add a rule that maps the server cert (A) to the chain of A->B->C2
2342 // rather than A->B->C. 2342 // rather than A->B->C.
2343 cert_verifier_->AddResultForCert(certs[0].get(), verify_result, OK); 2343 cert_verifier_->AddResultForCert(certs[0].get(), verify_result, OK);
2344 2344
2345 // Load and install the root for the validated chain. 2345 // Load and install the root for the validated chain.
2346 scoped_refptr<X509Certificate> root_cert = ImportCertFromFile( 2346 scoped_refptr<X509Certificate> root_cert = ImportCertFromFile(
2347 GetTestCertsDirectory(), "redundant-validated-chain-root.pem"); 2347 GetTestCertsDirectory(), "redundant-validated-chain-root.pem");
2348 ASSERT_NE(static_cast<X509Certificate*>(NULL), root_cert); 2348 ASSERT_NE(static_cast<X509Certificate*>(NULL), root_cert.get());
2349 ScopedTestRoot scoped_root(root_cert.get()); 2349 ScopedTestRoot scoped_root(root_cert.get());
2350 2350
2351 // Set up a test server with CERT_CHAIN_WRONG_ROOT. 2351 // Set up a test server with CERT_CHAIN_WRONG_ROOT.
2352 SpawnedTestServer::SSLOptions ssl_options( 2352 SpawnedTestServer::SSLOptions ssl_options(
2353 SpawnedTestServer::SSLOptions::CERT_CHAIN_WRONG_ROOT); 2353 SpawnedTestServer::SSLOptions::CERT_CHAIN_WRONG_ROOT);
2354 SpawnedTestServer test_server( 2354 SpawnedTestServer test_server(
2355 SpawnedTestServer::TYPE_HTTPS, 2355 SpawnedTestServer::TYPE_HTTPS,
2356 ssl_options, 2356 ssl_options,
2357 base::FilePath(FILE_PATH_LITERAL("net/data/ssl"))); 2357 base::FilePath(FILE_PATH_LITERAL("net/data/ssl")));
2358 ASSERT_TRUE(test_server.Start()); 2358 ASSERT_TRUE(test_server.Start());
(...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after
2990 ssl_config.channel_id_enabled = true; 2990 ssl_config.channel_id_enabled = true;
2991 2991
2992 int rv; 2992 int rv;
2993 ASSERT_TRUE(CreateAndConnectSSLClientSocket(ssl_config, &rv)); 2993 ASSERT_TRUE(CreateAndConnectSSLClientSocket(ssl_config, &rv));
2994 2994
2995 EXPECT_EQ(ERR_UNEXPECTED, rv); 2995 EXPECT_EQ(ERR_UNEXPECTED, rv);
2996 EXPECT_FALSE(sock_->IsConnected()); 2996 EXPECT_FALSE(sock_->IsConnected());
2997 } 2997 }
2998 2998
2999 } // namespace net 2999 } // namespace net
OLDNEW
« no previous file with comments | « net/socket/ssl_client_socket_nss.cc ('k') | net/socket/ssl_server_socket_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698