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_GFX_FONTSRCPRINCIPAL_H 7 #define MOZILLA_GFX_FONTSRCPRINCIPAL_H 8 9 #include "nsCOMPtr.h" 10 #include "PLDHashTable.h" 11 12 class nsIPrincipal; 13 14 namespace mozilla { 15 namespace net { 16 class nsSimpleURI; 17 } // namespace net 18 } // namespace mozilla 19 20 /** 21 * A wrapper for an nsIPrincipal that can be used OMT, which has cached 22 * information useful for the gfxUserFontSet. 23 */ 24 class gfxFontSrcPrincipal { 25 public: 26 explicit gfxFontSrcPrincipal(nsIPrincipal* aNodePrincipal, 27 nsIPrincipal* aStoragePrincipal); 28 NS_INLINE_DECL_THREADSAFE_REFCOUNTING(gfxFontSrcPrincipal)29 NS_INLINE_DECL_THREADSAFE_REFCOUNTING(gfxFontSrcPrincipal) 30 31 nsIPrincipal* get() const { return NodePrincipal(); } 32 NodePrincipal()33 nsIPrincipal* NodePrincipal() const { return mNodePrincipal; } 34 StoragePrincipal()35 nsIPrincipal* StoragePrincipal() const { return mStoragePrincipal; } 36 37 bool Equals(gfxFontSrcPrincipal* aOther); 38 Hash()39 PLDHashNumber Hash() const { return mHash; } 40 41 private: 42 ~gfxFontSrcPrincipal(); 43 44 // The principal of the node. 45 nsCOMPtr<nsIPrincipal> mNodePrincipal; 46 47 // The principal used for storage. 48 nsCOMPtr<nsIPrincipal> mStoragePrincipal; 49 50 // Precomputed hash for mStoragePrincipal. 51 PLDHashNumber mHash; 52 }; 53 54 #endif // MOZILLA_GFX_FONTSRCPRINCIPAL_H 55