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-2010 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 | // debug.cpp: Debugging utilities. |
michael@0 | 8 | |
michael@0 | 9 | #include "common/debug.h" |
michael@0 | 10 | #include "common/system.h" |
michael@0 | 11 | #include <d3d9.h> |
michael@0 | 12 | |
michael@0 | 13 | namespace gl |
michael@0 | 14 | { |
michael@0 | 15 | |
michael@0 | 16 | typedef void (WINAPI *PerfOutputFunction)(D3DCOLOR, LPCWSTR); |
michael@0 | 17 | |
michael@0 | 18 | static void output(bool traceFileDebugOnly, PerfOutputFunction perfFunc, const char *format, va_list vararg) |
michael@0 | 19 | { |
michael@0 | 20 | #if !defined(ANGLE_DISABLE_PERF) |
michael@0 | 21 | if (perfActive()) |
michael@0 | 22 | { |
michael@0 | 23 | char message[32768]; |
michael@0 | 24 | int len = vsprintf_s(message, format, vararg); |
michael@0 | 25 | if (len < 0) |
michael@0 | 26 | { |
michael@0 | 27 | return; |
michael@0 | 28 | } |
michael@0 | 29 | |
michael@0 | 30 | // There are no ASCII variants of these D3DPERF functions. |
michael@0 | 31 | wchar_t wideMessage[32768]; |
michael@0 | 32 | for (int i = 0; i < len; ++i) |
michael@0 | 33 | { |
michael@0 | 34 | wideMessage[i] = message[i]; |
michael@0 | 35 | } |
michael@0 | 36 | wideMessage[len] = 0; |
michael@0 | 37 | |
michael@0 | 38 | perfFunc(0, wideMessage); |
michael@0 | 39 | } |
michael@0 | 40 | #endif |
michael@0 | 41 | |
michael@0 | 42 | #if !defined(ANGLE_DISABLE_TRACE) |
michael@0 | 43 | #if defined(NDEBUG) |
michael@0 | 44 | if (traceFileDebugOnly) |
michael@0 | 45 | { |
michael@0 | 46 | return; |
michael@0 | 47 | } |
michael@0 | 48 | #endif |
michael@0 | 49 | |
michael@0 | 50 | FILE* file = fopen(TRACE_OUTPUT_FILE, "a"); |
michael@0 | 51 | if (file) |
michael@0 | 52 | { |
michael@0 | 53 | vfprintf(file, format, vararg); |
michael@0 | 54 | fclose(file); |
michael@0 | 55 | } |
michael@0 | 56 | #endif |
michael@0 | 57 | } |
michael@0 | 58 | |
michael@0 | 59 | void trace(bool traceFileDebugOnly, const char *format, ...) |
michael@0 | 60 | { |
michael@0 | 61 | va_list vararg; |
michael@0 | 62 | va_start(vararg, format); |
michael@0 | 63 | #if defined(ANGLE_DISABLE_PERF) |
michael@0 | 64 | output(traceFileDebugOnly, NULL, format, vararg); |
michael@0 | 65 | #else |
michael@0 | 66 | output(traceFileDebugOnly, D3DPERF_SetMarker, format, vararg); |
michael@0 | 67 | #endif |
michael@0 | 68 | va_end(vararg); |
michael@0 | 69 | } |
michael@0 | 70 | |
michael@0 | 71 | bool perfActive() |
michael@0 | 72 | { |
michael@0 | 73 | #if defined(ANGLE_DISABLE_PERF) |
michael@0 | 74 | return false; |
michael@0 | 75 | #else |
michael@0 | 76 | static bool active = D3DPERF_GetStatus() != 0; |
michael@0 | 77 | return active; |
michael@0 | 78 | #endif |
michael@0 | 79 | } |
michael@0 | 80 | |
michael@0 | 81 | ScopedPerfEventHelper::ScopedPerfEventHelper(const char* format, ...) |
michael@0 | 82 | { |
michael@0 | 83 | #if !defined(ANGLE_DISABLE_PERF) |
michael@0 | 84 | #if defined(ANGLE_DISABLE_TRACE) |
michael@0 | 85 | if (!perfActive()) |
michael@0 | 86 | { |
michael@0 | 87 | return; |
michael@0 | 88 | } |
michael@0 | 89 | #endif |
michael@0 | 90 | va_list vararg; |
michael@0 | 91 | va_start(vararg, format); |
michael@0 | 92 | output(true, reinterpret_cast<PerfOutputFunction>(D3DPERF_BeginEvent), format, vararg); |
michael@0 | 93 | va_end(vararg); |
michael@0 | 94 | #endif |
michael@0 | 95 | } |
michael@0 | 96 | |
michael@0 | 97 | ScopedPerfEventHelper::~ScopedPerfEventHelper() |
michael@0 | 98 | { |
michael@0 | 99 | #if !defined(ANGLE_DISABLE_PERF) |
michael@0 | 100 | if (perfActive()) |
michael@0 | 101 | { |
michael@0 | 102 | D3DPERF_EndEvent(); |
michael@0 | 103 | } |
michael@0 | 104 | #endif |
michael@0 | 105 | } |
michael@0 | 106 | } |