Backed out changeset f53842753805 (bug 1804872) for causing reftest failures on 15535...
[gecko.git] / security / manager / ssl / KeychainSecret.h
blobb31522b7dd75048ee0606941c8f7caf25d547b25
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef KeychainSecret_h
8 #define KeychainSecret_h
10 #include "CoreFoundation/CFBase.h"
12 #include "OSKeyStore.h"
13 #include "nsString.h"
15 template <typename T>
16 class ScopedCFType {
17 public:
18 explicit ScopedCFType(T value) : mValue(value) {}
20 ~ScopedCFType() {
21 if (mValue) {
22 CFRelease((CFTypeRef)mValue);
26 T get() { return mValue; }
28 explicit operator bool() const { return mValue != nullptr; }
30 private:
31 T mValue;
34 class KeychainSecret final : public AbstractOSKeyStore {
35 public:
36 KeychainSecret();
38 virtual nsresult RetrieveSecret(const nsACString& label,
39 /* out */ nsACString& secret) override;
40 virtual nsresult StoreSecret(const nsACString& secret,
41 const nsACString& label) override;
42 virtual nsresult DeleteSecret(const nsACString& label) override;
43 virtual nsresult Lock() override;
44 virtual nsresult Unlock() override;
46 virtual ~KeychainSecret();
49 #endif // KeychainSecret_h