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 2006 The Android Open Source Project |
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 SkThread_DEFINED |
michael@0 | 9 | #define SkThread_DEFINED |
michael@0 | 10 | |
michael@0 | 11 | #include "SkTypes.h" |
michael@0 | 12 | |
michael@0 | 13 | // SK_ATOMICS_PLATFORM_H must provide inline implementations for the following declarations. |
michael@0 | 14 | |
michael@0 | 15 | /** Atomically adds one to the int referenced by addr and returns the previous value. |
michael@0 | 16 | * No additional memory barrier is required; this must act as a compiler barrier. |
michael@0 | 17 | */ |
michael@0 | 18 | static int32_t sk_atomic_inc(int32_t* addr); |
michael@0 | 19 | |
michael@0 | 20 | /** Atomically adds inc to the int referenced by addr and returns the previous value. |
michael@0 | 21 | * No additional memory barrier is required; this must act as a compiler barrier. |
michael@0 | 22 | */ |
michael@0 | 23 | static int32_t sk_atomic_add(int32_t* addr, int32_t inc); |
michael@0 | 24 | |
michael@0 | 25 | /** Atomically subtracts one from the int referenced by addr and returns the previous value. |
michael@0 | 26 | * This must act as a release (SL/S) memory barrier and as a compiler barrier. |
michael@0 | 27 | */ |
michael@0 | 28 | static int32_t sk_atomic_dec(int32_t* addr); |
michael@0 | 29 | |
michael@0 | 30 | /** Atomically adds one to the int referenced by addr iff the referenced int was not 0 |
michael@0 | 31 | * and returns the previous value. |
michael@0 | 32 | * No additional memory barrier is required; this must act as a compiler barrier. |
michael@0 | 33 | */ |
michael@0 | 34 | static int32_t sk_atomic_conditional_inc(int32_t* addr); |
michael@0 | 35 | |
michael@0 | 36 | /** Atomic compare and set. |
michael@0 | 37 | * If *addr == before, set *addr to after and return true, otherwise return false. |
michael@0 | 38 | * This must act as a release (SL/S) memory barrier and as a compiler barrier. |
michael@0 | 39 | */ |
michael@0 | 40 | static bool sk_atomic_cas(int32_t* addr, int32_t before, int32_t after); |
michael@0 | 41 | |
michael@0 | 42 | /** If sk_atomic_dec does not act as an acquire (L/SL) barrier, |
michael@0 | 43 | * this must act as an acquire (L/SL) memory barrier and as a compiler barrier. |
michael@0 | 44 | */ |
michael@0 | 45 | static void sk_membar_acquire__after_atomic_dec(); |
michael@0 | 46 | |
michael@0 | 47 | /** If sk_atomic_conditional_inc does not act as an acquire (L/SL) barrier, |
michael@0 | 48 | * this must act as an acquire (L/SL) memory barrier and as a compiler barrier. |
michael@0 | 49 | */ |
michael@0 | 50 | static void sk_membar_acquire__after_atomic_conditional_inc(); |
michael@0 | 51 | |
michael@0 | 52 | #include SK_ATOMICS_PLATFORM_H |
michael@0 | 53 | |
michael@0 | 54 | /** SK_MUTEX_PLATFORM_H must provide the following (or equivalent) declarations. |
michael@0 | 55 | |
michael@0 | 56 | class SkBaseMutex { |
michael@0 | 57 | public: |
michael@0 | 58 | void acquire(); |
michael@0 | 59 | void release(); |
michael@0 | 60 | }; |
michael@0 | 61 | |
michael@0 | 62 | class SkMutex : SkBaseMutex { |
michael@0 | 63 | public: |
michael@0 | 64 | SkMutex(); |
michael@0 | 65 | ~SkMutex(); |
michael@0 | 66 | }; |
michael@0 | 67 | |
michael@0 | 68 | #define SK_DECLARE_STATIC_MUTEX(name) static SkBaseMutex name = ... |
michael@0 | 69 | #define SK_DECLARE_GLOBAL_MUTEX(name) SkBaseMutex name = ... |
michael@0 | 70 | */ |
michael@0 | 71 | |
michael@0 | 72 | #include SK_MUTEX_PLATFORM_H |
michael@0 | 73 | |
michael@0 | 74 | |
michael@0 | 75 | class SkAutoMutexAcquire : SkNoncopyable { |
michael@0 | 76 | public: |
michael@0 | 77 | explicit SkAutoMutexAcquire(SkBaseMutex& mutex) : fMutex(&mutex) { |
michael@0 | 78 | SkASSERT(fMutex != NULL); |
michael@0 | 79 | mutex.acquire(); |
michael@0 | 80 | } |
michael@0 | 81 | |
michael@0 | 82 | explicit SkAutoMutexAcquire(SkBaseMutex* mutex) : fMutex(mutex) { |
michael@0 | 83 | if (mutex) { |
michael@0 | 84 | mutex->acquire(); |
michael@0 | 85 | } |
michael@0 | 86 | } |
michael@0 | 87 | |
michael@0 | 88 | /** If the mutex has not been released, release it now. */ |
michael@0 | 89 | ~SkAutoMutexAcquire() { |
michael@0 | 90 | if (fMutex) { |
michael@0 | 91 | fMutex->release(); |
michael@0 | 92 | } |
michael@0 | 93 | } |
michael@0 | 94 | |
michael@0 | 95 | /** If the mutex has not been released, release it now. */ |
michael@0 | 96 | void release() { |
michael@0 | 97 | if (fMutex) { |
michael@0 | 98 | fMutex->release(); |
michael@0 | 99 | fMutex = NULL; |
michael@0 | 100 | } |
michael@0 | 101 | } |
michael@0 | 102 | |
michael@0 | 103 | private: |
michael@0 | 104 | SkBaseMutex* fMutex; |
michael@0 | 105 | }; |
michael@0 | 106 | #define SkAutoMutexAcquire(...) SK_REQUIRE_LOCAL_VAR(SkAutoMutexAcquire) |
michael@0 | 107 | |
michael@0 | 108 | #endif |