Sat, 03 Jan 2015 20:18:00 +0100
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 non-null strong pointers to reference-counted objects. */
9 #ifndef mozilla_dom_OwningNonNull_h
10 #define mozilla_dom_OwningNonNull_h
12 #include "nsAutoPtr.h"
14 namespace mozilla {
15 namespace dom {
17 template<class T>
18 class OwningNonNull
19 {
20 public:
21 OwningNonNull()
22 #ifdef DEBUG
23 : mInited(false)
24 #endif
25 {}
27 operator T&()
28 {
29 MOZ_ASSERT(mInited);
30 MOZ_ASSERT(mPtr, "OwningNonNull<T> was set to null");
31 return *mPtr;
32 }
34 operator T*()
35 {
36 MOZ_ASSERT(mInited);
37 MOZ_ASSERT(mPtr, "OwningNonNull<T> was set to null");
38 return mPtr;
39 }
41 void operator=(T* aValue)
42 {
43 init(aValue);
44 }
46 void operator=(const already_AddRefed<T>& aValue)
47 {
48 init(aValue);
49 }
51 already_AddRefed<T> forget()
52 {
53 #ifdef DEBUG
54 mInited = false;
55 #endif
56 return mPtr.forget();
57 }
59 // Make us work with smart pointer helpers that expect a get().
60 T* get() const
61 {
62 MOZ_ASSERT(mInited);
63 MOZ_ASSERT(mPtr);
64 return mPtr;
65 }
67 protected:
68 template<typename U>
69 void init(U aValue)
70 {
71 mPtr = aValue;
72 MOZ_ASSERT(mPtr);
73 #ifdef DEBUG
74 mInited = true;
75 #endif
76 }
78 nsRefPtr<T> mPtr;
79 #ifdef DEBUG
80 bool mInited;
81 #endif
82 };
84 } // namespace dom
85 } // namespace mozilla
87 #endif // mozilla_dom_OwningNonNull_h