Bug 1935611 - Fix libyuv/libpng link failed for loongarch64. r=glandium,tnikkel,ng
[gecko.git] / security / manager / ssl / nsCertTree.h
blobd7fd86216cccfd6eed3296e70d51f92d01df2c53
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #ifndef _NS_CERTTREE_H_
6 #define _NS_CERTTREE_H_
8 #include "nsCOMPtr.h"
9 #include "nsICertTree.h"
10 #include "nsITreeSelection.h"
11 #include "nsIMutableArray.h"
12 #include "nsNSSComponent.h"
13 #include "nsTArray.h"
14 #include "PLDHashTable.h"
15 #include "mozilla/Attributes.h"
17 /* Disable the "base class XXX should be explicitly initialized
18 in the copy constructor" warning. */
19 #if defined(__clang__)
20 # pragma clang diagnostic push
21 # pragma clang diagnostic ignored "-Wextra"
22 #elif defined(__GNUC__)
23 # pragma GCC diagnostic push
24 # pragma GCC diagnostic ignored "-Wextra"
25 #endif // __clang__ || __GNUC__
27 #include "mozilla/dom/XULTreeElement.h"
29 #if defined(__clang__)
30 # pragma clang diagnostic pop
31 #elif defined(__GNUC__)
32 # pragma GCC diagnostic pop
33 #endif // __clang__ || __GNUC__
35 typedef struct treeArrayElStr treeArrayEl;
37 struct CompareCacheHashEntry {
38 enum { max_criterions = 3 };
39 CompareCacheHashEntry();
41 void* key; // no ownership
42 bool mCritInit[max_criterions];
43 nsString mCrit[max_criterions];
46 struct CompareCacheHashEntryPtr : PLDHashEntryHdr {
47 CompareCacheHashEntryPtr();
48 ~CompareCacheHashEntryPtr();
49 CompareCacheHashEntry* entry;
52 class nsCertTreeDispInfo : public nsICertTreeItem {
53 protected:
54 virtual ~nsCertTreeDispInfo();
56 public:
57 explicit nsCertTreeDispInfo(nsIX509Cert* aCert) : mCert(aCert) {}
59 NS_DECL_ISUPPORTS
60 NS_DECL_NSICERTTREEITEM
62 nsCOMPtr<nsIX509Cert> mCert;
65 class nsCertTree : public nsICertTree {
66 public:
67 NS_DECL_ISUPPORTS
68 NS_DECL_NSICERTTREE
69 NS_DECL_NSITREEVIEW
71 nsCertTree();
73 enum sortCriterion {
74 sort_IssuerOrg,
75 sort_Org,
76 sort_Token,
77 sort_CommonName,
78 sort_IssuedDateDescending,
79 sort_Email,
80 sort_None
83 protected:
84 virtual ~nsCertTree();
86 void ClearCompareHash();
87 void RemoveCacheEntry(void* key);
89 typedef int (*nsCertCompareFunc)(void*, nsIX509Cert* a, nsIX509Cert* b);
91 static CompareCacheHashEntry* getCacheEntry(void* cache, void* aCert);
92 static void CmpInitCriterion(nsIX509Cert* cert, CompareCacheHashEntry* entry,
93 sortCriterion crit, int32_t level);
94 static int32_t CmpByCrit(nsIX509Cert* a, CompareCacheHashEntry* ace,
95 nsIX509Cert* b, CompareCacheHashEntry* bce,
96 sortCriterion crit, int32_t level);
97 static int32_t CmpBy(void* cache, nsIX509Cert* a, nsIX509Cert* b,
98 sortCriterion c0, sortCriterion c1, sortCriterion c2);
99 static int32_t CmpCACert(void* cache, nsIX509Cert* a, nsIX509Cert* b);
100 static int32_t CmpUserCert(void* cache, nsIX509Cert* a, nsIX509Cert* b);
101 static int32_t CmpEmailCert(void* cache, nsIX509Cert* a, nsIX509Cert* b);
102 nsCertCompareFunc GetCompareFuncFromCertType(uint32_t aType);
103 int32_t CountOrganizations();
105 private:
106 static const uint32_t kInitialCacheLength = 64;
108 nsTArray<RefPtr<nsCertTreeDispInfo>> mDispInfo;
109 RefPtr<mozilla::dom::XULTreeElement> mTree;
110 nsCOMPtr<nsITreeSelection> mSelection;
111 treeArrayEl* mTreeArray;
112 int32_t mNumOrgs;
113 int32_t mNumRows;
114 PLDHashTable mCompareCache;
116 treeArrayEl* GetThreadDescAtIndex(int32_t _index);
117 already_AddRefed<nsIX509Cert> GetCertAtIndex(
118 int32_t _index, int32_t* outAbsoluteCertOffset = nullptr);
119 already_AddRefed<nsCertTreeDispInfo> GetDispInfoAtIndex(
120 int32_t index, int32_t* outAbsoluteCertOffset = nullptr);
121 void FreeCertArray();
122 nsresult UpdateUIContents();
124 nsresult GetCertsByTypeFromCertList(
125 const nsTArray<RefPtr<nsIX509Cert>>& aCertList, uint32_t aWantedType,
126 nsCertCompareFunc aCertCmpFn, void* aCertCmpFnArg);
128 nsCOMPtr<nsIMutableArray> mCellText;
131 #endif /* _NS_CERTTREE_H_ */