gfx/skia/trunk/src/utils/SkCondVar.cpp

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

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.

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

mercurial