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

Unified Diff: net/base/openssl_util.h

Issue 4963002: Refactor EnsureOpenSSLInit and openssl_util into base (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review comments Created 10 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/base/cert_test_util.cc ('k') | net/base/openssl_util.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/openssl_util.h
diff --git a/net/base/openssl_util.h b/net/base/openssl_util.h
deleted file mode 100644
index d4603c6666a3db5ef2a0886bbb8fd3d0cb412ea6..0000000000000000000000000000000000000000
--- a/net/base/openssl_util.h
+++ /dev/null
@@ -1,59 +0,0 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include <openssl/ssl.h>
-
-#include "base/lock.h"
-#include "base/scoped_vector.h"
-#include "base/singleton.h"
-
-namespace net {
-
-// A helper class that takes care of destroying OpenSSL objects when it goes out
-// of scope.
-template <typename T, void (*destructor)(T*)>
-class ScopedSSL {
- public:
- explicit ScopedSSL(T* ptr_) : ptr_(ptr_) { }
- ~ScopedSSL() { if (ptr_) (*destructor)(ptr_); }
-
- T* get() const { return ptr_; }
-
- private:
- T* ptr_;
-};
-
-// Singleton for initializing / cleaning up OpenSSL and holding a X509 store.
-// Access it via GetOpenSSLInitSingleton().
-class OpenSSLInitSingleton {
- public:
- SSL_CTX* ssl_ctx() const { return ssl_ctx_.get(); }
- X509_STORE* x509_store() const { return store_.get(); }
-
- private:
- friend struct DefaultSingletonTraits<OpenSSLInitSingleton>;
- OpenSSLInitSingleton();
- ~OpenSSLInitSingleton();
-
- static void LockingCallback(int mode, int n, const char* file, int line);
- void OnLockingCallback(int mode, int n, const char* file, int line);
-
- ScopedSSL<SSL_CTX, SSL_CTX_free> ssl_ctx_;
- ScopedSSL<X509_STORE, X509_STORE_free> store_;
- // These locks are used and managed by OpenSSL via LockingCallback().
- ScopedVector<Lock> locks_;
-
- DISALLOW_COPY_AND_ASSIGN(OpenSSLInitSingleton);
-};
-
-OpenSSLInitSingleton* GetOpenSSLInitSingleton();
-
-// Initialize OpenSSL if it isn't already initialized. This must be called
-// before any other OpenSSL functions (except GetOpenSSLInitSingleton above).
-// This function is thread-safe, and OpenSSL will only ever be initialized once.
-// OpenSSL will be properly shut down on program exit.
-void EnsureOpenSSLInit();
-
-} // namespace net
-
« no previous file with comments | « net/base/cert_test_util.cc ('k') | net/base/openssl_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698