xpcom/glue/HoldDropJSObjects.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.

     1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
     3 /* This Source Code Form is subject to the terms of the Mozilla Public
     4  * License, v. 2.0. If a copy of the MPL was not distributed with this
     5  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     7 #ifndef mozilla_HoldDropJSObjects_h
     8 #define mozilla_HoldDropJSObjects_h
    10 #include "mozilla/TypeTraits.h"
    11 #include "nsCycleCollectionParticipant.h"
    13 class nsISupports;
    14 class nsScriptObjectTracer;
    16 // Only HoldJSObjects and DropJSObjects should be called directly.
    18 namespace mozilla {
    19 namespace cyclecollector {
    21 // These methods are defined in nsCycleCollector.cpp
    22 void HoldJSObjectsImpl(void* aHolder, nsScriptObjectTracer* aTracer);
    23 void HoldJSObjectsImpl(nsISupports* aHolder);
    24 void DropJSObjectsImpl(void* aHolder);
    25 void DropJSObjectsImpl(nsISupports* aHolder);
    27 } // namespace cyclecollector
    30 template<class T, bool isISupports=IsBaseOf<nsISupports, T>::value>
    31 struct HoldDropJSObjectsHelper
    32 {
    33   static void Hold(T* aHolder)
    34   {
    35     cyclecollector::HoldJSObjectsImpl(aHolder, NS_CYCLE_COLLECTION_PARTICIPANT(T));
    36   }
    37   static void Drop(T* aHolder)
    38   {
    39     cyclecollector::DropJSObjectsImpl(aHolder);
    40   }
    41 };
    43 template<class T>
    44 struct HoldDropJSObjectsHelper<T, true>
    45 {
    46   static void Hold(T* aHolder)
    47   {
    48     cyclecollector::HoldJSObjectsImpl(ToSupports(aHolder));
    49   }
    50   static void Drop(T* aHolder)
    51   {
    52     cyclecollector::DropJSObjectsImpl(ToSupports(aHolder));
    53   }
    54 };
    57 template<class T>
    58 void HoldJSObjects(T* aHolder)
    59 {
    60   HoldDropJSObjectsHelper<T>::Hold(aHolder);
    61 }
    63 template<class T>
    64 void DropJSObjects(T* aHolder)
    65 {
    66   HoldDropJSObjectsHelper<T>::Drop(aHolder);
    67 }
    69 } // namespace mozilla
    71 #endif // mozilla_HoldDropJSObjects_h

mercurial