OLD | NEW |
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 <errno.h> | 7 #include <errno.h> |
8 #include <string.h> | 8 #include <string.h> |
9 | 9 |
10 #include <utility> | 10 #include <utility> |
(...skipping 3585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3596 TEST_F(SSLClientSocketTest, DumpMemoryStats) { | 3596 TEST_F(SSLClientSocketTest, DumpMemoryStats) { |
3597 ASSERT_TRUE(StartTestServer(SpawnedTestServer::SSLOptions())); | 3597 ASSERT_TRUE(StartTestServer(SpawnedTestServer::SSLOptions())); |
3598 | 3598 |
3599 int rv; | 3599 int rv; |
3600 ASSERT_TRUE(CreateAndConnectSSLClientSocket(SSLConfig(), &rv)); | 3600 ASSERT_TRUE(CreateAndConnectSSLClientSocket(SSLConfig(), &rv)); |
3601 EXPECT_THAT(rv, IsOk()); | 3601 EXPECT_THAT(rv, IsOk()); |
3602 StreamSocket::SocketMemoryStats stats; | 3602 StreamSocket::SocketMemoryStats stats; |
3603 sock_->DumpMemoryStats(&stats); | 3603 sock_->DumpMemoryStats(&stats); |
3604 EXPECT_EQ(0u, stats.buffer_size); | 3604 EXPECT_EQ(0u, stats.buffer_size); |
3605 EXPECT_EQ(1u, stats.cert_count); | 3605 EXPECT_EQ(1u, stats.cert_count); |
3606 EXPECT_LT(0u, stats.serialized_cert_size); | 3606 EXPECT_LT(0u, stats.cert_size); |
3607 EXPECT_EQ(stats.serialized_cert_size, stats.total_size); | 3607 EXPECT_EQ(stats.cert_size, stats.total_size); |
3608 | 3608 |
3609 // Read the response without writing a request, so the read will be pending. | 3609 // Read the response without writing a request, so the read will be pending. |
3610 TestCompletionCallback read_callback; | 3610 TestCompletionCallback read_callback; |
3611 scoped_refptr<IOBuffer> buf(new IOBuffer(4096)); | 3611 scoped_refptr<IOBuffer> buf(new IOBuffer(4096)); |
3612 rv = sock_->Read(buf.get(), 4096, read_callback.callback()); | 3612 rv = sock_->Read(buf.get(), 4096, read_callback.callback()); |
3613 EXPECT_EQ(ERR_IO_PENDING, rv); | 3613 EXPECT_EQ(ERR_IO_PENDING, rv); |
3614 | 3614 |
3615 // Dump memory again and check that |buffer_size| contain the read buffer. | 3615 // Dump memory again and check that |buffer_size| contain the read buffer. |
3616 StreamSocket::SocketMemoryStats stats2; | 3616 StreamSocket::SocketMemoryStats stats2; |
3617 sock_->DumpMemoryStats(&stats2); | 3617 sock_->DumpMemoryStats(&stats2); |
3618 EXPECT_EQ(17 * 1024u, stats2.buffer_size); | 3618 EXPECT_EQ(17 * 1024u, stats2.buffer_size); |
3619 EXPECT_EQ(1u, stats2.cert_count); | 3619 EXPECT_EQ(1u, stats2.cert_count); |
3620 EXPECT_LT(0u, stats2.serialized_cert_size); | 3620 EXPECT_LT(0u, stats2.cert_size); |
3621 EXPECT_LT(17 * 1024u, stats2.total_size); | 3621 EXPECT_LT(17 * 1024u, stats2.total_size); |
3622 } | 3622 } |
3623 | 3623 |
3624 } // namespace net | 3624 } // namespace net |
OLD | NEW |