Bug 1494162 - Part 45: Lazy load Menu and MenuItem in TabBar. r=pbro
[gecko.git] / netwerk / cookie / nsCookieKey.h
blob098ed3e2a7cae5832138c4a4737469580d45bce9
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef mozilla_net_nsCookieKey_h
7 #define mozilla_net_nsCookieKey_h
8 #include "nsHashKeys.h"
9 #include "nsTHashtable.h"
11 namespace mozilla {
12 namespace net {
13 class nsCookieKey : public PLDHashEntryHdr
15 public:
16 typedef const nsCookieKey& KeyType;
17 typedef const nsCookieKey* KeyTypePointer;
19 nsCookieKey() = default;
21 nsCookieKey(const nsCString &baseDomain, const OriginAttributes &attrs)
22 : mBaseDomain(baseDomain)
23 , mOriginAttributes(attrs)
26 explicit nsCookieKey(KeyTypePointer other)
27 : mBaseDomain(other->mBaseDomain)
28 , mOriginAttributes(other->mOriginAttributes)
31 nsCookieKey(nsCookieKey&& other) = default;
32 nsCookieKey& operator=(nsCookieKey&&) = default;
34 bool KeyEquals(KeyTypePointer other) const
36 return mBaseDomain == other->mBaseDomain &&
37 mOriginAttributes == other->mOriginAttributes;
40 static KeyTypePointer KeyToPointer(KeyType aKey)
42 return &aKey;
45 static PLDHashNumber HashKey(KeyTypePointer aKey)
47 nsAutoCString temp(aKey->mBaseDomain);
48 temp.Append('#');
49 nsAutoCString suffix;
50 aKey->mOriginAttributes.CreateSuffix(suffix);
51 temp.Append(suffix);
52 return mozilla::HashString(temp);
55 size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const
57 return mBaseDomain.SizeOfExcludingThisIfUnshared(aMallocSizeOf);
60 enum { ALLOW_MEMMOVE = true };
62 nsCString mBaseDomain;
63 OriginAttributes mOriginAttributes;
66 } // net
67 } // mozilla
68 #endif // mozilla_net_nsCookieKey_h