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 */
8 #ifndef SkPathHeap_DEFINED
9 #define SkPathHeap_DEFINED
11 #include "SkRefCnt.h"
12 #include "SkChunkAlloc.h"
13 #include "SkTDArray.h"
15 class SkPath;
16 class SkReadBuffer;
17 class SkWriteBuffer;
19 class SkPathHeap : public SkRefCnt {
20 public:
21 SK_DECLARE_INST_COUNT(SkPathHeap)
23 SkPathHeap();
24 SkPathHeap(SkReadBuffer&);
25 virtual ~SkPathHeap();
27 /** Copy the path into the heap, and return the new total number of paths.
28 Thus, the returned value will be index+1, where index is the index of
29 this newly added (copied) path.
30 */
31 int append(const SkPath&);
33 /** Add the specified path to the heap using its gen ID to de-duplicate.
34 Returns the path's index in the heap + 1.
35 */
36 int insert(const SkPath&);
38 // called during picture-playback
39 int count() const { return fPaths.count(); }
40 const SkPath& operator[](int index) const {
41 return *fPaths[index];
42 }
44 void flatten(SkWriteBuffer&) const;
46 private:
47 // we store the paths in the heap (placement new)
48 SkChunkAlloc fHeap;
49 // we just store ptrs into fHeap here
50 SkTDArray<SkPath*> fPaths;
52 class LookupEntry {
53 public:
54 LookupEntry(const SkPath& path);
56 int storageSlot() const { return fStorageSlot; }
57 void setStorageSlot(int storageSlot) { fStorageSlot = storageSlot; }
59 static bool Less(const LookupEntry& a, const LookupEntry& b) {
60 return a.fGenerationID < b.fGenerationID;
61 }
63 private:
64 uint32_t fGenerationID; // the SkPath's generation ID
65 // the path's index in the heap + 1. It is 0 if the path is not yet in the heap.
66 int fStorageSlot;
67 };
69 SkTDArray<LookupEntry> fLookupTable;
71 SkPathHeap::LookupEntry* addIfNotPresent(const SkPath& path);
73 typedef SkRefCnt INHERITED;
74 };
76 #endif