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.
2 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
3 *
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
9 #include "xptcprivate.h"
10 #include "xptiprivate.h"
12 #include <stddef.h>
13 #include <stdlib.h>
14 #include <stdint.h>
16 // "This code is for IA64 only"
18 /* Implement shared vtbl methods. */
20 extern "C" nsresult ATTRIBUTE_USED
21 PrepareAndDispatch(nsXPTCStubBase* self, uint32_t methodIndex,
22 uint64_t* intargs, uint64_t* floatargs, uint64_t* restargs)
23 {
25 #define PARAM_BUFFER_COUNT 16
27 nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
28 nsXPTCMiniVariant* dispatchParams = nullptr;
29 const nsXPTMethodInfo* info;
30 nsresult result = NS_ERROR_FAILURE;
31 uint64_t* iargs = intargs;
32 uint64_t* fargs = floatargs;
33 uint8_t paramCount;
34 uint8_t i;
36 NS_ASSERTION(self,"no self");
38 self->mEntry->GetMethodInfo(uint16_t(methodIndex), &info);
39 NS_ASSERTION(info,"no method info");
40 if (! info)
41 return NS_ERROR_UNEXPECTED;
43 paramCount = info->GetParamCount();
45 // setup variant array pointer
46 if(paramCount > PARAM_BUFFER_COUNT)
47 dispatchParams = new nsXPTCMiniVariant[paramCount];
48 else
49 dispatchParams = paramBuffer;
50 NS_ASSERTION(dispatchParams,"no place for params");
51 if (! dispatchParams)
52 return NS_ERROR_OUT_OF_MEMORY;
54 for(i = 0; i < paramCount; ++i)
55 {
56 int isfloat = 0;
57 const nsXPTParamInfo& param = info->GetParam(i);
58 const nsXPTType& type = param.GetType();
59 nsXPTCMiniVariant* dp = &dispatchParams[i];
61 if(param.IsOut() || !type.IsArithmetic())
62 {
63 #ifdef __LP64__
64 /* 64 bit pointer mode */
65 dp->val.p = (void*) *iargs;
66 #else
67 /* 32 bit pointer mode */
68 uint32_t* adr = (uint32_t*) iargs;
69 dp->val.p = (void*) (*(adr+1));
70 #endif
71 }
72 else
73 switch(type)
74 {
75 case nsXPTType::T_I8 : dp->val.i8 = *(iargs); break;
76 case nsXPTType::T_I16 : dp->val.i16 = *(iargs); break;
77 case nsXPTType::T_I32 : dp->val.i32 = *(iargs); break;
78 case nsXPTType::T_I64 : dp->val.i64 = *(iargs); break;
79 case nsXPTType::T_U8 : dp->val.u8 = *(iargs); break;
80 case nsXPTType::T_U16 : dp->val.u16 = *(iargs); break;
81 case nsXPTType::T_U32 : dp->val.u32 = *(iargs); break;
82 case nsXPTType::T_U64 : dp->val.u64 = *(iargs); break;
83 case nsXPTType::T_FLOAT :
84 isfloat = 1;
85 if (i < 7)
86 dp->val.f = (float) *((double*) fargs); /* register */
87 else
88 dp->val.u32 = *(fargs); /* memory */
89 break;
90 case nsXPTType::T_DOUBLE :
91 isfloat = 1;
92 dp->val.u64 = *(fargs);
93 break;
94 case nsXPTType::T_BOOL : dp->val.b = *(iargs); break;
95 case nsXPTType::T_CHAR : dp->val.c = *(iargs); break;
96 case nsXPTType::T_WCHAR : dp->val.wc = *(iargs); break;
97 default:
98 NS_ERROR("bad type");
99 break;
100 }
101 if (i < 7)
102 {
103 /* we are parsing register arguments */
104 if (i == 6)
105 {
106 // run out of register arguments, move on to memory arguments
107 iargs = restargs;
108 fargs = restargs;
109 }
110 else
111 {
112 ++iargs; // advance one integer register slot
113 if (isfloat) ++fargs; // advance float register slot if isfloat
114 }
115 }
116 else
117 {
118 /* we are parsing memory arguments */
119 ++iargs;
120 ++fargs;
121 }
122 }
124 result = self->mOuter->CallMethod((uint16_t) methodIndex, info, dispatchParams);
126 if(dispatchParams != paramBuffer)
127 delete [] dispatchParams;
129 return result;
130 }
132 extern "C" nsresult SharedStub(uint64_t,uint64_t,uint64_t,uint64_t,
133 uint64_t,uint64_t,uint64_t,uint64_t,uint64_t,uint64_t *);
135 /* Variable a0-a7 were put there so we can have access to the 8 input
136 registers on Stubxyz entry */
138 #define STUB_ENTRY(n) \
139 nsresult nsXPTCStubBase::Stub##n(uint64_t a1, \
140 uint64_t a2,uint64_t a3,uint64_t a4,uint64_t a5,uint64_t a6,uint64_t a7, \
141 uint64_t a8) \
142 { uint64_t a0 = (uint64_t) this; \
143 return SharedStub(a0,a1,a2,a3,a4,a5,a6,a7,(uint64_t) n, &a8); \
144 }
146 #define SENTINEL_ENTRY(n) \
147 nsresult nsXPTCStubBase::Sentinel##n() \
148 { \
149 NS_ERROR("nsXPTCStubBase::Sentinel called"); \
150 return NS_ERROR_NOT_IMPLEMENTED; \
151 }
153 #include "xptcstubsdef.inc"