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 24 matching lines...) Expand all Loading... |
35 static OpenSSLInitSingleton* GetInstance() { | 35 static OpenSSLInitSingleton* GetInstance() { |
36 // We allow the SSL environment to leak for multiple reasons: | 36 // We allow the SSL environment to leak for multiple reasons: |
37 // - it is used from a non-joinable worker thread that is not stopped on | 37 // - it is used from a non-joinable worker thread that is not stopped on |
38 // shutdown, hence may still be using OpenSSL library after the AtExit | 38 // shutdown, hence may still be using OpenSSL library after the AtExit |
39 // runner has completed. | 39 // runner has completed. |
40 // - There are other OpenSSL related singletons (e.g. the client socket | 40 // - There are other OpenSSL related singletons (e.g. the client socket |
41 // context) who's cleanup depends on the global environment here, but | 41 // context) who's cleanup depends on the global environment here, but |
42 // we can't control the order the AtExit handlers will run in so | 42 // we can't control the order the AtExit handlers will run in so |
43 // allowing the global environment to leak at least ensures it is | 43 // allowing the global environment to leak at least ensures it is |
44 // available for those other singletons to reliably cleanup. | 44 // available for those other singletons to reliably cleanup. |
45 return Singleton<OpenSSLInitSingleton, | 45 return base::Singleton< |
46 LeakySingletonTraits<OpenSSLInitSingleton> >::get(); | 46 OpenSSLInitSingleton, |
| 47 base::LeakySingletonTraits<OpenSSLInitSingleton>>::get(); |
47 } | 48 } |
48 private: | 49 private: |
49 friend struct DefaultSingletonTraits<OpenSSLInitSingleton>; | 50 friend struct base::DefaultSingletonTraits<OpenSSLInitSingleton>; |
50 OpenSSLInitSingleton() { | 51 OpenSSLInitSingleton() { |
51 #if defined(OS_ANDROID) && defined(ARCH_CPU_ARMEL) | 52 #if defined(OS_ANDROID) && defined(ARCH_CPU_ARMEL) |
52 const bool has_neon = | 53 const bool has_neon = |
53 (android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON) != 0; | 54 (android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON) != 0; |
54 // CRYPTO_set_NEON_capable is called before |SSL_library_init| because this | 55 // CRYPTO_set_NEON_capable is called before |SSL_library_init| because this |
55 // stops BoringSSL from probing for NEON support via SIGILL in the case | 56 // stops BoringSSL from probing for NEON support via SIGILL in the case |
56 // that getauxval isn't present. | 57 // that getauxval isn't present. |
57 CRYPTO_set_NEON_capable(has_neon); | 58 CRYPTO_set_NEON_capable(has_neon); |
58 // See https://code.google.com/p/chromium/issues/detail?id=341598 | 59 // See https://code.google.com/p/chromium/issues/detail?id=341598 |
59 base::CPU cpu; | 60 base::CPU cpu; |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 std::string message; | 124 std::string message; |
124 location.Write(true, true, &message); | 125 location.Write(true, true, &message); |
125 DVLOG(1) << "OpenSSL ERR_get_error stack from " << message; | 126 DVLOG(1) << "OpenSSL ERR_get_error stack from " << message; |
126 ERR_print_errors_cb(&OpenSSLErrorCallback, NULL); | 127 ERR_print_errors_cb(&OpenSSLErrorCallback, NULL); |
127 } else { | 128 } else { |
128 ERR_clear_error(); | 129 ERR_clear_error(); |
129 } | 130 } |
130 } | 131 } |
131 | 132 |
132 } // namespace crypto | 133 } // namespace crypto |
OLD | NEW |