Bug 1827566 - Isolate SSE2 requirements to SSE-compiled file r=glandium
[gecko.git] / caps / ContentPrincipalInfoHashKey.h
blobed1f79852f15313a3e35e2d637959a2e0234d20e
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
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 CAPS_PRINCIPALHASHKEY_H_
8 #define CAPS_PRINCIPALHASHKEY_H_
10 #include "mozilla/ipc/PBackgroundSharedTypes.h"
11 #include "PLDHashTable.h"
12 #include "nsHashKeys.h"
13 #include "nsUnicharUtils.h"
15 namespace mozilla {
17 class ContentPrincipalInfoHashKey : public PLDHashEntryHdr {
18 public:
19 using KeyType = const ipc::ContentPrincipalInfo&;
20 using KeyTypePointer = const ipc::ContentPrincipalInfo*;
22 explicit ContentPrincipalInfoHashKey(KeyTypePointer aKey)
23 : mPrincipalInfo(*aKey) {
24 MOZ_COUNT_CTOR(ContentPrincipalInfoHashKey);
26 ContentPrincipalInfoHashKey(ContentPrincipalInfoHashKey&& aOther) noexcept
27 : mPrincipalInfo(aOther.mPrincipalInfo) {
28 MOZ_COUNT_CTOR(ContentPrincipalInfoHashKey);
31 MOZ_COUNTED_DTOR(ContentPrincipalInfoHashKey)
33 KeyType GetKey() const { return mPrincipalInfo; }
35 bool KeyEquals(KeyTypePointer aKey) const {
36 // Mocks BasePrincipal::FastEquals()
37 return mPrincipalInfo.originNoSuffix() == aKey->originNoSuffix() &&
38 mPrincipalInfo.attrs() == aKey->attrs();
41 static KeyTypePointer KeyToPointer(KeyType aKey) { return &aKey; }
42 static PLDHashNumber HashKey(KeyTypePointer aKey) {
43 nsAutoCString suffix;
44 aKey->attrs().CreateSuffix(suffix);
45 return HashGeneric(HashString(aKey->originNoSuffix()), HashString(suffix));
48 enum { ALLOW_MEMMOVE = true };
50 protected:
51 const ipc::ContentPrincipalInfo mPrincipalInfo;
54 } // namespace mozilla
56 #endif // CAPS_PRINCIPALHASHKEY_H_