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 2011 Google Inc. |
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 | |
michael@0 | 10 | #ifndef SkGPipe_DEFINED |
michael@0 | 11 | #define SkGPipe_DEFINED |
michael@0 | 12 | |
michael@0 | 13 | #include "SkFlattenable.h" |
michael@0 | 14 | #include "SkPicture.h" |
michael@0 | 15 | #include "SkWriter32.h" |
michael@0 | 16 | |
michael@0 | 17 | class SkCanvas; |
michael@0 | 18 | |
michael@0 | 19 | // XLib.h might have defined Status already (ugh) |
michael@0 | 20 | #ifdef Status |
michael@0 | 21 | #undef Status |
michael@0 | 22 | #endif |
michael@0 | 23 | |
michael@0 | 24 | class SkGPipeReader { |
michael@0 | 25 | public: |
michael@0 | 26 | SkGPipeReader(); |
michael@0 | 27 | SkGPipeReader(SkCanvas* target); |
michael@0 | 28 | ~SkGPipeReader(); |
michael@0 | 29 | |
michael@0 | 30 | enum Status { |
michael@0 | 31 | kDone_Status, //!< no more data expected from reader |
michael@0 | 32 | kEOF_Status, //!< need more data from reader |
michael@0 | 33 | kError_Status, //!< encountered error |
michael@0 | 34 | kReadAtom_Status//!< finished reading an atom |
michael@0 | 35 | }; |
michael@0 | 36 | |
michael@0 | 37 | enum PlaybackFlags { |
michael@0 | 38 | kReadAtom_PlaybackFlag = 0x1, //!< playback a single command from the stream |
michael@0 | 39 | kSilent_PlaybackFlag = 0x2, //!< playback without drawing |
michael@0 | 40 | }; |
michael@0 | 41 | |
michael@0 | 42 | void setCanvas(SkCanvas*); |
michael@0 | 43 | |
michael@0 | 44 | /** |
michael@0 | 45 | * Set a function for decoding bitmaps that have encoded data. |
michael@0 | 46 | */ |
michael@0 | 47 | void setBitmapDecoder(SkPicture::InstallPixelRefProc proc) { fProc = proc; } |
michael@0 | 48 | |
michael@0 | 49 | // data must be 4-byte aligned |
michael@0 | 50 | // length must be a multiple of 4 |
michael@0 | 51 | Status playback(const void* data, size_t length, uint32_t playbackFlags = 0, |
michael@0 | 52 | size_t* bytesRead = NULL); |
michael@0 | 53 | private: |
michael@0 | 54 | SkCanvas* fCanvas; |
michael@0 | 55 | class SkGPipeState* fState; |
michael@0 | 56 | SkPicture::InstallPixelRefProc fProc; |
michael@0 | 57 | }; |
michael@0 | 58 | |
michael@0 | 59 | /////////////////////////////////////////////////////////////////////////////// |
michael@0 | 60 | |
michael@0 | 61 | class SkGPipeCanvas; |
michael@0 | 62 | |
michael@0 | 63 | class SkGPipeController { |
michael@0 | 64 | public: |
michael@0 | 65 | SkGPipeController() : fCanvas(NULL) {} |
michael@0 | 66 | virtual ~SkGPipeController(); |
michael@0 | 67 | |
michael@0 | 68 | /** |
michael@0 | 69 | * Called periodically by the writer, to get a working buffer of RAM to |
michael@0 | 70 | * write into. The actual size of the block is also returned, and must be |
michael@0 | 71 | * actual >= minRequest. If NULL is returned, then actual is ignored and |
michael@0 | 72 | * writing will stop. |
michael@0 | 73 | * |
michael@0 | 74 | * The returned block must be 4-byte aligned, and actual must be a |
michael@0 | 75 | * multiple of 4. |
michael@0 | 76 | * minRequest will always be a multiple of 4. |
michael@0 | 77 | */ |
michael@0 | 78 | virtual void* requestBlock(size_t minRequest, size_t* actual) = 0; |
michael@0 | 79 | |
michael@0 | 80 | /** |
michael@0 | 81 | * This is called each time some atomic portion of the data has been |
michael@0 | 82 | * written to the block (most recently returned by requestBlock()). |
michael@0 | 83 | * If bytes == 0, then the writer has finished. |
michael@0 | 84 | * |
michael@0 | 85 | * bytes will always be a multiple of 4. |
michael@0 | 86 | */ |
michael@0 | 87 | virtual void notifyWritten(size_t bytes) = 0; |
michael@0 | 88 | virtual int numberOfReaders() const { return 1; } |
michael@0 | 89 | |
michael@0 | 90 | private: |
michael@0 | 91 | friend class SkGPipeWriter; |
michael@0 | 92 | void setCanvas(SkGPipeCanvas*); |
michael@0 | 93 | |
michael@0 | 94 | SkGPipeCanvas* fCanvas; |
michael@0 | 95 | }; |
michael@0 | 96 | |
michael@0 | 97 | class SkGPipeWriter { |
michael@0 | 98 | public: |
michael@0 | 99 | SkGPipeWriter(); |
michael@0 | 100 | ~SkGPipeWriter(); |
michael@0 | 101 | |
michael@0 | 102 | bool isRecording() const { return NULL != fCanvas; } |
michael@0 | 103 | |
michael@0 | 104 | enum Flags { |
michael@0 | 105 | /** |
michael@0 | 106 | * Tells the writer that the reader will be in a different process, so |
michael@0 | 107 | * (for example) we cannot put function pointers in the stream. |
michael@0 | 108 | */ |
michael@0 | 109 | kCrossProcess_Flag = 1 << 0, |
michael@0 | 110 | |
michael@0 | 111 | /** |
michael@0 | 112 | * Only meaningful if kCrossProcess_Flag is set. Tells the writer that |
michael@0 | 113 | * in spite of being cross process, it will have shared address space |
michael@0 | 114 | * with the reader, so the two can share large objects (like SkBitmaps). |
michael@0 | 115 | */ |
michael@0 | 116 | kSharedAddressSpace_Flag = 1 << 1, |
michael@0 | 117 | |
michael@0 | 118 | /** |
michael@0 | 119 | * Tells the writer that there will be multiple threads reading the stream |
michael@0 | 120 | * simultaneously. |
michael@0 | 121 | */ |
michael@0 | 122 | kSimultaneousReaders_Flag = 1 << 2, |
michael@0 | 123 | }; |
michael@0 | 124 | |
michael@0 | 125 | SkCanvas* startRecording(SkGPipeController*, uint32_t flags = 0, |
michael@0 | 126 | uint32_t width = kDefaultRecordingCanvasSize, |
michael@0 | 127 | uint32_t height = kDefaultRecordingCanvasSize); |
michael@0 | 128 | |
michael@0 | 129 | // called in destructor, but can be called sooner once you know there |
michael@0 | 130 | // should be no more drawing calls made into the recording canvas. |
michael@0 | 131 | void endRecording(); |
michael@0 | 132 | |
michael@0 | 133 | /** |
michael@0 | 134 | * Tells the writer to commit all recorded draw commands to the |
michael@0 | 135 | * controller immediately. |
michael@0 | 136 | * @param detachCurrentBlock Set to true to request that the next draw |
michael@0 | 137 | * command be recorded in a new block. |
michael@0 | 138 | */ |
michael@0 | 139 | void flushRecording(bool detachCurrentBlock); |
michael@0 | 140 | |
michael@0 | 141 | /** |
michael@0 | 142 | * Return the amount of bytes being used for recording. Note that this |
michael@0 | 143 | * does not include the amount of storage written to the stream, which is |
michael@0 | 144 | * controlled by the SkGPipeController. |
michael@0 | 145 | * Currently only returns the amount used for SkBitmaps, since they are |
michael@0 | 146 | * potentially unbounded (if the client is not calling playback). |
michael@0 | 147 | */ |
michael@0 | 148 | size_t storageAllocatedForRecording() const; |
michael@0 | 149 | |
michael@0 | 150 | /** |
michael@0 | 151 | * Attempt to reduce the storage allocated for recording by evicting |
michael@0 | 152 | * cache resources. |
michael@0 | 153 | * @param bytesToFree minimum number of bytes that should be attempted to |
michael@0 | 154 | * be freed. |
michael@0 | 155 | * @return number of bytes actually freed. |
michael@0 | 156 | */ |
michael@0 | 157 | size_t freeMemoryIfPossible(size_t bytesToFree); |
michael@0 | 158 | |
michael@0 | 159 | private: |
michael@0 | 160 | enum { |
michael@0 | 161 | kDefaultRecordingCanvasSize = 32767, |
michael@0 | 162 | }; |
michael@0 | 163 | |
michael@0 | 164 | SkGPipeCanvas* fCanvas; |
michael@0 | 165 | SkWriter32 fWriter; |
michael@0 | 166 | }; |
michael@0 | 167 | |
michael@0 | 168 | #endif |