dom/bindings/UnionMember.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 /* A class for holding the members of a union. */
     9 #ifndef mozilla_dom_UnionMember_h
    10 #define mozilla_dom_UnionMember_h
    12 #include "mozilla/Alignment.h"
    14 namespace mozilla {
    15 namespace dom {
    17 // The union type has an enum to keep track of which of its UnionMembers has
    18 // been constructed.
    19 template<class T>
    20 class UnionMember
    21 {
    22   AlignedStorage2<T> mStorage;
    24 public:
    25   T& SetValue()
    26   {
    27     new (mStorage.addr()) T();
    28     return *mStorage.addr();
    29   }
    30   template <typename T1>
    31   T& SetValue(const T1& aValue)
    32   {
    33     new (mStorage.addr()) T(aValue);
    34     return *mStorage.addr();
    35   }
    36   template<typename T1, typename T2>
    37   T& SetValue(const T1& aValue1, const T2& aValue2)
    38   {
    39     new (mStorage.addr()) T(aValue1, aValue2);
    40     return *mStorage.addr();
    41   }
    42   T& Value()
    43   {
    44     return *mStorage.addr();
    45   }
    46   const T& Value() const
    47   {
    48     return *mStorage.addr();
    49   }
    50   void Destroy()
    51   {
    52     mStorage.addr()->~T();
    53   }
    54 };
    56 } // namespace dom
    57 } // namespace mozilla
    59 #endif // mozilla_dom_UnionMember_h

mercurial