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

Side by Side Diff: net/ssl/ssl_client_session_cache.cc

Issue 2728303005: Don't use crypto/x509 in SSLClientSocketImpl. (Closed)
Patch Set: fix ios 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/ssl/ssl_client_session_cache.h" 5 #include "net/ssl/ssl_client_session_cache.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/containers/flat_set.h" 9 #include "base/containers/flat_set.h"
10 #include "base/memory/memory_coordinator_client_registry.h" 10 #include "base/memory/memory_coordinator_client_registry.h"
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 sk_CRYPTO_BUFFER_num(pair.second.session.get()->certs); 135 sk_CRYPTO_BUFFER_num(pair.second.session.get()->certs);
136 } 136 }
137 // Use a flat_set here to avoid malloc upon insertion. 137 // Use a flat_set here to avoid malloc upon insertion.
138 base::flat_set<const CRYPTO_BUFFER*> crypto_buffer_set; 138 base::flat_set<const CRYPTO_BUFFER*> crypto_buffer_set;
139 crypto_buffer_set.reserve(undeduped_cert_count); 139 crypto_buffer_set.reserve(undeduped_cert_count);
140 for (const auto& pair : cache_) { 140 for (const auto& pair : cache_) {
141 const SSL_SESSION* session = pair.second.session.get(); 141 const SSL_SESSION* session = pair.second.session.get();
142 size_t pair_cert_count = sk_CRYPTO_BUFFER_num(session->certs); 142 size_t pair_cert_count = sk_CRYPTO_BUFFER_num(session->certs);
143 for (size_t i = 0; i < pair_cert_count; ++i) { 143 for (size_t i = 0; i < pair_cert_count; ++i) {
144 const CRYPTO_BUFFER* cert = sk_CRYPTO_BUFFER_value(session->certs, i); 144 const CRYPTO_BUFFER* cert = sk_CRYPTO_BUFFER_value(session->certs, i);
145 // TODO(xunjieli): The multipler is added to account for the difference 145 undeduped_cert_size += CRYPTO_BUFFER_len(cert);
146 // between the serialized form and real cert allocation. Remove after
147 // crbug.com/671420 is done.
148 size_t individual_cert_size = 4 * CRYPTO_BUFFER_len(cert);
149 undeduped_cert_size += individual_cert_size;
150 auto result = crypto_buffer_set.insert(cert); 146 auto result = crypto_buffer_set.insert(cert);
151 if (!result.second) 147 if (!result.second)
152 continue; 148 continue;
153 cert_size += individual_cert_size; 149 cert_size += CRYPTO_BUFFER_len(cert);
154 cert_count++; 150 cert_count++;
155 } 151 }
156 } 152 }
157 cache_dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, 153 cache_dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize,
158 base::trace_event::MemoryAllocatorDump::kUnitsBytes, 154 base::trace_event::MemoryAllocatorDump::kUnitsBytes,
159 cert_size); 155 cert_size);
160 cache_dump->AddScalar("cert_size", 156 cache_dump->AddScalar("cert_size",
161 base::trace_event::MemoryAllocatorDump::kUnitsBytes, 157 base::trace_event::MemoryAllocatorDump::kUnitsBytes,
162 cert_size); 158 cert_size);
163 cache_dump->AddScalar("cert_count", 159 cache_dump->AddScalar("cert_count",
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 Flush(); 195 Flush();
200 break; 196 break;
201 } 197 }
202 } 198 }
203 199
204 void SSLClientSessionCache::OnPurgeMemory() { 200 void SSLClientSessionCache::OnPurgeMemory() {
205 Flush(); 201 Flush();
206 } 202 }
207 203
208 } // namespace net 204 } // namespace net
OLDNEW
« net/socket/ssl_client_socket_impl.cc ('K') | « net/socket/ssl_client_socket_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698