| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef NET_CERT_NSS_CERT_DATABASE_CHROMEOS_TEST_UTILS_ |
| 6 #define NET_CERT_NSS_CERT_DATABASE_CHROMEOS_TEST_UTILS_ |
| 7 |
| 8 #include <string> |
| 9 |
| 10 #include "base/basictypes.h" |
| 11 #include "crypto/nss_util.h" |
| 12 #include "net/base/net_export.h" |
| 13 |
| 14 namespace net { |
| 15 |
| 16 // A ScopedTestNSSCertDatabaseChromeOS will initialize nss_util for the given |
| 17 // username_hash just like ScopedTestNSSChromeOSUser, but on destruction will |
| 18 // also clean up any NSSCertDatabaseChromeOS for that user. |
| 19 // |
| 20 // Note that constructing a ScopedTestNSSCertDatabaseChromeOS does not |
| 21 // actually create the NSSCertDatabaseChromeOS, you still need to call |
| 22 // NSSCertDatabaseChromeOS::GetForUser to create it. |
| 23 // |
| 24 // Exposed for unittests only. |
| 25 class CRYPTO_EXPORT_PRIVATE ScopedTestNSSCertDatabaseChromeOS { |
| 26 public: |
| 27 explicit ScopedTestNSSCertDatabaseChromeOS(const std::string& username_hash); |
| 28 ~ScopedTestNSSCertDatabaseChromeOS(); |
| 29 |
| 30 std::string username_hash() const { return scoped_nss_user_.username_hash(); } |
| 31 bool constructed_successfully() const { |
| 32 return scoped_nss_user_.constructed_successfully(); |
| 33 } |
| 34 |
| 35 // Completes initialization of user in nss_util. Causes any waiting nss_util |
| 36 // private slot callbacks and NSSCertDatabaseChromeOS::GetForUser callbacks to |
| 37 // run. |
| 38 void FinishInit(); |
| 39 |
| 40 private: |
| 41 crypto::ScopedTestNSSChromeOSUser scoped_nss_user_; |
| 42 |
| 43 DISALLOW_COPY_AND_ASSIGN(ScopedTestNSSCertDatabaseChromeOS); |
| 44 }; |
| 45 |
| 46 } // namespace net |
| 47 |
| 48 #endif // NET_CERT_NSS_CERT_DATABASE_CHROMEOS_TEST_UTILS_ |
| OLD | NEW |