netwerk/base/public/nsURIHashKey.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
     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 #ifndef nsURIHashKey_h__
     6 #define nsURIHashKey_h__
     8 #include "pldhash.h"
     9 #include "nsCOMPtr.h"
    10 #include "nsIURI.h"
    11 #include "nsHashKeys.h"
    13 /**
    14  * Hashtable key class to use with nsTHashtable/nsBaseHashtable
    15  */
    16 class nsURIHashKey : public PLDHashEntryHdr
    17 {
    18 public:
    19     typedef nsIURI* KeyType;
    20     typedef const nsIURI* KeyTypePointer;
    22     nsURIHashKey(const nsIURI* aKey) :
    23         mKey(const_cast<nsIURI*>(aKey)) { MOZ_COUNT_CTOR(nsURIHashKey); }
    24     nsURIHashKey(const nsURIHashKey& toCopy) :
    25         mKey(toCopy.mKey) { MOZ_COUNT_CTOR(nsURIHashKey); }
    26     ~nsURIHashKey() { MOZ_COUNT_DTOR(nsURIHashKey); }
    28     nsIURI* GetKey() const { return mKey; }
    30     bool KeyEquals(const nsIURI* aKey) const {
    31         bool eq;
    32         if (NS_SUCCEEDED(mKey->Equals(const_cast<nsIURI*>(aKey), &eq))) {
    33             return eq;
    34         }
    35         return false;
    36     }
    38     static const nsIURI* KeyToPointer(nsIURI* aKey) { return aKey; }
    39     static PLDHashNumber HashKey(const nsIURI* aKey) {
    40         nsAutoCString spec;
    41         const_cast<nsIURI*>(aKey)->GetSpec(spec);
    42         return mozilla::HashString(spec);
    43     }
    45     enum { ALLOW_MEMMOVE = true };
    47 protected:
    48     nsCOMPtr<nsIURI> mKey;
    49 };
    51 #endif // nsURIHashKey_h__

mercurial