blob: c01653f836fdb2cda1f31bbfdd85c4a1678adc46 [file] [log] [blame]
[email protected]190933f2014-07-28 09:56:511// Copyright 2014 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 CRYPTO_SCOPED_TEST_NSS_DB_H_
6#define CRYPTO_SCOPED_TEST_NSS_DB_H_
7
8#include "base/files/scoped_temp_dir.h"
9#include "base/macros.h"
10#include "crypto/crypto_export.h"
11#include "crypto/scoped_nss_types.h"
12
13namespace crypto {
14
15// Opens a persistent NSS database in a temporary directory.
16// Prior NSS version 3.15.1, because of http://bugzil.la/875601 , the opened DB
17// will not be closed automatically.
xhwang3e9ca562015-11-06 18:50:3618class CRYPTO_EXPORT ScopedTestNSSDB {
[email protected]190933f2014-07-28 09:56:5119 public:
20 ScopedTestNSSDB();
21 ~ScopedTestNSSDB();
22
dcheng5d64b522016-01-20 01:41:0223 bool is_open() const { return !!slot_; }
[email protected]442233d42014-08-02 07:37:2424 PK11SlotInfo* slot() const { return slot_.get(); }
[email protected]190933f2014-07-28 09:56:5125
26 private:
27 base::ScopedTempDir temp_dir_;
28 ScopedPK11Slot slot_;
29
30 DISALLOW_COPY_AND_ASSIGN(ScopedTestNSSDB);
31};
32
33} // namespace crypto
34
35#endif // CRYPTO_SCOPED_TEST_NSS_DB_H_