summaryrefslogtreecommitdiffstats
path: root/caps/ContentPrincipalInfoHashKey.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
commit6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch)
treea68f146d7fa01f0134297619fbe7e33db084e0aa /caps/ContentPrincipalInfoHashKey.h
parentInitial commit. (diff)
downloadthunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.tar.xz
thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.zip
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'caps/ContentPrincipalInfoHashKey.h')
-rw-r--r--caps/ContentPrincipalInfoHashKey.h56
1 files changed, 56 insertions, 0 deletions
diff --git a/caps/ContentPrincipalInfoHashKey.h b/caps/ContentPrincipalInfoHashKey.h
new file mode 100644
index 0000000000..ed1f79852f
--- /dev/null
+++ b/caps/ContentPrincipalInfoHashKey.h
@@ -0,0 +1,56 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#ifndef CAPS_PRINCIPALHASHKEY_H_
+#define CAPS_PRINCIPALHASHKEY_H_
+
+#include "mozilla/ipc/PBackgroundSharedTypes.h"
+#include "PLDHashTable.h"
+#include "nsHashKeys.h"
+#include "nsUnicharUtils.h"
+
+namespace mozilla {
+
+class ContentPrincipalInfoHashKey : public PLDHashEntryHdr {
+ public:
+ using KeyType = const ipc::ContentPrincipalInfo&;
+ using KeyTypePointer = const ipc::ContentPrincipalInfo*;
+
+ explicit ContentPrincipalInfoHashKey(KeyTypePointer aKey)
+ : mPrincipalInfo(*aKey) {
+ MOZ_COUNT_CTOR(ContentPrincipalInfoHashKey);
+ }
+ ContentPrincipalInfoHashKey(ContentPrincipalInfoHashKey&& aOther) noexcept
+ : mPrincipalInfo(aOther.mPrincipalInfo) {
+ MOZ_COUNT_CTOR(ContentPrincipalInfoHashKey);
+ }
+
+ MOZ_COUNTED_DTOR(ContentPrincipalInfoHashKey)
+
+ KeyType GetKey() const { return mPrincipalInfo; }
+
+ bool KeyEquals(KeyTypePointer aKey) const {
+ // Mocks BasePrincipal::FastEquals()
+ return mPrincipalInfo.originNoSuffix() == aKey->originNoSuffix() &&
+ mPrincipalInfo.attrs() == aKey->attrs();
+ }
+
+ static KeyTypePointer KeyToPointer(KeyType aKey) { return &aKey; }
+ static PLDHashNumber HashKey(KeyTypePointer aKey) {
+ nsAutoCString suffix;
+ aKey->attrs().CreateSuffix(suffix);
+ return HashGeneric(HashString(aKey->originNoSuffix()), HashString(suffix));
+ }
+
+ enum { ALLOW_MEMMOVE = true };
+
+ protected:
+ const ipc::ContentPrincipalInfo mPrincipalInfo;
+};
+
+} // namespace mozilla
+
+#endif // CAPS_PRINCIPALHASHKEY_H_