xpcom/glue/nsCycleCollectionNoteChild.h

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

michael@0 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 // This header will be included by headers that define refpointer and array classes
michael@0 7 // in order to specialize CC helpers such as ImplCycleCollectionTraverse for them.
michael@0 8
michael@0 9 #ifndef nsCycleCollectionNoteChild_h__
michael@0 10 #define nsCycleCollectionNoteChild_h__
michael@0 11
michael@0 12 #include "nsCycleCollectionTraversalCallback.h"
michael@0 13 #include "mozilla/Likely.h"
michael@0 14 #include "mozilla/TypeTraits.h"
michael@0 15
michael@0 16 enum {
michael@0 17 CycleCollectionEdgeNameArrayFlag = 1
michael@0 18 };
michael@0 19
michael@0 20 // Just a helper for appending "[i]". Didn't want to pull in string headers here.
michael@0 21 void
michael@0 22 CycleCollectionNoteEdgeNameImpl(nsCycleCollectionTraversalCallback& aCallback,
michael@0 23 const char* aName,
michael@0 24 uint32_t aFlags = 0);
michael@0 25
michael@0 26 // Should be inlined so that in the no-debug-info case this is just a simple if().
michael@0 27 MOZ_ALWAYS_INLINE void
michael@0 28 CycleCollectionNoteEdgeName(nsCycleCollectionTraversalCallback& aCallback,
michael@0 29 const char* aName,
michael@0 30 uint32_t aFlags = 0)
michael@0 31 {
michael@0 32 if (MOZ_UNLIKELY(aCallback.WantDebugInfo())) {
michael@0 33 CycleCollectionNoteEdgeNameImpl(aCallback, aName, aFlags);
michael@0 34 }
michael@0 35 }
michael@0 36
michael@0 37 #define NS_CYCLE_COLLECTION_INNERCLASS \
michael@0 38 cycleCollection
michael@0 39
michael@0 40 #define NS_CYCLE_COLLECTION_INNERNAME \
michael@0 41 _cycleCollectorGlobal
michael@0 42
michael@0 43 #define NS_CYCLE_COLLECTION_PARTICIPANT(_class) \
michael@0 44 _class::NS_CYCLE_COLLECTION_INNERCLASS::GetParticipant()
michael@0 45
michael@0 46 template <typename T>
michael@0 47 nsISupports* ToSupports(T* p, typename T::NS_CYCLE_COLLECTION_INNERCLASS* dummy = 0)
michael@0 48 {
michael@0 49 return T::NS_CYCLE_COLLECTION_INNERCLASS::Upcast(p);
michael@0 50 }
michael@0 51
michael@0 52 // The default implementation of this class template is empty, because it
michael@0 53 // should never be used: see the partial specializations below.
michael@0 54 template <typename T,
michael@0 55 bool IsXPCOM = mozilla::IsBaseOf<nsISupports, T>::value>
michael@0 56 struct CycleCollectionNoteChildImpl
michael@0 57 {
michael@0 58 };
michael@0 59
michael@0 60 template <typename T>
michael@0 61 struct CycleCollectionNoteChildImpl<T, true>
michael@0 62 {
michael@0 63 static void Run(nsCycleCollectionTraversalCallback& aCallback, T* aChild)
michael@0 64 {
michael@0 65 aCallback.NoteXPCOMChild(ToSupports(aChild));
michael@0 66 }
michael@0 67 };
michael@0 68
michael@0 69 template <typename T>
michael@0 70 struct CycleCollectionNoteChildImpl<T, false>
michael@0 71 {
michael@0 72 static void Run(nsCycleCollectionTraversalCallback& aCallback, T* aChild)
michael@0 73 {
michael@0 74 aCallback.NoteNativeChild(aChild, NS_CYCLE_COLLECTION_PARTICIPANT(T));
michael@0 75 }
michael@0 76 };
michael@0 77
michael@0 78 template <typename T>
michael@0 79 inline void CycleCollectionNoteChild(nsCycleCollectionTraversalCallback& aCallback,
michael@0 80 T* aChild,
michael@0 81 const char* aName,
michael@0 82 uint32_t aFlags = 0)
michael@0 83 {
michael@0 84 CycleCollectionNoteEdgeName(aCallback, aName, aFlags);
michael@0 85 CycleCollectionNoteChildImpl<T>::Run(aCallback, aChild);
michael@0 86 }
michael@0 87
michael@0 88 #endif // nsCycleCollectionNoteChild_h__

mercurial