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 | #ifndef _GNU_SOURCE |
michael@0 | 9 | #define _GNU_SOURCE //for pthread_setaffinity_np |
michael@0 | 10 | #endif |
michael@0 | 11 | |
michael@0 | 12 | #include "SkThreadUtils.h" |
michael@0 | 13 | #include "SkThreadUtils_pthread.h" |
michael@0 | 14 | |
michael@0 | 15 | #include <pthread.h> |
michael@0 | 16 | |
michael@0 | 17 | static int nth_set_cpu(unsigned int n, cpu_set_t* cpuSet) { |
michael@0 | 18 | n %= CPU_COUNT(cpuSet); |
michael@0 | 19 | for (unsigned int setCpusSeen = 0, currentCpu = 0; true; ++currentCpu) { |
michael@0 | 20 | if (CPU_ISSET(currentCpu, cpuSet)) { |
michael@0 | 21 | ++setCpusSeen; |
michael@0 | 22 | if (setCpusSeen > n) { |
michael@0 | 23 | return currentCpu; |
michael@0 | 24 | } |
michael@0 | 25 | } |
michael@0 | 26 | } |
michael@0 | 27 | } |
michael@0 | 28 | |
michael@0 | 29 | bool SkThread::setProcessorAffinity(unsigned int processor) { |
michael@0 | 30 | SkThread_PThreadData* pthreadData = static_cast<SkThread_PThreadData*>(fData); |
michael@0 | 31 | if (!pthreadData->fValidPThread) { |
michael@0 | 32 | return false; |
michael@0 | 33 | } |
michael@0 | 34 | |
michael@0 | 35 | cpu_set_t parentCpuset; |
michael@0 | 36 | if (0 != pthread_getaffinity_np(pthread_self(), sizeof(cpu_set_t), &parentCpuset)) { |
michael@0 | 37 | return false; |
michael@0 | 38 | } |
michael@0 | 39 | |
michael@0 | 40 | cpu_set_t cpuset; |
michael@0 | 41 | CPU_ZERO(&cpuset); |
michael@0 | 42 | CPU_SET(nth_set_cpu(processor, &parentCpuset), &cpuset); |
michael@0 | 43 | return 0 == pthread_setaffinity_np(pthreadData->fPThread, |
michael@0 | 44 | sizeof(cpu_set_t), |
michael@0 | 45 | &cpuset); |
michael@0 | 46 | } |