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++; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 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 | #include <windows.h> |
michael@0 | 7 | #include <stdio.h> |
michael@0 | 8 | #include <time.h> |
michael@0 | 9 | |
michael@0 | 10 | #include "vprof.h" |
michael@0 | 11 | |
michael@0 | 12 | static void cProbe (void* vprofID) |
michael@0 | 13 | { |
michael@0 | 14 | if (_VAL == _IVAR1) _I64VAR1 ++; |
michael@0 | 15 | _IVAR1 = _IVAR0; |
michael@0 | 16 | |
michael@0 | 17 | if (_VAL == _IVAR0) _I64VAR0 ++; |
michael@0 | 18 | _IVAR0 = (int) _VAL; |
michael@0 | 19 | |
michael@0 | 20 | _DVAR0 = ((double)_I64VAR0) / _COUNT; |
michael@0 | 21 | _DVAR1 = ((double)_I64VAR1) / _COUNT; |
michael@0 | 22 | } |
michael@0 | 23 | |
michael@0 | 24 | //__declspec (thread) boolean cv; |
michael@0 | 25 | //#define if(c) cv = (c); _vprof (cv); if (cv) |
michael@0 | 26 | //#define if(c) cv = (c); _vprof (cv, cProbe); if (cv) |
michael@0 | 27 | |
michael@0 | 28 | #define THREADS 1 |
michael@0 | 29 | #define COUNT 100000 |
michael@0 | 30 | #define SLEEPTIME 0 |
michael@0 | 31 | |
michael@0 | 32 | static int64_t evens = 0; |
michael@0 | 33 | static int64_t odds = 0; |
michael@0 | 34 | |
michael@0 | 35 | void sub(int val) |
michael@0 | 36 | { |
michael@0 | 37 | int i; |
michael@0 | 38 | //_vprof (1); |
michael@0 | 39 | for (i = 0; i < COUNT; i++) { |
michael@0 | 40 | //_nvprof ("Iteration", 1); |
michael@0 | 41 | //_nvprof ("Iteration", 1); |
michael@0 | 42 | _vprof (i); |
michael@0 | 43 | //_vprof (i); |
michael@0 | 44 | //_hprof(i, 3, (int64_t) 1000, (int64_t)2000, (int64_t)3000); |
michael@0 | 45 | //_hprof(i, 3, 10000, 10001, 3000000); |
michael@0 | 46 | //_nhprof("Event", i, 3, 10000, 10001, 3000000); |
michael@0 | 47 | //_nhprof("Event", i, 3, 10000, 10001, 3000000); |
michael@0 | 48 | //Sleep(SLEEPTIME); |
michael@0 | 49 | if (i % 2 == 0) { |
michael@0 | 50 | //_vprof (i); |
michael@0 | 51 | ////_hprof(i, 3, 10000, 10001, 3000000); |
michael@0 | 52 | //_nvprof ("Iteration", i); |
michael@0 | 53 | evens ++; |
michael@0 | 54 | } else { |
michael@0 | 55 | //_vprof (1); |
michael@0 | 56 | _vprof (i, cProbe); |
michael@0 | 57 | odds ++; |
michael@0 | 58 | } |
michael@0 | 59 | //_nvprof ("Iterate", 1); |
michael@0 | 60 | } |
michael@0 | 61 | //printf("sub %d done.\n", val); |
michael@0 | 62 | } |
michael@0 | 63 | |
michael@0 | 64 | HANDLE array[THREADS]; |
michael@0 | 65 | |
michael@0 | 66 | static int run (void) |
michael@0 | 67 | { |
michael@0 | 68 | int i; |
michael@0 | 69 | |
michael@0 | 70 | time_t start_time = time(0); |
michael@0 | 71 | |
michael@0 | 72 | for (i = 0; i < THREADS; i++) { |
michael@0 | 73 | array[i] = CreateThread(0, 0, (LPTHREAD_START_ROUTINE)sub, (LPVOID)i, 0, 0); |
michael@0 | 74 | } |
michael@0 | 75 | |
michael@0 | 76 | for (i = 0; i < THREADS; i++) { |
michael@0 | 77 | WaitForSingleObject(array[i], INFINITE); |
michael@0 | 78 | } |
michael@0 | 79 | |
michael@0 | 80 | return 0; |
michael@0 | 81 | } |
michael@0 | 82 | |
michael@0 | 83 | int main () |
michael@0 | 84 | { |
michael@0 | 85 | DWORD start, end; |
michael@0 | 86 | |
michael@0 | 87 | start = GetTickCount (); |
michael@0 | 88 | run (); |
michael@0 | 89 | end = GetTickCount (); |
michael@0 | 90 | |
michael@0 | 91 | printf ("\nRun took %d msecs\n\n", end-start); |
michael@0 | 92 | } |