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=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 file,
5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_dom_quota_arraycluster_h__
8 #define mozilla_dom_quota_arraycluster_h__
10 #include "mozilla/dom/quota/QuotaCommon.h"
12 #include "Client.h"
14 BEGIN_QUOTA_NAMESPACE
16 template <class ValueType, uint32_t Length = Client::TYPE_MAX>
17 class ArrayCluster
18 {
19 public:
20 ArrayCluster()
21 {
22 mArrays.AppendElements(Length);
23 }
25 nsTArray<ValueType>&
26 ArrayAt(uint32_t aIndex)
27 {
28 MOZ_ASSERT(aIndex < Length, "Bad index!");
29 return mArrays[aIndex];
30 }
32 nsTArray<ValueType>&
33 operator[](uint32_t aIndex)
34 {
35 return ArrayAt(aIndex);
36 }
38 bool
39 IsEmpty()
40 {
41 for (uint32_t index = 0; index < Length; index++) {
42 if (!mArrays[index].IsEmpty()) {
43 return false;
44 }
45 }
46 return true;
47 }
49 template <class T>
50 void
51 AppendElementsTo(uint32_t aIndex, nsTArray<T>& aArray)
52 {
53 NS_ASSERTION(aIndex < Length, "Bad index!");
54 aArray.AppendElements(mArrays[aIndex]);
55 }
57 template <class T>
58 void
59 AppendElementsTo(uint32_t aIndex, ArrayCluster<T, Length>& aArrayCluster)
60 {
61 NS_ASSERTION(aIndex < Length, "Bad index!");
62 aArrayCluster[aIndex].AppendElements(mArrays[aIndex]);
63 }
65 template <class T>
66 void
67 AppendElementsTo(nsTArray<T>& aArray)
68 {
69 for (uint32_t index = 0; index < Length; index++) {
70 aArray.AppendElements(mArrays[index]);
71 }
72 }
74 template<class T>
75 void
76 AppendElementsTo(ArrayCluster<T, Length>& aArrayCluster)
77 {
78 for (uint32_t index = 0; index < Length; index++) {
79 aArrayCluster[index].AppendElements(mArrays[index]);
80 }
81 }
83 template<class T>
84 void
85 SwapElements(ArrayCluster<T, Length>& aArrayCluster)
86 {
87 for (uint32_t index = 0; index < Length; index++) {
88 mArrays[index].SwapElements(aArrayCluster.mArrays[index]);
89 }
90 }
92 void
93 Clear()
94 {
95 for (uint32_t index = 0; index < Length; index++) {
96 mArrays[index].Clear();
97 }
98 }
100 private:
101 nsAutoTArray<nsTArray<ValueType>, Length> mArrays;
102 };
104 END_QUOTA_NAMESPACE
106 #endif // mozilla_dom_quota_arraycluster_h__