OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "crypto/openssl_util.h" | 5 #include "crypto/openssl_util.h" |
6 | 6 |
7 #include <openssl/err.h> | 7 #include <openssl/err.h> |
8 #include <openssl/ssl.h> | 8 #include <openssl/ssl.h> |
9 #include <openssl/cpu.h> | 9 #include <openssl/cpu.h> |
10 | 10 |
(...skipping 17 matching lines...) Loading... |
28 static OpenSSLInitSingleton* GetInstance() { | 28 static OpenSSLInitSingleton* GetInstance() { |
29 // We allow the SSL environment to leak for multiple reasons: | 29 // We allow the SSL environment to leak for multiple reasons: |
30 // - it is used from a non-joinable worker thread that is not stopped on | 30 // - it is used from a non-joinable worker thread that is not stopped on |
31 // shutdown, hence may still be using OpenSSL library after the AtExit | 31 // shutdown, hence may still be using OpenSSL library after the AtExit |
32 // runner has completed. | 32 // runner has completed. |
33 // - There are other OpenSSL related singletons (e.g. the client socket | 33 // - There are other OpenSSL related singletons (e.g. the client socket |
34 // context) who's cleanup depends on the global environment here, but | 34 // context) who's cleanup depends on the global environment here, but |
35 // we can't control the order the AtExit handlers will run in so | 35 // we can't control the order the AtExit handlers will run in so |
36 // allowing the global environment to leak at least ensures it is | 36 // allowing the global environment to leak at least ensures it is |
37 // available for those other singletons to reliably cleanup. | 37 // available for those other singletons to reliably cleanup. |
38 return Singleton<OpenSSLInitSingleton, | 38 return base::Singleton< |
39 LeakySingletonTraits<OpenSSLInitSingleton> >::get(); | 39 OpenSSLInitSingleton, |
| 40 base::LeakySingletonTraits<OpenSSLInitSingleton>>::get(); |
40 } | 41 } |
41 private: | 42 private: |
42 friend struct DefaultSingletonTraits<OpenSSLInitSingleton>; | 43 friend struct base::DefaultSingletonTraits<OpenSSLInitSingleton>; |
43 OpenSSLInitSingleton() { | 44 OpenSSLInitSingleton() { |
44 #if defined(OS_ANDROID) && defined(ARCH_CPU_ARMEL) | 45 #if defined(OS_ANDROID) && defined(ARCH_CPU_ARMEL) |
45 const bool has_neon = | 46 const bool has_neon = |
46 (android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON) != 0; | 47 (android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON) != 0; |
47 // CRYPTO_set_NEON_capable is called before |SSL_library_init| because this | 48 // CRYPTO_set_NEON_capable is called before |SSL_library_init| because this |
48 // stops BoringSSL from probing for NEON support via SIGILL in the case | 49 // stops BoringSSL from probing for NEON support via SIGILL in the case |
49 // that getauxval isn't present. | 50 // that getauxval isn't present. |
50 CRYPTO_set_NEON_capable(has_neon); | 51 CRYPTO_set_NEON_capable(has_neon); |
51 // See https://code.google.com/p/chromium/issues/detail?id=341598 | 52 // See https://code.google.com/p/chromium/issues/detail?id=341598 |
52 base::CPU cpu; | 53 base::CPU cpu; |
(...skipping 37 matching lines...) Loading... |
90 std::string message; | 91 std::string message; |
91 location.Write(true, true, &message); | 92 location.Write(true, true, &message); |
92 DVLOG(1) << "OpenSSL ERR_get_error stack from " << message; | 93 DVLOG(1) << "OpenSSL ERR_get_error stack from " << message; |
93 ERR_print_errors_cb(&OpenSSLErrorCallback, NULL); | 94 ERR_print_errors_cb(&OpenSSLErrorCallback, NULL); |
94 } else { | 95 } else { |
95 ERR_clear_error(); | 96 ERR_clear_error(); |
96 } | 97 } |
97 } | 98 } |
98 | 99 |
99 } // namespace crypto | 100 } // namespace crypto |
OLD | NEW |