Bug 1883463 [wpt PR 44909] - Add historical test for navigator.getUserMedia, a=testonly
[gecko.git] / caps / OriginAttributesHashKey.h
blobff70c393d6eb893bcac7d740d2b65f428fd262ce
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 mozilla_OriginAttributesHashKey_h
8 #define mozilla_OriginAttributesHashKey_h
10 #include "OriginAttributes.h"
11 #include "PLDHashTable.h"
12 #include "nsHashKeys.h"
14 namespace mozilla {
16 class OriginAttributesHashKey : public PLDHashEntryHdr {
17 public:
18 using KeyType = OriginAttributes;
19 using KeyTypeRef = const KeyType&;
20 using KeyTypePointer = const KeyType*;
22 explicit OriginAttributesHashKey(KeyTypePointer aKey) {
23 mOriginAttributes = *aKey;
24 MOZ_COUNT_CTOR(OriginAttributesHashKey);
26 OriginAttributesHashKey(OriginAttributesHashKey&& aKey) noexcept {
27 mOriginAttributes = std::move(aKey.mOriginAttributes);
28 MOZ_COUNT_CTOR(OriginAttributesHashKey);
31 MOZ_COUNTED_DTOR(OriginAttributesHashKey)
33 KeyTypeRef GetKey() const { return mOriginAttributes; }
35 bool KeyEquals(KeyTypePointer aKey) const {
36 return mOriginAttributes == *aKey;
39 static KeyTypePointer KeyToPointer(KeyTypeRef aKey) { return &aKey; }
41 static PLDHashNumber HashKey(KeyTypePointer aKey) {
42 nsAutoCString suffix;
43 aKey->CreateSuffix(suffix);
44 return mozilla::HashString(suffix);
47 enum { ALLOW_MEMMOVE = true };
49 protected:
50 OriginAttributes mOriginAttributes;
53 } // namespace mozilla
55 #endif