Chromium Code Reviews| 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_impl.h" | 5 #include "net/socket/ssl_client_socket_impl.h" |
| 6 | 6 |
| 7 #include <errno.h> | 7 #include <errno.h> |
| 8 #include <string.h> | 8 #include <string.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 826 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 837 int64_t SSLClientSocketImpl::GetTotalReceivedBytes() const { | 837 int64_t SSLClientSocketImpl::GetTotalReceivedBytes() const { |
| 838 return transport_->socket()->GetTotalReceivedBytes(); | 838 return transport_->socket()->GetTotalReceivedBytes(); |
| 839 } | 839 } |
| 840 | 840 |
| 841 void SSLClientSocketImpl::DumpMemoryStats(SocketMemoryStats* stats) const { | 841 void SSLClientSocketImpl::DumpMemoryStats(SocketMemoryStats* stats) const { |
| 842 if (transport_adapter_) | 842 if (transport_adapter_) |
| 843 stats->buffer_size = transport_adapter_->GetAllocationSize(); | 843 stats->buffer_size = transport_adapter_->GetAllocationSize(); |
| 844 if (server_cert_chain_) { | 844 if (server_cert_chain_) { |
| 845 for (size_t i = 0; i < server_cert_chain_->size(); ++i) { | 845 for (size_t i = 0; i < server_cert_chain_->size(); ++i) { |
| 846 X509* cert = server_cert_chain_->Get(i); | 846 X509* cert = server_cert_chain_->Get(i); |
| 847 // This measures the lower bound of the serialized certificate. It doesn't | 847 // Estimate the size of the certificate before deduplication. |
| 848 // measure the actual memory used, which is 4x this amount (see | 848 // The multiplier (4) is added to account for the difference between the |
| 849 // crbug.com/671420 for more details). | 849 // serialized cert size and the actual cert allocation. |
| 850 stats->serialized_cert_size += i2d_X509(cert, nullptr); | 850 // TODO(xunjieli): Update this after crbug.com/671420 is done. |
| 851 stats->cert_size += 4 * i2d_X509(cert, nullptr); | |
|
xunjieli
2017/02/16 22:54:24
I didn't find a way to track distinct X509*. This
| |
| 851 } | 852 } |
| 852 stats->cert_count = server_cert_chain_->size(); | 853 stats->cert_count = server_cert_chain_->size(); |
| 853 } | 854 } |
| 854 stats->total_size = stats->buffer_size + stats->serialized_cert_size; | 855 stats->total_size = stats->buffer_size + stats->cert_size; |
| 855 } | 856 } |
| 856 | 857 |
| 857 // static | 858 // static |
| 858 void SSLClientSocketImpl::DumpSSLClientSessionMemoryStats( | 859 void SSLClientSocketImpl::DumpSSLClientSessionMemoryStats( |
| 859 base::trace_event::ProcessMemoryDump* pmd) { | 860 base::trace_event::ProcessMemoryDump* pmd) { |
| 860 SSLContext::GetInstance()->session_cache()->DumpMemoryStats(pmd); | 861 SSLContext::GetInstance()->session_cache()->DumpMemoryStats(pmd); |
| 861 } | 862 } |
| 862 | 863 |
| 863 int SSLClientSocketImpl::Read(IOBuffer* buf, | 864 int SSLClientSocketImpl::Read(IOBuffer* buf, |
| 864 int buf_len, | 865 int buf_len, |
| (...skipping 1178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2043 if (ERR_GET_REASON(info->error_code) == SSL_R_TLSV1_ALERT_ACCESS_DENIED && | 2044 if (ERR_GET_REASON(info->error_code) == SSL_R_TLSV1_ALERT_ACCESS_DENIED && |
| 2044 !certificate_requested_) { | 2045 !certificate_requested_) { |
| 2045 net_error = ERR_SSL_PROTOCOL_ERROR; | 2046 net_error = ERR_SSL_PROTOCOL_ERROR; |
| 2046 } | 2047 } |
| 2047 } | 2048 } |
| 2048 | 2049 |
| 2049 return net_error; | 2050 return net_error; |
| 2050 } | 2051 } |
| 2051 | 2052 |
| 2052 } // namespace net | 2053 } // namespace net |
| OLD | NEW |