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 2012 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 | #include "SkBitmap.h" |
michael@0 | 9 | #include "SkChunkAlloc.h" |
michael@0 | 10 | #include "SkGPipe.h" |
michael@0 | 11 | #include "SkPicture.h" |
michael@0 | 12 | #include "SkTDArray.h" |
michael@0 | 13 | |
michael@0 | 14 | class SkCanvas; |
michael@0 | 15 | class SkMatrix; |
michael@0 | 16 | |
michael@0 | 17 | class PipeController : public SkGPipeController { |
michael@0 | 18 | public: |
michael@0 | 19 | PipeController(SkCanvas* target, SkPicture::InstallPixelRefProc proc = NULL); |
michael@0 | 20 | virtual ~PipeController(); |
michael@0 | 21 | virtual void* requestBlock(size_t minRequest, size_t* actual) SK_OVERRIDE; |
michael@0 | 22 | virtual void notifyWritten(size_t bytes) SK_OVERRIDE; |
michael@0 | 23 | protected: |
michael@0 | 24 | const void* getData() { return (const char*) fBlock + fBytesWritten; } |
michael@0 | 25 | SkGPipeReader fReader; |
michael@0 | 26 | private: |
michael@0 | 27 | void* fBlock; |
michael@0 | 28 | size_t fBlockSize; |
michael@0 | 29 | size_t fBytesWritten; |
michael@0 | 30 | SkGPipeReader::Status fStatus; |
michael@0 | 31 | }; |
michael@0 | 32 | |
michael@0 | 33 | //////////////////////////////////////////////////////////////////////////////// |
michael@0 | 34 | |
michael@0 | 35 | class TiledPipeController : public PipeController { |
michael@0 | 36 | public: |
michael@0 | 37 | TiledPipeController(const SkBitmap&, SkPicture::InstallPixelRefProc proc = NULL, |
michael@0 | 38 | const SkMatrix* initialMatrix = NULL); |
michael@0 | 39 | virtual ~TiledPipeController() {}; |
michael@0 | 40 | virtual void notifyWritten(size_t bytes) SK_OVERRIDE; |
michael@0 | 41 | virtual int numberOfReaders() const SK_OVERRIDE { return NumberOfTiles; } |
michael@0 | 42 | private: |
michael@0 | 43 | enum { |
michael@0 | 44 | NumberOfTiles = 10 |
michael@0 | 45 | }; |
michael@0 | 46 | SkGPipeReader fReaders[NumberOfTiles - 1]; |
michael@0 | 47 | SkBitmap fBitmaps[NumberOfTiles]; |
michael@0 | 48 | typedef PipeController INHERITED; |
michael@0 | 49 | }; |
michael@0 | 50 | |
michael@0 | 51 | //////////////////////////////////////////////////////////////////////////////// |
michael@0 | 52 | |
michael@0 | 53 | /** |
michael@0 | 54 | * Borrowed (and modified) from SkDeferredCanvas.cpp::DeferredPipeController. |
michael@0 | 55 | * Allows playing back from multiple threads, but does not do the threading itself. |
michael@0 | 56 | */ |
michael@0 | 57 | class ThreadSafePipeController : public SkGPipeController { |
michael@0 | 58 | public: |
michael@0 | 59 | ThreadSafePipeController(int numberOfReaders); |
michael@0 | 60 | virtual void* requestBlock(size_t minRequest, size_t* actual) SK_OVERRIDE; |
michael@0 | 61 | virtual void notifyWritten(size_t bytes) SK_OVERRIDE; |
michael@0 | 62 | virtual int numberOfReaders() const SK_OVERRIDE { return fNumberOfReaders; } |
michael@0 | 63 | |
michael@0 | 64 | /** |
michael@0 | 65 | * Play the stored drawing commands to the specified canvas. If SkGPipeWriter::startRecording |
michael@0 | 66 | * used the flag SkGPipeWriter::kSimultaneousReaders_Flag, this can be called from different |
michael@0 | 67 | * threads simultaneously. |
michael@0 | 68 | */ |
michael@0 | 69 | void draw(SkCanvas*); |
michael@0 | 70 | private: |
michael@0 | 71 | enum { |
michael@0 | 72 | kMinBlockSize = 4096 |
michael@0 | 73 | }; |
michael@0 | 74 | struct PipeBlock { |
michael@0 | 75 | PipeBlock(void* block, size_t bytes) { fBlock = block, fBytes = bytes; } |
michael@0 | 76 | // Stream of draw commands written by the SkGPipeWriter. Allocated by fAllocator, which will |
michael@0 | 77 | // handle freeing it. |
michael@0 | 78 | void* fBlock; |
michael@0 | 79 | // Number of bytes that were written to fBlock. |
michael@0 | 80 | size_t fBytes; |
michael@0 | 81 | }; |
michael@0 | 82 | void* fBlock; |
michael@0 | 83 | size_t fBytesWritten; |
michael@0 | 84 | SkChunkAlloc fAllocator; |
michael@0 | 85 | SkTDArray<PipeBlock> fBlockList; |
michael@0 | 86 | int fNumberOfReaders; |
michael@0 | 87 | }; |