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 2008 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 | |
michael@0 | 9 | #ifndef SkMallocPixelRef_DEFINED |
michael@0 | 10 | #define SkMallocPixelRef_DEFINED |
michael@0 | 11 | |
michael@0 | 12 | #include "SkPixelRef.h" |
michael@0 | 13 | |
michael@0 | 14 | /** We explicitly use the same allocator for our pixels that SkMask does, |
michael@0 | 15 | so that we can freely assign memory allocated by one class to the other. |
michael@0 | 16 | */ |
michael@0 | 17 | class SK_API SkMallocPixelRef : public SkPixelRef { |
michael@0 | 18 | public: |
michael@0 | 19 | SK_DECLARE_INST_COUNT(SkMallocPixelRef) |
michael@0 | 20 | /** |
michael@0 | 21 | * Return a new SkMallocPixelRef with the provided pixel storage, rowBytes, |
michael@0 | 22 | * and optional colortable. The caller is responsible for managing the |
michael@0 | 23 | * lifetime of the pixel storage buffer, as this pixelref will not try |
michael@0 | 24 | * to delete it. |
michael@0 | 25 | * |
michael@0 | 26 | * The pixelref will ref() the colortable (if not NULL). |
michael@0 | 27 | * |
michael@0 | 28 | * Returns NULL on failure. |
michael@0 | 29 | */ |
michael@0 | 30 | static SkMallocPixelRef* NewDirect(const SkImageInfo&, void* addr, |
michael@0 | 31 | size_t rowBytes, SkColorTable*); |
michael@0 | 32 | |
michael@0 | 33 | /** |
michael@0 | 34 | * Return a new SkMallocPixelRef, automatically allocating storage for the |
michael@0 | 35 | * pixels. If rowBytes are 0, an optimal value will be chosen automatically. |
michael@0 | 36 | * If rowBytes is > 0, then it will be respected, or NULL will be returned |
michael@0 | 37 | * if rowBytes is invalid for the specified info. |
michael@0 | 38 | * |
michael@0 | 39 | * This pixelref will ref() the specified colortable (if not NULL). |
michael@0 | 40 | * |
michael@0 | 41 | * Returns NULL on failure. |
michael@0 | 42 | */ |
michael@0 | 43 | static SkMallocPixelRef* NewAllocate(const SkImageInfo& info, |
michael@0 | 44 | size_t rowBytes, SkColorTable*); |
michael@0 | 45 | |
michael@0 | 46 | /** |
michael@0 | 47 | * Return a new SkMallocPixelRef with the provided pixel storage, |
michael@0 | 48 | * rowBytes, and optional colortable. On destruction, ReleaseProc |
michael@0 | 49 | * will be called. |
michael@0 | 50 | * |
michael@0 | 51 | * This pixelref will ref() the specified colortable (if not NULL). |
michael@0 | 52 | * |
michael@0 | 53 | * Returns NULL on failure. |
michael@0 | 54 | */ |
michael@0 | 55 | typedef void (*ReleaseProc)(void* addr, void* context); |
michael@0 | 56 | static SkMallocPixelRef* NewWithProc(const SkImageInfo& info, |
michael@0 | 57 | size_t rowBytes, SkColorTable*, |
michael@0 | 58 | void* addr, ReleaseProc proc, |
michael@0 | 59 | void* context); |
michael@0 | 60 | |
michael@0 | 61 | /** |
michael@0 | 62 | * Return a new SkMallocPixelRef that will use the provided |
michael@0 | 63 | * SkData, rowBytes, and optional colortable as pixel storage. |
michael@0 | 64 | * The SkData will be ref()ed and on destruction of the PielRef, |
michael@0 | 65 | * the SkData will be unref()ed. |
michael@0 | 66 | * |
michael@0 | 67 | * @param offset (in bytes) into the provided SkData that the |
michael@0 | 68 | * first pixel is located at. |
michael@0 | 69 | * |
michael@0 | 70 | * This pixelref will ref() the specified colortable (if not NULL). |
michael@0 | 71 | * |
michael@0 | 72 | * Returns NULL on failure. |
michael@0 | 73 | */ |
michael@0 | 74 | static SkMallocPixelRef* NewWithData(const SkImageInfo& info, |
michael@0 | 75 | size_t rowBytes, |
michael@0 | 76 | SkColorTable* ctable, |
michael@0 | 77 | SkData* data, |
michael@0 | 78 | size_t offset = 0); |
michael@0 | 79 | |
michael@0 | 80 | void* getAddr() const { return fStorage; } |
michael@0 | 81 | |
michael@0 | 82 | class PRFactory : public SkPixelRefFactory { |
michael@0 | 83 | public: |
michael@0 | 84 | virtual SkPixelRef* create(const SkImageInfo&, |
michael@0 | 85 | SkColorTable*) SK_OVERRIDE; |
michael@0 | 86 | }; |
michael@0 | 87 | |
michael@0 | 88 | SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkMallocPixelRef) |
michael@0 | 89 | |
michael@0 | 90 | protected: |
michael@0 | 91 | // The ownPixels version of this constructor is deprecated. |
michael@0 | 92 | SkMallocPixelRef(const SkImageInfo&, void* addr, size_t rb, SkColorTable*, |
michael@0 | 93 | bool ownPixels); |
michael@0 | 94 | SkMallocPixelRef(SkReadBuffer& buffer); |
michael@0 | 95 | virtual ~SkMallocPixelRef(); |
michael@0 | 96 | |
michael@0 | 97 | virtual bool onNewLockPixels(LockRec*) SK_OVERRIDE; |
michael@0 | 98 | virtual void onUnlockPixels() SK_OVERRIDE; |
michael@0 | 99 | virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; |
michael@0 | 100 | virtual size_t getAllocatedSizeInBytes() const SK_OVERRIDE; |
michael@0 | 101 | |
michael@0 | 102 | private: |
michael@0 | 103 | void* fStorage; |
michael@0 | 104 | SkColorTable* fCTable; |
michael@0 | 105 | size_t fRB; |
michael@0 | 106 | ReleaseProc fReleaseProc; |
michael@0 | 107 | void* fReleaseProcContext; |
michael@0 | 108 | |
michael@0 | 109 | SkMallocPixelRef(const SkImageInfo&, void* addr, size_t rb, SkColorTable*, |
michael@0 | 110 | ReleaseProc proc, void* context); |
michael@0 | 111 | |
michael@0 | 112 | typedef SkPixelRef INHERITED; |
michael@0 | 113 | }; |
michael@0 | 114 | |
michael@0 | 115 | |
michael@0 | 116 | #endif |