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

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

Issue 2696403007: Add a multiplier in tracking certificate memory allocation size (Closed)
Patch Set: self Created 3 years, 9 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/client_socket_pool_base.cc ('k') | net/socket/ssl_client_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_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 827 matching lines...) Expand 10 before | Expand all | Expand 10 after
838 int64_t SSLClientSocketImpl::GetTotalReceivedBytes() const { 838 int64_t SSLClientSocketImpl::GetTotalReceivedBytes() const {
839 return transport_->socket()->GetTotalReceivedBytes(); 839 return transport_->socket()->GetTotalReceivedBytes();
840 } 840 }
841 841
842 void SSLClientSocketImpl::DumpMemoryStats(SocketMemoryStats* stats) const { 842 void SSLClientSocketImpl::DumpMemoryStats(SocketMemoryStats* stats) const {
843 if (transport_adapter_) 843 if (transport_adapter_)
844 stats->buffer_size = transport_adapter_->GetAllocationSize(); 844 stats->buffer_size = transport_adapter_->GetAllocationSize();
845 if (server_cert_chain_) { 845 if (server_cert_chain_) {
846 for (size_t i = 0; i < server_cert_chain_->size(); ++i) { 846 for (size_t i = 0; i < server_cert_chain_->size(); ++i) {
847 X509* cert = server_cert_chain_->Get(i); 847 X509* cert = server_cert_chain_->Get(i);
848 // This measures the lower bound of the serialized certificate. It doesn't 848 // Estimate the size of the certificate before deduplication.
849 // measure the actual memory used, which is 4x this amount (see 849 // The multiplier (4) is added to account for the difference between the
850 // crbug.com/671420 for more details). 850 // serialized cert size and the actual cert allocation.
851 stats->serialized_cert_size += i2d_X509(cert, nullptr); 851 // TODO(xunjieli): Update this after crbug.com/671420 is done.
852 stats->cert_size += 4 * i2d_X509(cert, nullptr);
852 } 853 }
853 stats->cert_count = server_cert_chain_->size(); 854 stats->cert_count = server_cert_chain_->size();
854 } 855 }
855 stats->total_size = stats->buffer_size + stats->serialized_cert_size; 856 stats->total_size = stats->buffer_size + stats->cert_size;
856 } 857 }
857 858
858 // static 859 // static
859 void SSLClientSocketImpl::DumpSSLClientSessionMemoryStats( 860 void SSLClientSocketImpl::DumpSSLClientSessionMemoryStats(
860 base::trace_event::ProcessMemoryDump* pmd) { 861 base::trace_event::ProcessMemoryDump* pmd) {
861 SSLContext::GetInstance()->session_cache()->DumpMemoryStats(pmd); 862 SSLContext::GetInstance()->session_cache()->DumpMemoryStats(pmd);
862 } 863 }
863 864
864 int SSLClientSocketImpl::Read(IOBuffer* buf, 865 int SSLClientSocketImpl::Read(IOBuffer* buf,
865 int buf_len, 866 int buf_len,
(...skipping 1184 matching lines...) Expand 10 before | Expand all | Expand 10 after
2050 if (ERR_GET_REASON(info->error_code) == SSL_R_TLSV1_ALERT_ACCESS_DENIED && 2051 if (ERR_GET_REASON(info->error_code) == SSL_R_TLSV1_ALERT_ACCESS_DENIED &&
2051 !certificate_requested_) { 2052 !certificate_requested_) {
2052 net_error = ERR_SSL_PROTOCOL_ERROR; 2053 net_error = ERR_SSL_PROTOCOL_ERROR;
2053 } 2054 }
2054 } 2055 }
2055 2056
2056 return net_error; 2057 return net_error;
2057 } 2058 }
2058 2059
2059 } // namespace net 2060 } // namespace net
OLDNEW
« no previous file with comments | « net/socket/client_socket_pool_base.cc ('k') | net/socket/ssl_client_socket_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698