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: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 * Version: MPL 1.1
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/. */
8 #include "xptcprivate.h"
9 #include "xptiprivate.h"
11 #include <stdint.h>
13 /*
14 * This is for MIPS O32 ABI
15 * Args contains a0-3 and then the stack.
16 * Because a0 is 'this', we want to skip it
17 */
18 extern "C" nsresult ATTRIBUTE_USED
19 PrepareAndDispatch(nsXPTCStubBase* self, uint32_t methodIndex, uint32_t* args)
20 {
21 args++; // always skip over a0
23 #define PARAM_BUFFER_COUNT 16
25 nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
26 nsXPTCMiniVariant* dispatchParams = nullptr;
27 const nsXPTMethodInfo* info;
28 uint8_t paramCount;
29 uint8_t i;
30 nsresult result = NS_ERROR_FAILURE;
32 NS_ASSERTION(self,"no self");
34 self->mEntry->GetMethodInfo(uint16_t(methodIndex), &info);
35 NS_ASSERTION(info,"no method info");
37 paramCount = info->GetParamCount();
39 // setup variant array pointer
40 if(paramCount > PARAM_BUFFER_COUNT)
41 dispatchParams = new nsXPTCMiniVariant[paramCount];
42 else
43 dispatchParams = paramBuffer;
44 NS_ASSERTION(dispatchParams,"no place for params");
46 uint32_t* ap = args;
47 for(i = 0; i < paramCount; i++, ap++)
48 {
49 const nsXPTParamInfo& param = info->GetParam(i);
50 const nsXPTType& type = param.GetType();
51 nsXPTCMiniVariant* dp = &dispatchParams[i];
53 if(param.IsOut() || !type.IsArithmetic())
54 {
55 dp->val.p = (void*) *ap;
56 continue;
57 }
59 switch(type)
60 {
61 case nsXPTType::T_I64 :
62 if ((intptr_t)ap & 4) ap++;
63 dp->val.i64 = *((int64_t*) ap); ap++;
64 break;
65 case nsXPTType::T_U64 :
66 if ((intptr_t)ap & 4) ap++;
67 dp->val.u64 = *((int64_t*) ap); ap++;
68 break;
69 case nsXPTType::T_DOUBLE:
70 if ((intptr_t)ap & 4) ap++;
71 dp->val.d = *((double*) ap); ap++;
72 break;
73 #ifdef IS_LITTLE_ENDIAN
74 default:
75 dp->val.p = (void*) *ap;
76 break;
77 #else
78 case nsXPTType::T_I8 : dp->val.i8 = (int8_t) *ap; break;
79 case nsXPTType::T_I16 : dp->val.i16 = (int16_t) *ap; break;
80 case nsXPTType::T_I32 : dp->val.i32 = (int32_t) *ap; break;
81 case nsXPTType::T_U8 : dp->val.u8 = (uint8_t) *ap; break;
82 case nsXPTType::T_U16 : dp->val.u16 = (uint16_t) *ap; break;
83 case nsXPTType::T_U32 : dp->val.u32 = (uint32_t) *ap; break;
84 case nsXPTType::T_BOOL : dp->val.b = (bool) *ap; break;
85 case nsXPTType::T_CHAR : dp->val.c = (char) *ap; break;
86 case nsXPTType::T_WCHAR : dp->val.wc = (wchar_t) *ap; break;
87 case nsXPTType::T_FLOAT : dp->val.f = *(float *) ap; break;
88 default:
89 NS_ASSERTION(0, "bad type");
90 break;
91 #endif
92 }
93 }
95 result = self->mOuter->CallMethod((uint16_t)methodIndex, info, dispatchParams);
97 if(dispatchParams != paramBuffer)
98 delete [] dispatchParams;
100 return result;
101 }
103 #define STUB_ENTRY(n) // done in the .s file
105 #define SENTINEL_ENTRY(n) \
106 nsresult nsXPTCStubBase::Sentinel##n() \
107 { \
108 NS_ERROR("nsXPTCStubBase::Sentinel called"); \
109 return NS_ERROR_NOT_IMPLEMENTED; \
110 }
112 #include "xptcstubsdef.inc"