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

Side by Side Diff: base/openssl_util.h

Issue 4646001: Implement LoadTemporaryRoot for Windows (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/net/base
Patch Set: New Win method & unittests 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | net/base/cert_database_nss_unittest.cc » ('j') | net/base/cert_test_util.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 #ifndef BASE_OPENSSL_UTIL_H_ 5 #ifndef BASE_OPENSSL_UTIL_H_
6 #define BASE_OPENSSL_UTIL_H_ 6 #define BASE_OPENSSL_UTIL_H_
7 #pragma once 7 #pragma once
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/tracked.h" 10 #include "base/tracked.h"
11 11
12 namespace base { 12 namespace base {
13 13
14 // A helper class that takes care of destroying OpenSSL objects when it goes out 14 // A helper class that takes care of destroying OpenSSL objects when it goes out
15 // of scope. 15 // of scope.
16 template <typename T, void (*destructor)(T*)> 16 template <typename T, void (*destructor)(T*)>
17 class ScopedOpenSSL { 17 class ScopedOpenSSL {
18 public: 18 public:
19 explicit ScopedOpenSSL(T* ptr_) : ptr_(ptr_) { } 19 explicit ScopedOpenSSL(T* ptr) : ptr_(ptr) {}
20 ~ScopedOpenSSL() { if (ptr_) (*destructor)(ptr_); } 20 ~ScopedOpenSSL() {
21 reset(NULL);
wtc 2010/11/23 00:30:11 Nit: since you let the argument default to NULL, y
22 }
23
24 void reset(T* p = NULL) {
25 if (ptr_ != p) {
26 (*destructor)(ptr_);
27 ptr_ = p;
28 }
29 }
21 30
22 T* get() const { return ptr_; } 31 T* get() const { return ptr_; }
23 32
24 private: 33 private:
25 T* ptr_; 34 T* ptr_;
26 }; 35 };
27 36
28 // Provides a buffer of at least MIN_SIZE bytes, for use when calling OpenSSL's 37 // Provides a buffer of at least MIN_SIZE bytes, for use when calling OpenSSL's
29 // SHA256, HMAC, etc functions, adapting the buffer sizing rules to meet those 38 // SHA256, HMAC, etc functions, adapting the buffer sizing rules to meet those
30 // of the our base wrapper APIs. 39 // of the our base wrapper APIs.
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 // OpenSSL will be properly shut down on program exit. 80 // OpenSSL will be properly shut down on program exit.
72 void EnsureOpenSSLInit(); 81 void EnsureOpenSSLInit();
73 82
74 // Drains the OpenSSL ERR_get_error stack. On a debug build the error codes 83 // Drains the OpenSSL ERR_get_error stack. On a debug build the error codes
75 // are send to VLOG(1), on a release build they are disregarded. 84 // are send to VLOG(1), on a release build they are disregarded.
76 void ClearOpenSSLERRStack(); 85 void ClearOpenSSLERRStack();
77 86
78 } // namespace base 87 } // namespace base
79 88
80 #endif // BASE_OPENSSL_UTIL_H_ 89 #endif // BASE_OPENSSL_UTIL_H_
OLDNEW
« no previous file with comments | « no previous file | net/base/cert_database_nss_unittest.cc » ('j') | net/base/cert_test_util.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698