gfx/skia/trunk/include/core/SkChunkAlloc.h

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.

michael@0 1
michael@0 2 /*
michael@0 3 * Copyright 2006 The Android Open Source Project
michael@0 4 *
michael@0 5 * Use of this source code is governed by a BSD-style license that can be
michael@0 6 * found in the LICENSE file.
michael@0 7 */
michael@0 8
michael@0 9
michael@0 10 #ifndef SkChunkAlloc_DEFINED
michael@0 11 #define SkChunkAlloc_DEFINED
michael@0 12
michael@0 13 #include "SkTypes.h"
michael@0 14
michael@0 15 class SkChunkAlloc : SkNoncopyable {
michael@0 16 public:
michael@0 17 SkChunkAlloc(size_t minSize);
michael@0 18 ~SkChunkAlloc();
michael@0 19
michael@0 20 /**
michael@0 21 * Free up all allocated blocks. This invalidates all returned
michael@0 22 * pointers.
michael@0 23 */
michael@0 24 void reset();
michael@0 25
michael@0 26 enum AllocFailType {
michael@0 27 kReturnNil_AllocFailType,
michael@0 28 kThrow_AllocFailType
michael@0 29 };
michael@0 30
michael@0 31 void* alloc(size_t bytes, AllocFailType);
michael@0 32 void* allocThrow(size_t bytes) {
michael@0 33 return this->alloc(bytes, kThrow_AllocFailType);
michael@0 34 }
michael@0 35
michael@0 36 /** Call this to unalloc the most-recently allocated ptr by alloc(). On
michael@0 37 success, the number of bytes freed is returned, or 0 if the block could
michael@0 38 not be unallocated. This is a hint to the underlying allocator that
michael@0 39 the previous allocation may be reused, but the implementation is free
michael@0 40 to ignore this call (and return 0).
michael@0 41 */
michael@0 42 size_t unalloc(void* ptr);
michael@0 43
michael@0 44 size_t totalCapacity() const { return fTotalCapacity; }
michael@0 45 size_t totalUsed() const { return fTotalUsed; }
michael@0 46 int blockCount() const { return fBlockCount; }
michael@0 47
michael@0 48 /**
michael@0 49 * Returns true if the specified address is within one of the chunks, and
michael@0 50 * has at least 1-byte following the address (i.e. if addr points to the
michael@0 51 * end of a chunk, then contains() will return false).
michael@0 52 */
michael@0 53 bool contains(const void* addr) const;
michael@0 54
michael@0 55 private:
michael@0 56 struct Block;
michael@0 57
michael@0 58 Block* fBlock;
michael@0 59 size_t fMinSize;
michael@0 60 size_t fChunkSize;
michael@0 61 size_t fTotalCapacity;
michael@0 62 size_t fTotalUsed; // will be <= fTotalCapacity
michael@0 63 int fBlockCount;
michael@0 64
michael@0 65 Block* newBlock(size_t bytes, AllocFailType ftype);
michael@0 66 };
michael@0 67
michael@0 68 #endif

mercurial