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 2012 Google Inc. |
michael@0 | 3 | * |
michael@0 | 4 | * Use of this source code is governed by a BSD-style license that can be |
michael@0 | 5 | * found in the LICENSE file. |
michael@0 | 6 | */ |
michael@0 | 7 | |
michael@0 | 8 | #include "SkCondVar.h" |
michael@0 | 9 | |
michael@0 | 10 | SkCondVar::SkCondVar() { |
michael@0 | 11 | #ifdef SK_USE_POSIX_THREADS |
michael@0 | 12 | pthread_mutex_init(&fMutex, NULL /* default mutex attr */); |
michael@0 | 13 | pthread_cond_init(&fCond, NULL /* default cond attr */); |
michael@0 | 14 | #elif defined(SK_BUILD_FOR_WIN32) |
michael@0 | 15 | InitializeCriticalSection(&fCriticalSection); |
michael@0 | 16 | InitializeConditionVariable(&fCondition); |
michael@0 | 17 | #endif |
michael@0 | 18 | } |
michael@0 | 19 | |
michael@0 | 20 | SkCondVar::~SkCondVar() { |
michael@0 | 21 | #ifdef SK_USE_POSIX_THREADS |
michael@0 | 22 | pthread_mutex_destroy(&fMutex); |
michael@0 | 23 | pthread_cond_destroy(&fCond); |
michael@0 | 24 | #elif defined(SK_BUILD_FOR_WIN32) |
michael@0 | 25 | DeleteCriticalSection(&fCriticalSection); |
michael@0 | 26 | // No need to clean up fCondition. |
michael@0 | 27 | #endif |
michael@0 | 28 | } |
michael@0 | 29 | |
michael@0 | 30 | void SkCondVar::lock() { |
michael@0 | 31 | #ifdef SK_USE_POSIX_THREADS |
michael@0 | 32 | pthread_mutex_lock(&fMutex); |
michael@0 | 33 | #elif defined(SK_BUILD_FOR_WIN32) |
michael@0 | 34 | EnterCriticalSection(&fCriticalSection); |
michael@0 | 35 | #endif |
michael@0 | 36 | } |
michael@0 | 37 | |
michael@0 | 38 | void SkCondVar::unlock() { |
michael@0 | 39 | #ifdef SK_USE_POSIX_THREADS |
michael@0 | 40 | pthread_mutex_unlock(&fMutex); |
michael@0 | 41 | #elif defined(SK_BUILD_FOR_WIN32) |
michael@0 | 42 | LeaveCriticalSection(&fCriticalSection); |
michael@0 | 43 | #endif |
michael@0 | 44 | } |
michael@0 | 45 | |
michael@0 | 46 | void SkCondVar::wait() { |
michael@0 | 47 | #ifdef SK_USE_POSIX_THREADS |
michael@0 | 48 | pthread_cond_wait(&fCond, &fMutex); |
michael@0 | 49 | #elif defined(SK_BUILD_FOR_WIN32) |
michael@0 | 50 | SleepConditionVariableCS(&fCondition, &fCriticalSection, INFINITE); |
michael@0 | 51 | #endif |
michael@0 | 52 | } |
michael@0 | 53 | |
michael@0 | 54 | void SkCondVar::signal() { |
michael@0 | 55 | #ifdef SK_USE_POSIX_THREADS |
michael@0 | 56 | pthread_cond_signal(&fCond); |
michael@0 | 57 | #elif defined(SK_BUILD_FOR_WIN32) |
michael@0 | 58 | WakeConditionVariable(&fCondition); |
michael@0 | 59 | #endif |
michael@0 | 60 | } |
michael@0 | 61 | |
michael@0 | 62 | void SkCondVar::broadcast() { |
michael@0 | 63 | #ifdef SK_USE_POSIX_THREADS |
michael@0 | 64 | pthread_cond_broadcast(&fCond); |
michael@0 | 65 | #elif defined(SK_BUILD_FOR_WIN32) |
michael@0 | 66 | WakeAllConditionVariable(&fCondition); |
michael@0 | 67 | #endif |
michael@0 | 68 | } |