gfx/skia/trunk/src/gpu/GrAllocPool.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.

     1 /*
     2  * Copyright 2010 Google Inc.
     3  *
     4  * Use of this source code is governed by a BSD-style license that can be
     5  * found in the LICENSE file.
     6  */
     8 #ifndef GrAllocPool_DEFINED
     9 #define GrAllocPool_DEFINED
    11 #include "SkTypes.h"
    13 class GrAllocPool : public SkNoncopyable {
    14 public:
    15     GrAllocPool(size_t blockSize = 0);
    16     ~GrAllocPool();
    18     /**
    19      *  Frees all blocks that have been allocated with alloc().
    20      */
    21     void reset();
    23     /**
    24      *  Returns a block of memory bytes size big. This address must not be
    25      *  passed to realloc/free/delete or any other function that assumes the
    26      *  address was allocated by malloc or new (because it hasn't).
    27      */
    28     void* alloc(size_t bytes);
    30     /**
    31      * Releases the most recently allocated bytes back to allocpool.
    32      */
    33     void release(size_t bytes);
    35 private:
    36     struct Block;
    38     Block*  fBlock;
    39     size_t  fMinBlockSize;
    41 #ifdef SK_DEBUG
    42     int fBlocksAllocated;
    43     void validate() const;
    44 #else
    45     void validate() const {}
    46 #endif
    47 };
    49 template <typename T> class GrTAllocPool {
    50 public:
    51     GrTAllocPool(int count) : fPool(count * sizeof(T)) {}
    53     void reset() { fPool.reset(); }
    54     T* alloc() { return (T*)fPool.alloc(sizeof(T)); }
    56 private:
    57     GrAllocPool fPool;
    58 };
    60 #endif

mercurial