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.
2 /*
3 * Copyright 2011 Google Inc.
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
7 */
10 #ifndef SkBitSet_DEFINED
11 #define SkBitSet_DEFINED
13 #include "SkTypes.h"
14 #include "SkTDArray.h"
16 class SkBitSet {
17 public:
18 /** NumberOfBits must be greater than zero.
19 */
20 explicit SkBitSet(int numberOfBits);
21 explicit SkBitSet(const SkBitSet& source);
23 SkBitSet& operator=(const SkBitSet& rhs);
24 bool operator==(const SkBitSet& rhs);
25 bool operator!=(const SkBitSet& rhs);
27 /** Clear all data.
28 */
29 void clearAll();
31 /** Set the value of the index-th bit.
32 */
33 void setBit(int index, bool value);
35 /** Test if bit index is set.
36 */
37 bool isBitSet(int index) const;
39 /** Or bits from source. false is returned if this doesn't have the same
40 * bit count as source.
41 */
42 bool orBits(const SkBitSet& source);
44 /** Export indices of set bits to T array.
45 */
46 template<typename T>
47 void exportTo(SkTDArray<T>* array) const {
48 SkASSERT(array);
49 uint32_t* data = reinterpret_cast<uint32_t*>(fBitData.get());
50 for (unsigned int i = 0; i < fDwordCount; ++i) {
51 uint32_t value = data[i];
52 if (value) { // There are set bits
53 unsigned int index = i * 32;
54 for (unsigned int j = 0; j < 32; ++j) {
55 if (0x1 & (value >> j)) {
56 array->push(index + j);
57 }
58 }
59 }
60 }
61 }
63 private:
64 SkAutoFree fBitData;
65 // Dword (32-bit) count of the bitset.
66 size_t fDwordCount;
67 size_t fBitCount;
69 uint32_t* internalGet(int index) const {
70 SkASSERT((size_t)index < fBitCount);
71 size_t internalIndex = index / 32;
72 SkASSERT(internalIndex < fDwordCount);
73 return reinterpret_cast<uint32_t*>(fBitData.get()) + internalIndex;
74 }
75 };
78 #endif