[DevTools] Implement DevToolsManager::Observer which notifies about target updates.
[chromium-blink-merge.git] / crypto / scoped_test_system_nss_key_slot.h
blobac3b72c4ce0bd1f4b7940c40aba78d52fcb25019
1 // 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.
5 #ifndef CRYPTO_SCOPED_TEST_SYSTEM_NSS_KEY_SLOT_H_
6 #define CRYPTO_SCOPED_TEST_SYSTEM_NSS_KEY_SLOT_H_
8 #include "base/macros.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "crypto/crypto_export.h"
12 // Forward declaration, from <pk11pub.h>
13 typedef struct PK11SlotInfoStr PK11SlotInfo;
15 namespace crypto {
17 class ScopedTestNSSDB;
19 // Opens a persistent NSS software database in a temporary directory and sets
20 // the test system slot to the opened database. This helper should be created in
21 // tests to fake the system token that is usually provided by the Chaps module.
22 // |slot| is exposed through |GetSystemNSSKeySlot| and |IsTPMTokenReady| will
23 // return true.
24 // |InitializeTPMTokenAndSystemSlot|, which triggers the TPM initialization,
25 // does not have to be called if this helper is used.
26 // At most one instance of this helper must be used at a time.
27 class CRYPTO_EXPORT_PRIVATE ScopedTestSystemNSSKeySlot {
28 public:
29 explicit ScopedTestSystemNSSKeySlot();
30 ~ScopedTestSystemNSSKeySlot();
32 bool ConstructedSuccessfully() const;
33 PK11SlotInfo* slot() const;
35 private:
36 scoped_ptr<ScopedTestNSSDB> test_db_;
38 DISALLOW_COPY_AND_ASSIGN(ScopedTestSystemNSSKeySlot);
41 } // namespace crypto
43 #endif // CRYPTO_SCOPED_TEST_SYSTEM_NSS_KEY_SLOT_H_