Bug 1935611 - Fix libyuv/libpng link failed for loongarch64. r=glandium,tnikkel,ng
[gecko.git] / security / manager / ssl / nsClientAuthRemember.h
blob36383ad1a30c9a16a6f77aa424aba37c59b8c539
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 __NSCLIENTAUTHREMEMBER_H__
8 #define __NSCLIENTAUTHREMEMBER_H__
10 #include <utility>
12 #include "mozilla/Attributes.h"
13 #include "mozilla/DataMutex.h"
14 #include "mozilla/HashFunctions.h"
15 #include "mozilla/ReentrantMonitor.h"
16 #include "nsIClientAuthRememberService.h"
17 #include "nsIDataStorage.h"
18 #include "nsIObserver.h"
19 #include "nsNSSCertificate.h"
20 #include "nsString.h"
21 #include "nsTHashtable.h"
22 #include "nsWeakReference.h"
24 namespace mozilla {
25 class OriginAttributes;
28 using mozilla::OriginAttributes;
30 class nsClientAuthRemember final : public nsIClientAuthRememberRecord {
31 public:
32 NS_DECL_THREADSAFE_ISUPPORTS
33 NS_DECL_NSICLIENTAUTHREMEMBERRECORD
35 nsClientAuthRemember(const nsACString& aHostName,
36 const OriginAttributes& aOriginAttributes) {
37 mAsciiHost.Assign(aHostName);
38 aOriginAttributes.CreateSuffix(mOriginAttributesSuffix);
41 nsClientAuthRemember(const nsCString& aEntryKey, const nsCString& aDBKey) {
42 if (!aDBKey.Equals(nsClientAuthRemember::SentinelValue)) {
43 mDBKey = aDBKey;
46 size_t field_index = 0;
47 for (const auto& field : aEntryKey.Split(',')) {
48 switch (field_index) {
49 case 0:
50 mAsciiHost.Assign(field);
51 break;
52 case 1:
53 break;
54 case 2:
55 mOriginAttributesSuffix.Assign(field);
56 break;
57 default:
58 break;
60 field_index++;
64 nsCString mAsciiHost;
65 nsCString mOriginAttributesSuffix;
66 nsCString mDBKey;
67 static constexpr nsLiteralCString SentinelValue = "no client certificate"_ns;
69 protected:
70 ~nsClientAuthRemember() = default;
73 class nsClientAuthRememberService final : public nsIClientAuthRememberService {
74 public:
75 NS_DECL_THREADSAFE_ISUPPORTS
76 NS_DECL_NSICLIENTAUTHREMEMBERSERVICE
78 nsClientAuthRememberService()
79 : mMigrated(false, "nsClientAuthRememberService::mMigrated") {}
81 nsresult Init();
83 static bool IsPrivateBrowsingKey(const nsCString& entryKey);
85 protected:
86 ~nsClientAuthRememberService() = default;
88 static nsIDataStorage::DataType GetDataStorageType(
89 const OriginAttributes& aOriginAttributes);
91 nsCOMPtr<nsIDataStorage> mClientAuthRememberList;
93 nsresult AddEntryToList(const nsACString& aHost,
94 const OriginAttributes& aOriginAttributes,
95 const nsACString& aDBKey);
97 mozilla::DataMutex<bool> mMigrated;
98 void Migrate();
101 #endif