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/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> |
11 #include <sslproto.h> | 11 #include <sslproto.h> |
12 | 12 |
13 #include <string> | 13 #include <string> |
| 14 #include <utility> |
14 | 15 |
15 #include "base/bind.h" | 16 #include "base/bind.h" |
16 #include "base/cpu.h" | 17 #include "base/cpu.h" |
17 #include "base/lazy_instance.h" | 18 #include "base/lazy_instance.h" |
18 #include "base/logging.h" | 19 #include "base/logging.h" |
19 #include "base/memory/singleton.h" | 20 #include "base/memory/singleton.h" |
20 #include "base/threading/thread_restrictions.h" | 21 #include "base/threading/thread_restrictions.h" |
21 #include "base/values.h" | 22 #include "base/values.h" |
22 #include "build/build_config.h" | 23 #include "build/build_config.h" |
23 #include "crypto/nss_util.h" | 24 #include "crypto/nss_util.h" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 } | 81 } |
81 | 82 |
82 scoped_ptr<base::Value> NetLogSSLErrorCallback( | 83 scoped_ptr<base::Value> NetLogSSLErrorCallback( |
83 int net_error, | 84 int net_error, |
84 int ssl_lib_error, | 85 int ssl_lib_error, |
85 NetLogCaptureMode /* capture_mode */) { | 86 NetLogCaptureMode /* capture_mode */) { |
86 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | 87 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
87 dict->SetInteger("net_error", net_error); | 88 dict->SetInteger("net_error", net_error); |
88 if (ssl_lib_error) | 89 if (ssl_lib_error) |
89 dict->SetInteger("ssl_lib_error", ssl_lib_error); | 90 dict->SetInteger("ssl_lib_error", ssl_lib_error); |
90 return dict.Pass(); | 91 return std::move(dict); |
91 } | 92 } |
92 | 93 |
93 class NSSSSLInitSingleton { | 94 class NSSSSLInitSingleton { |
94 public: | 95 public: |
95 NSSSSLInitSingleton() : model_fd_(NULL) { | 96 NSSSSLInitSingleton() : model_fd_(NULL) { |
96 crypto::EnsureNSSInit(); | 97 crypto::EnsureNSSInit(); |
97 | 98 |
98 NSS_SetDomesticPolicy(); | 99 NSS_SetDomesticPolicy(); |
99 | 100 |
100 const PRUint16* const ssl_ciphers = SSL_GetImplementedCiphers(); | 101 const PRUint16* const ssl_ciphers = SSL_GetImplementedCiphers(); |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
381 scoped_ptr<base::Value> NetLogSSLFailedNSSFunctionCallback( | 382 scoped_ptr<base::Value> NetLogSSLFailedNSSFunctionCallback( |
382 const char* function, | 383 const char* function, |
383 const char* param, | 384 const char* param, |
384 int ssl_lib_error, | 385 int ssl_lib_error, |
385 NetLogCaptureMode /* capture_mode */) { | 386 NetLogCaptureMode /* capture_mode */) { |
386 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | 387 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
387 dict->SetString("function", function); | 388 dict->SetString("function", function); |
388 if (param[0] != '\0') | 389 if (param[0] != '\0') |
389 dict->SetString("param", param); | 390 dict->SetString("param", param); |
390 dict->SetInteger("ssl_lib_error", ssl_lib_error); | 391 dict->SetInteger("ssl_lib_error", ssl_lib_error); |
391 return dict.Pass(); | 392 return std::move(dict); |
392 } | 393 } |
393 | 394 |
394 void LogFailedNSSFunction(const BoundNetLog& net_log, | 395 void LogFailedNSSFunction(const BoundNetLog& net_log, |
395 const char* function, | 396 const char* function, |
396 const char* param) { | 397 const char* param) { |
397 DCHECK(function); | 398 DCHECK(function); |
398 DCHECK(param); | 399 DCHECK(param); |
399 net_log.AddEvent( | 400 net_log.AddEvent( |
400 NetLog::TYPE_SSL_NSS_ERROR, | 401 NetLog::TYPE_SSL_NSS_ERROR, |
401 base::Bind(&NetLogSSLFailedNSSFunctionCallback, | 402 base::Bind(&NetLogSSLFailedNSSFunctionCallback, |
402 function, param, PR_GetError())); | 403 function, param, PR_GetError())); |
403 } | 404 } |
404 | 405 |
405 NetLog::ParametersCallback CreateNetLogSSLErrorCallback(int net_error, | 406 NetLog::ParametersCallback CreateNetLogSSLErrorCallback(int net_error, |
406 int ssl_lib_error) { | 407 int ssl_lib_error) { |
407 return base::Bind(&NetLogSSLErrorCallback, net_error, ssl_lib_error); | 408 return base::Bind(&NetLogSSLErrorCallback, net_error, ssl_lib_error); |
408 } | 409 } |
409 | 410 |
410 } // namespace net | 411 } // namespace net |
OLD | NEW |