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

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

Issue 1892323002: Change scoped_ptr to std::unique_ptr in //net/socket. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 (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/nss_ssl_util.h" 5 #include "net/socket/nss_ssl_util.h"
6 6
7 #include <nss.h> 7 #include <nss.h>
8 #include <secerr.h> 8 #include <secerr.h>
9 #include <ssl.h> 9 #include <ssl.h>
10 #include <sslerr.h> 10 #include <sslerr.h>
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 // CiphersCopy copies the zero-terminated array |in| to |out|. It returns the 73 // CiphersCopy copies the zero-terminated array |in| to |out|. It returns the
74 // number of cipher suite ids copied. 74 // number of cipher suite ids copied.
75 size_t CiphersCopy(const uint16_t* in, uint16_t* out) { 75 size_t CiphersCopy(const uint16_t* in, uint16_t* out) {
76 for (size_t i = 0; ; i++) { 76 for (size_t i = 0; ; i++) {
77 if (in[i] == 0) 77 if (in[i] == 0)
78 return i; 78 return i;
79 out[i] = in[i]; 79 out[i] = in[i];
80 } 80 }
81 } 81 }
82 82
83 scoped_ptr<base::Value> NetLogSSLErrorCallback( 83 std::unique_ptr<base::Value> NetLogSSLErrorCallback(
84 int net_error, 84 int net_error,
85 int ssl_lib_error, 85 int ssl_lib_error,
86 NetLogCaptureMode /* capture_mode */) { 86 NetLogCaptureMode /* capture_mode */) {
87 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); 87 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
88 dict->SetInteger("net_error", net_error); 88 dict->SetInteger("net_error", net_error);
89 if (ssl_lib_error) 89 if (ssl_lib_error)
90 dict->SetInteger("ssl_lib_error", ssl_lib_error); 90 dict->SetInteger("ssl_lib_error", ssl_lib_error);
91 return std::move(dict); 91 return std::move(dict);
92 } 92 }
93 93
94 class NSSSSLInitSingleton { 94 class NSSSSLInitSingleton {
95 public: 95 public:
96 NSSSSLInitSingleton() : model_fd_(NULL) { 96 NSSSSLInitSingleton() : model_fd_(NULL) {
97 crypto::EnsureNSSInit(); 97 crypto::EnsureNSSInit();
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 static const uint16_t chacha_ciphers[] = { 150 static const uint16_t chacha_ciphers[] = {
151 TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256, 151 TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256,
152 TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256, 152 TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256,
153 TLS_DHE_RSA_WITH_CHACHA20_POLY1305_SHA256, 0, 153 TLS_DHE_RSA_WITH_CHACHA20_POLY1305_SHA256, 0,
154 }; 154 };
155 static const uint16_t aes_gcm_ciphers[] = { 155 static const uint16_t aes_gcm_ciphers[] = {
156 TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, 156 TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,
157 TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, 157 TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,
158 TLS_DHE_RSA_WITH_AES_128_GCM_SHA256, 0, 158 TLS_DHE_RSA_WITH_AES_128_GCM_SHA256, 0,
159 }; 159 };
160 scoped_ptr<uint16_t[]> ciphers(new uint16_t[num_ciphers]); 160 std::unique_ptr<uint16_t[]> ciphers(new uint16_t[num_ciphers]);
161 memcpy(ciphers.get(), ssl_ciphers, sizeof(uint16_t) * num_ciphers); 161 memcpy(ciphers.get(), ssl_ciphers, sizeof(uint16_t) * num_ciphers);
162 162
163 if (CiphersRemove(chacha_ciphers, ciphers.get(), num_ciphers) && 163 if (CiphersRemove(chacha_ciphers, ciphers.get(), num_ciphers) &&
164 CiphersRemove(aes_gcm_ciphers, ciphers.get(), num_ciphers)) { 164 CiphersRemove(aes_gcm_ciphers, ciphers.get(), num_ciphers)) {
165 CiphersCompact(ciphers.get(), num_ciphers); 165 CiphersCompact(ciphers.get(), num_ciphers);
166 166
167 const uint16_t* preference_ciphers = chacha_ciphers; 167 const uint16_t* preference_ciphers = chacha_ciphers;
168 const uint16_t* other_ciphers = aes_gcm_ciphers; 168 const uint16_t* other_ciphers = aes_gcm_ciphers;
169 base::CPU cpu; 169 base::CPU cpu;
170 170
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 LOG(WARNING) << "Unknown error " << err << " (" << err_name << ")" 373 LOG(WARNING) << "Unknown error " << err << " (" << err_name << ")"
374 << " mapped to net::ERR_FAILED"; 374 << " mapped to net::ERR_FAILED";
375 return ERR_FAILED; 375 return ERR_FAILED;
376 } 376 }
377 } 377 }
378 } 378 }
379 379
380 // Returns parameters to attach to the NetLog when we receive an error in 380 // Returns parameters to attach to the NetLog when we receive an error in
381 // response to a call to an NSS function. Used instead of 381 // response to a call to an NSS function. Used instead of
382 // NetLogSSLErrorCallback with events of type TYPE_SSL_NSS_ERROR. 382 // NetLogSSLErrorCallback with events of type TYPE_SSL_NSS_ERROR.
383 scoped_ptr<base::Value> NetLogSSLFailedNSSFunctionCallback( 383 std::unique_ptr<base::Value> NetLogSSLFailedNSSFunctionCallback(
384 const char* function, 384 const char* function,
385 const char* param, 385 const char* param,
386 int ssl_lib_error, 386 int ssl_lib_error,
387 NetLogCaptureMode /* capture_mode */) { 387 NetLogCaptureMode /* capture_mode */) {
388 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); 388 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
389 dict->SetString("function", function); 389 dict->SetString("function", function);
390 if (param[0] != '\0') 390 if (param[0] != '\0')
391 dict->SetString("param", param); 391 dict->SetString("param", param);
392 dict->SetInteger("ssl_lib_error", ssl_lib_error); 392 dict->SetInteger("ssl_lib_error", ssl_lib_error);
393 return std::move(dict); 393 return std::move(dict);
394 } 394 }
395 395
396 void LogFailedNSSFunction(const BoundNetLog& net_log, 396 void LogFailedNSSFunction(const BoundNetLog& net_log,
397 const char* function, 397 const char* function,
398 const char* param) { 398 const char* param) {
399 DCHECK(function); 399 DCHECK(function);
400 DCHECK(param); 400 DCHECK(param);
401 net_log.AddEvent( 401 net_log.AddEvent(
402 NetLog::TYPE_SSL_NSS_ERROR, 402 NetLog::TYPE_SSL_NSS_ERROR,
403 base::Bind(&NetLogSSLFailedNSSFunctionCallback, 403 base::Bind(&NetLogSSLFailedNSSFunctionCallback,
404 function, param, PR_GetError())); 404 function, param, PR_GetError()));
405 } 405 }
406 406
407 NetLog::ParametersCallback CreateNetLogSSLErrorCallback(int net_error, 407 NetLog::ParametersCallback CreateNetLogSSLErrorCallback(int net_error,
408 int ssl_lib_error) { 408 int ssl_lib_error) {
409 return base::Bind(&NetLogSSLErrorCallback, net_error, ssl_lib_error); 409 return base::Bind(&NetLogSSLErrorCallback, net_error, ssl_lib_error);
410 } 410 }
411 411
412 } // namespace net 412 } // namespace net
OLDNEW
« no previous file with comments | « net/socket/mock_client_socket_pool_manager.cc ('k') | net/socket/sequenced_socket_data_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698