Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/netwerk/cookie/nsCookieKey.h
Line
Count
Source (jump to first uncovered line)
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/. */
5
6
#ifndef mozilla_net_nsCookieKey_h
7
#define mozilla_net_nsCookieKey_h
8
#include "nsHashKeys.h"
9
#include "nsTHashtable.h"
10
11
namespace mozilla {
12
namespace net {
13
class nsCookieKey : public PLDHashEntryHdr
14
{
15
public:
16
  typedef const nsCookieKey& KeyType;
17
  typedef const nsCookieKey* KeyTypePointer;
18
19
0
  nsCookieKey() = default;
20
21
  nsCookieKey(const nsCString &baseDomain, const OriginAttributes &attrs)
22
    : mBaseDomain(baseDomain)
23
    , mOriginAttributes(attrs)
24
0
  {}
25
26
  explicit nsCookieKey(KeyTypePointer other)
27
    : mBaseDomain(other->mBaseDomain)
28
    , mOriginAttributes(other->mOriginAttributes)
29
0
  {}
30
31
  nsCookieKey(nsCookieKey&& other) = default;
32
0
  nsCookieKey& operator=(nsCookieKey&&) = default;
33
34
  bool KeyEquals(KeyTypePointer other) const
35
0
  {
36
0
    return mBaseDomain == other->mBaseDomain &&
37
0
           mOriginAttributes == other->mOriginAttributes;
38
0
  }
39
40
  static KeyTypePointer KeyToPointer(KeyType aKey)
41
0
  {
42
0
    return &aKey;
43
0
  }
44
45
  static PLDHashNumber HashKey(KeyTypePointer aKey)
46
0
  {
47
0
    nsAutoCString temp(aKey->mBaseDomain);
48
0
    temp.Append('#');
49
0
    nsAutoCString suffix;
50
0
    aKey->mOriginAttributes.CreateSuffix(suffix);
51
0
    temp.Append(suffix);
52
0
    return mozilla::HashString(temp);
53
0
  }
54
55
  size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const
56
0
  {
57
0
    return mBaseDomain.SizeOfExcludingThisIfUnshared(aMallocSizeOf);
58
0
  }
59
60
  enum { ALLOW_MEMMOVE = true };
61
62
  nsCString        mBaseDomain;
63
  OriginAttributes mOriginAttributes;
64
};
65
66
} // net
67
} // mozilla
68
#endif // mozilla_net_nsCookieKey_h