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

Unified Diff: net/cert/nss_cert_database_chromeos_test_utils.h

Issue 111273002: NSSCertDatabaseChromeOS (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: gcc fix Created 7 years 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
Index: net/cert/nss_cert_database_chromeos_test_utils.h
diff --git a/net/cert/nss_cert_database_chromeos_test_utils.h b/net/cert/nss_cert_database_chromeos_test_utils.h
new file mode 100644
index 0000000000000000000000000000000000000000..6a7bffef4ddab47dda2532c7270533b6f79c4761
--- /dev/null
+++ b/net/cert/nss_cert_database_chromeos_test_utils.h
@@ -0,0 +1,48 @@
+// Copyright (c) 2013 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.
+
+#ifndef NET_CERT_NSS_CERT_DATABASE_CHROMEOS_TEST_UTILS_
+#define NET_CERT_NSS_CERT_DATABASE_CHROMEOS_TEST_UTILS_
+
+#include <string>
+
+#include "base/basictypes.h"
+#include "crypto/nss_util.h"
+#include "net/base/net_export.h"
+
+namespace net {
+
+// A ScopedTestNSSCertDatabaseChromeOS will initialize nss_util for the given
+// username_hash just like ScopedTestNSSChromeOSUser, but on destruction will
+// also clean up any NSSCertDatabaseChromeOS for that user.
+//
+// Note that constructing a ScopedTestNSSCertDatabaseChromeOS does not
+// actually create the NSSCertDatabaseChromeOS, you still need to call
+// NSSCertDatabaseChromeOS::GetForUser to create it.
+//
+// Exposed for unittests only.
+class CRYPTO_EXPORT_PRIVATE ScopedTestNSSCertDatabaseChromeOS {
+ public:
+ explicit ScopedTestNSSCertDatabaseChromeOS(const std::string& username_hash);
+ ~ScopedTestNSSCertDatabaseChromeOS();
+
+ std::string username_hash() const { return scoped_nss_user_.username_hash(); }
+ bool constructed_successfully() const {
+ return scoped_nss_user_.constructed_successfully();
+ }
+
+ // Completes initialization of user in nss_util. Causes any waiting nss_util
+ // private slot callbacks and NSSCertDatabaseChromeOS::GetForUser callbacks to
+ // run.
+ void FinishInit();
+
+ private:
+ crypto::ScopedTestNSSChromeOSUser scoped_nss_user_;
+
+ DISALLOW_COPY_AND_ASSIGN(ScopedTestNSSCertDatabaseChromeOS);
+};
+
+} // namespace net
+
+#endif // NET_CERT_NSS_CERT_DATABASE_CHROMEOS_TEST_UTILS_

Powered by Google App Engine
This is Rietveld 408576698