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 | /* |
michael@0 | 3 | * Copyright 2011 Google Inc. |
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 | #ifndef SkWriteBuffer_DEFINED |
michael@0 | 10 | #define SkWriteBuffer_DEFINED |
michael@0 | 11 | |
michael@0 | 12 | #include "SkBitmapHeap.h" |
michael@0 | 13 | #include "SkData.h" |
michael@0 | 14 | #include "SkPath.h" |
michael@0 | 15 | #include "SkPicture.h" |
michael@0 | 16 | #include "SkRefCnt.h" |
michael@0 | 17 | #include "SkWriter32.h" |
michael@0 | 18 | |
michael@0 | 19 | class SkBitmap; |
michael@0 | 20 | class SkFactorySet; |
michael@0 | 21 | class SkFlattenable; |
michael@0 | 22 | class SkNamedFactorySet; |
michael@0 | 23 | class SkRefCntSet; |
michael@0 | 24 | |
michael@0 | 25 | class SkWriteBuffer { |
michael@0 | 26 | public: |
michael@0 | 27 | enum Flags { |
michael@0 | 28 | kCrossProcess_Flag = 1 << 0, |
michael@0 | 29 | kValidation_Flag = 1 << 1, |
michael@0 | 30 | }; |
michael@0 | 31 | |
michael@0 | 32 | SkWriteBuffer(uint32_t flags = 0); |
michael@0 | 33 | SkWriteBuffer(void* initialStorage, size_t storageSize, uint32_t flags = 0); |
michael@0 | 34 | ~SkWriteBuffer(); |
michael@0 | 35 | |
michael@0 | 36 | bool isCrossProcess() const { |
michael@0 | 37 | return this->isValidating() || SkToBool(fFlags & kCrossProcess_Flag); |
michael@0 | 38 | } |
michael@0 | 39 | |
michael@0 | 40 | SkWriter32* getWriter32() { return &fWriter; } |
michael@0 | 41 | void reset(void* storage = NULL, size_t storageSize = 0) { |
michael@0 | 42 | fWriter.reset(storage, storageSize); |
michael@0 | 43 | } |
michael@0 | 44 | |
michael@0 | 45 | uint32_t* reserve(size_t size) { return fWriter.reserve(size); } |
michael@0 | 46 | |
michael@0 | 47 | size_t bytesWritten() const { return fWriter.bytesWritten(); } |
michael@0 | 48 | |
michael@0 | 49 | void writeByteArray(const void* data, size_t size); |
michael@0 | 50 | void writeDataAsByteArray(SkData* data) { this->writeByteArray(data->data(), data->size()); } |
michael@0 | 51 | void writeBool(bool value); |
michael@0 | 52 | void writeFixed(SkFixed value); |
michael@0 | 53 | void writeScalar(SkScalar value); |
michael@0 | 54 | void writeScalarArray(const SkScalar* value, uint32_t count); |
michael@0 | 55 | void writeInt(int32_t value); |
michael@0 | 56 | void writeIntArray(const int32_t* value, uint32_t count); |
michael@0 | 57 | void writeUInt(uint32_t value); |
michael@0 | 58 | void write32(int32_t value); |
michael@0 | 59 | void writeString(const char* value); |
michael@0 | 60 | void writeEncodedString(const void* value, size_t byteLength, SkPaint::TextEncoding encoding); |
michael@0 | 61 | void writeFunctionPtr(void* ptr) { this->writeByteArray(&ptr, sizeof(ptr)); } |
michael@0 | 62 | |
michael@0 | 63 | void writeFlattenable(const SkFlattenable* flattenable); |
michael@0 | 64 | void writeColor(const SkColor& color); |
michael@0 | 65 | void writeColorArray(const SkColor* color, uint32_t count); |
michael@0 | 66 | void writePoint(const SkPoint& point); |
michael@0 | 67 | void writePointArray(const SkPoint* point, uint32_t count); |
michael@0 | 68 | void writeMatrix(const SkMatrix& matrix); |
michael@0 | 69 | void writeIRect(const SkIRect& rect); |
michael@0 | 70 | void writeRect(const SkRect& rect); |
michael@0 | 71 | void writeRegion(const SkRegion& region); |
michael@0 | 72 | void writePath(const SkPath& path); |
michael@0 | 73 | size_t writeStream(SkStream* stream, size_t length); |
michael@0 | 74 | void writeBitmap(const SkBitmap& bitmap); |
michael@0 | 75 | void writeTypeface(SkTypeface* typeface); |
michael@0 | 76 | void writePaint(const SkPaint& paint) { paint.flatten(*this); } |
michael@0 | 77 | |
michael@0 | 78 | bool writeToStream(SkWStream*); |
michael@0 | 79 | void writeToMemory(void* dst) { fWriter.flatten(dst); } |
michael@0 | 80 | |
michael@0 | 81 | SkFactorySet* setFactoryRecorder(SkFactorySet*); |
michael@0 | 82 | SkNamedFactorySet* setNamedFactoryRecorder(SkNamedFactorySet*); |
michael@0 | 83 | |
michael@0 | 84 | SkRefCntSet* getTypefaceRecorder() const { return fTFSet; } |
michael@0 | 85 | SkRefCntSet* setTypefaceRecorder(SkRefCntSet*); |
michael@0 | 86 | |
michael@0 | 87 | /** |
michael@0 | 88 | * Set an SkBitmapHeap to store bitmaps rather than flattening. |
michael@0 | 89 | * |
michael@0 | 90 | * Incompatible with an EncodeBitmap function. If an EncodeBitmap function is set, setting an |
michael@0 | 91 | * SkBitmapHeap will set the function to NULL in release mode and crash in debug. |
michael@0 | 92 | */ |
michael@0 | 93 | void setBitmapHeap(SkBitmapHeap*); |
michael@0 | 94 | |
michael@0 | 95 | /** |
michael@0 | 96 | * Provide a function to encode an SkBitmap to an SkData. writeBitmap will attempt to use |
michael@0 | 97 | * bitmapEncoder to store the SkBitmap. If the reader does not provide a function to decode, it |
michael@0 | 98 | * will not be able to restore SkBitmaps, but will still be able to read the rest of the stream. |
michael@0 | 99 | * bitmapEncoder will never be called with a NULL pixelRefOffset. |
michael@0 | 100 | * |
michael@0 | 101 | * Incompatible with the SkBitmapHeap. If an encoder is set fBitmapHeap will be set to NULL in |
michael@0 | 102 | * release and crash in debug. |
michael@0 | 103 | */ |
michael@0 | 104 | void setBitmapEncoder(SkPicture::EncodeBitmap bitmapEncoder); |
michael@0 | 105 | |
michael@0 | 106 | private: |
michael@0 | 107 | bool isValidating() const { return SkToBool(fFlags & kValidation_Flag); } |
michael@0 | 108 | |
michael@0 | 109 | const uint32_t fFlags; |
michael@0 | 110 | SkFactorySet* fFactorySet; |
michael@0 | 111 | SkNamedFactorySet* fNamedFactorySet; |
michael@0 | 112 | SkWriter32 fWriter; |
michael@0 | 113 | |
michael@0 | 114 | SkBitmapHeap* fBitmapHeap; |
michael@0 | 115 | SkRefCntSet* fTFSet; |
michael@0 | 116 | |
michael@0 | 117 | SkPicture::EncodeBitmap fBitmapEncoder; |
michael@0 | 118 | }; |
michael@0 | 119 | |
michael@0 | 120 | #endif // SkWriteBuffer_DEFINED |