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 | // |
michael@0 | 2 | // Copyright (c) 2002-2012 The ANGLE Project Authors. All rights reserved. |
michael@0 | 3 | // Use of this source code is governed by a BSD-style license that can be |
michael@0 | 4 | // found in the LICENSE file. |
michael@0 | 5 | // |
michael@0 | 6 | |
michael@0 | 7 | // main.cpp: DLL entry point and management of thread-local data. |
michael@0 | 8 | |
michael@0 | 9 | #include "libEGL/main.h" |
michael@0 | 10 | |
michael@0 | 11 | #include "common/debug.h" |
michael@0 | 12 | |
michael@0 | 13 | static DWORD currentTLS = TLS_OUT_OF_INDEXES; |
michael@0 | 14 | |
michael@0 | 15 | extern "C" BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, LPVOID reserved) |
michael@0 | 16 | { |
michael@0 | 17 | switch (reason) |
michael@0 | 18 | { |
michael@0 | 19 | case DLL_PROCESS_ATTACH: |
michael@0 | 20 | { |
michael@0 | 21 | #if !defined(ANGLE_DISABLE_TRACE) |
michael@0 | 22 | FILE *debug = fopen(TRACE_OUTPUT_FILE, "rt"); |
michael@0 | 23 | |
michael@0 | 24 | if (debug) |
michael@0 | 25 | { |
michael@0 | 26 | fclose(debug); |
michael@0 | 27 | debug = fopen(TRACE_OUTPUT_FILE, "wt"); // Erase |
michael@0 | 28 | |
michael@0 | 29 | if (debug) |
michael@0 | 30 | { |
michael@0 | 31 | fclose(debug); |
michael@0 | 32 | } |
michael@0 | 33 | } |
michael@0 | 34 | #endif |
michael@0 | 35 | |
michael@0 | 36 | currentTLS = TlsAlloc(); |
michael@0 | 37 | |
michael@0 | 38 | if (currentTLS == TLS_OUT_OF_INDEXES) |
michael@0 | 39 | { |
michael@0 | 40 | return FALSE; |
michael@0 | 41 | } |
michael@0 | 42 | } |
michael@0 | 43 | // Fall throught to initialize index |
michael@0 | 44 | case DLL_THREAD_ATTACH: |
michael@0 | 45 | { |
michael@0 | 46 | egl::Current *current = (egl::Current*)LocalAlloc(LPTR, sizeof(egl::Current)); |
michael@0 | 47 | |
michael@0 | 48 | if (current) |
michael@0 | 49 | { |
michael@0 | 50 | TlsSetValue(currentTLS, current); |
michael@0 | 51 | |
michael@0 | 52 | current->error = EGL_SUCCESS; |
michael@0 | 53 | current->API = EGL_OPENGL_ES_API; |
michael@0 | 54 | current->display = EGL_NO_DISPLAY; |
michael@0 | 55 | current->drawSurface = EGL_NO_SURFACE; |
michael@0 | 56 | current->readSurface = EGL_NO_SURFACE; |
michael@0 | 57 | } |
michael@0 | 58 | } |
michael@0 | 59 | break; |
michael@0 | 60 | case DLL_THREAD_DETACH: |
michael@0 | 61 | { |
michael@0 | 62 | void *current = TlsGetValue(currentTLS); |
michael@0 | 63 | |
michael@0 | 64 | if (current) |
michael@0 | 65 | { |
michael@0 | 66 | LocalFree((HLOCAL)current); |
michael@0 | 67 | } |
michael@0 | 68 | } |
michael@0 | 69 | break; |
michael@0 | 70 | case DLL_PROCESS_DETACH: |
michael@0 | 71 | { |
michael@0 | 72 | void *current = TlsGetValue(currentTLS); |
michael@0 | 73 | |
michael@0 | 74 | if (current) |
michael@0 | 75 | { |
michael@0 | 76 | LocalFree((HLOCAL)current); |
michael@0 | 77 | } |
michael@0 | 78 | |
michael@0 | 79 | TlsFree(currentTLS); |
michael@0 | 80 | } |
michael@0 | 81 | break; |
michael@0 | 82 | default: |
michael@0 | 83 | break; |
michael@0 | 84 | } |
michael@0 | 85 | |
michael@0 | 86 | return TRUE; |
michael@0 | 87 | } |
michael@0 | 88 | |
michael@0 | 89 | namespace egl |
michael@0 | 90 | { |
michael@0 | 91 | void setCurrentError(EGLint error) |
michael@0 | 92 | { |
michael@0 | 93 | Current *current = (Current*)TlsGetValue(currentTLS); |
michael@0 | 94 | |
michael@0 | 95 | current->error = error; |
michael@0 | 96 | } |
michael@0 | 97 | |
michael@0 | 98 | EGLint getCurrentError() |
michael@0 | 99 | { |
michael@0 | 100 | Current *current = (Current*)TlsGetValue(currentTLS); |
michael@0 | 101 | |
michael@0 | 102 | return current->error; |
michael@0 | 103 | } |
michael@0 | 104 | |
michael@0 | 105 | void setCurrentAPI(EGLenum API) |
michael@0 | 106 | { |
michael@0 | 107 | Current *current = (Current*)TlsGetValue(currentTLS); |
michael@0 | 108 | |
michael@0 | 109 | current->API = API; |
michael@0 | 110 | } |
michael@0 | 111 | |
michael@0 | 112 | EGLenum getCurrentAPI() |
michael@0 | 113 | { |
michael@0 | 114 | Current *current = (Current*)TlsGetValue(currentTLS); |
michael@0 | 115 | |
michael@0 | 116 | return current->API; |
michael@0 | 117 | } |
michael@0 | 118 | |
michael@0 | 119 | void setCurrentDisplay(EGLDisplay dpy) |
michael@0 | 120 | { |
michael@0 | 121 | Current *current = (Current*)TlsGetValue(currentTLS); |
michael@0 | 122 | |
michael@0 | 123 | current->display = dpy; |
michael@0 | 124 | } |
michael@0 | 125 | |
michael@0 | 126 | EGLDisplay getCurrentDisplay() |
michael@0 | 127 | { |
michael@0 | 128 | Current *current = (Current*)TlsGetValue(currentTLS); |
michael@0 | 129 | |
michael@0 | 130 | return current->display; |
michael@0 | 131 | } |
michael@0 | 132 | |
michael@0 | 133 | void setCurrentDrawSurface(EGLSurface surface) |
michael@0 | 134 | { |
michael@0 | 135 | Current *current = (Current*)TlsGetValue(currentTLS); |
michael@0 | 136 | |
michael@0 | 137 | current->drawSurface = surface; |
michael@0 | 138 | } |
michael@0 | 139 | |
michael@0 | 140 | EGLSurface getCurrentDrawSurface() |
michael@0 | 141 | { |
michael@0 | 142 | Current *current = (Current*)TlsGetValue(currentTLS); |
michael@0 | 143 | |
michael@0 | 144 | return current->drawSurface; |
michael@0 | 145 | } |
michael@0 | 146 | |
michael@0 | 147 | void setCurrentReadSurface(EGLSurface surface) |
michael@0 | 148 | { |
michael@0 | 149 | Current *current = (Current*)TlsGetValue(currentTLS); |
michael@0 | 150 | |
michael@0 | 151 | current->readSurface = surface; |
michael@0 | 152 | } |
michael@0 | 153 | |
michael@0 | 154 | EGLSurface getCurrentReadSurface() |
michael@0 | 155 | { |
michael@0 | 156 | Current *current = (Current*)TlsGetValue(currentTLS); |
michael@0 | 157 | |
michael@0 | 158 | return current->readSurface; |
michael@0 | 159 | } |
michael@0 | 160 | |
michael@0 | 161 | void error(EGLint errorCode) |
michael@0 | 162 | { |
michael@0 | 163 | egl::setCurrentError(errorCode); |
michael@0 | 164 | } |
michael@0 | 165 | |
michael@0 | 166 | } |