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.
michael@0 | 1 | /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | /* Implement shared vtbl methods. */ |
michael@0 | 7 | |
michael@0 | 8 | #include "xptcprivate.h" |
michael@0 | 9 | |
michael@0 | 10 | #if !defined(__NetBSD__) || !defined(__m68k__) |
michael@0 | 11 | #error This code is for NetBSD/m68k only |
michael@0 | 12 | #endif |
michael@0 | 13 | |
michael@0 | 14 | extern "C" { |
michael@0 | 15 | static nsresult ATTRIBUTE_USED |
michael@0 | 16 | PrepareAndDispatch(nsXPTCStubBase* self, uint32_t methodIndex, uint32_t* args) |
michael@0 | 17 | { |
michael@0 | 18 | #define PARAM_BUFFER_COUNT 16 |
michael@0 | 19 | |
michael@0 | 20 | nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT]; |
michael@0 | 21 | nsXPTCMiniVariant* dispatchParams = nullptr; |
michael@0 | 22 | nsIInterfaceInfo* iface_info = nullptr; |
michael@0 | 23 | const nsXPTMethodInfo* info; |
michael@0 | 24 | uint8_t paramCount; |
michael@0 | 25 | uint8_t i; |
michael@0 | 26 | nsresult result = NS_ERROR_FAILURE; |
michael@0 | 27 | |
michael@0 | 28 | NS_ASSERTION(self,"no self"); |
michael@0 | 29 | |
michael@0 | 30 | self->GetInterfaceInfo(&iface_info); |
michael@0 | 31 | NS_ASSERTION(iface_info,"no interface info"); |
michael@0 | 32 | |
michael@0 | 33 | iface_info->GetMethodInfo(uint16_t(methodIndex), &info); |
michael@0 | 34 | NS_ASSERTION(info,"no interface info"); |
michael@0 | 35 | |
michael@0 | 36 | paramCount = info->GetParamCount(); |
michael@0 | 37 | |
michael@0 | 38 | // setup variant array pointer |
michael@0 | 39 | if(paramCount > PARAM_BUFFER_COUNT) |
michael@0 | 40 | dispatchParams = new nsXPTCMiniVariant[paramCount]; |
michael@0 | 41 | else |
michael@0 | 42 | dispatchParams = paramBuffer; |
michael@0 | 43 | NS_ASSERTION(dispatchParams,"no place for params"); |
michael@0 | 44 | |
michael@0 | 45 | uint32_t* ap = args; |
michael@0 | 46 | for(i = 0; i < paramCount; i++, ap++) |
michael@0 | 47 | { |
michael@0 | 48 | const nsXPTParamInfo& param = info->GetParam(i); |
michael@0 | 49 | const nsXPTType& type = param.GetType(); |
michael@0 | 50 | nsXPTCMiniVariant* dp = &dispatchParams[i]; |
michael@0 | 51 | |
michael@0 | 52 | if(param.IsOut() || !type.IsArithmetic()) |
michael@0 | 53 | { |
michael@0 | 54 | dp->val.p = (void*) *ap; |
michael@0 | 55 | continue; |
michael@0 | 56 | } |
michael@0 | 57 | |
michael@0 | 58 | switch(type) |
michael@0 | 59 | { |
michael@0 | 60 | // the 8 and 16 bit types will have been promoted to 32 bits before |
michael@0 | 61 | // being pushed onto the stack. Since the 68k is big endian, we |
michael@0 | 62 | // need to skip over the leading high order bytes. |
michael@0 | 63 | case nsXPTType::T_I8 : dp->val.i8 = *(((int8_t*) ap) + 3); break; |
michael@0 | 64 | case nsXPTType::T_I16 : dp->val.i16 = *(((int16_t*) ap) + 1); break; |
michael@0 | 65 | case nsXPTType::T_I32 : dp->val.i32 = *((int32_t*) ap); break; |
michael@0 | 66 | case nsXPTType::T_I64 : dp->val.i64 = *((int64_t*) ap); ap++; break; |
michael@0 | 67 | case nsXPTType::T_U8 : dp->val.u8 = *(((uint8_t*) ap) + 3); break; |
michael@0 | 68 | case nsXPTType::T_U16 : dp->val.u16 = *(((uint16_t*)ap) + 1); break; |
michael@0 | 69 | case nsXPTType::T_U32 : dp->val.u32 = *((uint32_t*)ap); break; |
michael@0 | 70 | case nsXPTType::T_U64 : dp->val.u64 = *((uint64_t*)ap); ap++; break; |
michael@0 | 71 | case nsXPTType::T_FLOAT : dp->val.f = *((float*) ap); break; |
michael@0 | 72 | case nsXPTType::T_DOUBLE : dp->val.d = *((double*) ap); ap++; break; |
michael@0 | 73 | case nsXPTType::T_BOOL : dp->val.b = *(((char*) ap) + 3); break; |
michael@0 | 74 | case nsXPTType::T_CHAR : dp->val.c = *(((char*) ap) + 3); break; |
michael@0 | 75 | // wchar_t is an int (32 bits) on NetBSD |
michael@0 | 76 | case nsXPTType::T_WCHAR : dp->val.wc = *((wchar_t*) ap); break; |
michael@0 | 77 | default: |
michael@0 | 78 | NS_ERROR("bad type"); |
michael@0 | 79 | break; |
michael@0 | 80 | } |
michael@0 | 81 | } |
michael@0 | 82 | |
michael@0 | 83 | result = self->CallMethod((uint16_t)methodIndex, info, dispatchParams); |
michael@0 | 84 | |
michael@0 | 85 | NS_RELEASE(iface_info); |
michael@0 | 86 | |
michael@0 | 87 | if(dispatchParams != paramBuffer) |
michael@0 | 88 | delete [] dispatchParams; |
michael@0 | 89 | |
michael@0 | 90 | return result; |
michael@0 | 91 | } |
michael@0 | 92 | } |
michael@0 | 93 | |
michael@0 | 94 | #define STUB_ENTRY(n) \ |
michael@0 | 95 | __asm__( \ |
michael@0 | 96 | ".global _Stub"#n"__14nsXPTCStubBase\n\t" \ |
michael@0 | 97 | "_Stub"#n"__14nsXPTCStubBase:\n\t" \ |
michael@0 | 98 | "link a6,#0 \n\t" \ |
michael@0 | 99 | "lea a6@(12), a0 \n\t" /* pointer to args */ \ |
michael@0 | 100 | "movl a0, sp@- \n\t" \ |
michael@0 | 101 | "movl #"#n", sp@- \n\t" /* method index */ \ |
michael@0 | 102 | "movl a6@(8), sp@- \n\t" /* this */ \ |
michael@0 | 103 | "jbsr _PrepareAndDispatch \n\t" \ |
michael@0 | 104 | "unlk a6 \n\t" \ |
michael@0 | 105 | "rts \n\t" \ |
michael@0 | 106 | ); |
michael@0 | 107 | |
michael@0 | 108 | #define SENTINEL_ENTRY(n) \ |
michael@0 | 109 | nsresult nsXPTCStubBase::Sentinel##n() \ |
michael@0 | 110 | { \ |
michael@0 | 111 | NS_ERROR("nsXPTCStubBase::Sentinel called"); \ |
michael@0 | 112 | return NS_ERROR_NOT_IMPLEMENTED; \ |
michael@0 | 113 | } |
michael@0 | 114 | |
michael@0 | 115 | #include "xptcstubsdef.inc" |