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 2006 The Android Open Source Project |
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 | |
michael@0 | 10 | #ifndef SkFlattenable_DEFINED |
michael@0 | 11 | #define SkFlattenable_DEFINED |
michael@0 | 12 | |
michael@0 | 13 | #include "SkRefCnt.h" |
michael@0 | 14 | |
michael@0 | 15 | class SkReadBuffer; |
michael@0 | 16 | class SkWriteBuffer; |
michael@0 | 17 | |
michael@0 | 18 | #define SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(flattenable) \ |
michael@0 | 19 | SkFlattenable::Registrar(#flattenable, flattenable::CreateProc, \ |
michael@0 | 20 | flattenable::GetFlattenableType()); |
michael@0 | 21 | |
michael@0 | 22 | #define SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP() static void InitializeFlattenables(); |
michael@0 | 23 | |
michael@0 | 24 | #define SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(flattenable) \ |
michael@0 | 25 | void flattenable::InitializeFlattenables() { |
michael@0 | 26 | |
michael@0 | 27 | #define SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END \ |
michael@0 | 28 | } |
michael@0 | 29 | |
michael@0 | 30 | #define SK_DECLARE_UNFLATTENABLE_OBJECT() \ |
michael@0 | 31 | virtual Factory getFactory() const SK_OVERRIDE { return NULL; } |
michael@0 | 32 | |
michael@0 | 33 | #define SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(flattenable) \ |
michael@0 | 34 | virtual Factory getFactory() const SK_OVERRIDE { return CreateProc; } \ |
michael@0 | 35 | static SkFlattenable* CreateProc(SkReadBuffer& buffer) { \ |
michael@0 | 36 | return SkNEW_ARGS(flattenable, (buffer)); \ |
michael@0 | 37 | } |
michael@0 | 38 | |
michael@0 | 39 | /** For SkFlattenable derived objects with a valid type |
michael@0 | 40 | This macro should only be used in base class objects in core |
michael@0 | 41 | */ |
michael@0 | 42 | #define SK_DEFINE_FLATTENABLE_TYPE(flattenable) \ |
michael@0 | 43 | static Type GetFlattenableType() { \ |
michael@0 | 44 | return k##flattenable##_Type; \ |
michael@0 | 45 | } |
michael@0 | 46 | |
michael@0 | 47 | /** \class SkFlattenable |
michael@0 | 48 | |
michael@0 | 49 | SkFlattenable is the base class for objects that need to be flattened |
michael@0 | 50 | into a data stream for either transport or as part of the key to the |
michael@0 | 51 | font cache. |
michael@0 | 52 | */ |
michael@0 | 53 | class SK_API SkFlattenable : public SkRefCnt { |
michael@0 | 54 | public: |
michael@0 | 55 | enum Type { |
michael@0 | 56 | kSkColorFilter_Type, |
michael@0 | 57 | kSkDrawLooper_Type, |
michael@0 | 58 | kSkImageFilter_Type, |
michael@0 | 59 | kSkMaskFilter_Type, |
michael@0 | 60 | kSkPathEffect_Type, |
michael@0 | 61 | kSkPixelRef_Type, |
michael@0 | 62 | kSkRasterizer_Type, |
michael@0 | 63 | kSkShader_Type, |
michael@0 | 64 | kSkUnitMapper_Type, |
michael@0 | 65 | kSkXfermode_Type, |
michael@0 | 66 | }; |
michael@0 | 67 | |
michael@0 | 68 | SK_DECLARE_INST_COUNT(SkFlattenable) |
michael@0 | 69 | |
michael@0 | 70 | typedef SkFlattenable* (*Factory)(SkReadBuffer&); |
michael@0 | 71 | |
michael@0 | 72 | SkFlattenable() {} |
michael@0 | 73 | |
michael@0 | 74 | /** Implement this to return a factory function pointer that can be called |
michael@0 | 75 | to recreate your class given a buffer (previously written to by your |
michael@0 | 76 | override of flatten(). |
michael@0 | 77 | */ |
michael@0 | 78 | virtual Factory getFactory() const = 0; |
michael@0 | 79 | |
michael@0 | 80 | /** Returns the name of the object's class |
michael@0 | 81 | */ |
michael@0 | 82 | const char* getTypeName() const { return FactoryToName(getFactory()); } |
michael@0 | 83 | |
michael@0 | 84 | static Factory NameToFactory(const char name[]); |
michael@0 | 85 | static const char* FactoryToName(Factory); |
michael@0 | 86 | static bool NameToType(const char name[], Type* type); |
michael@0 | 87 | |
michael@0 | 88 | static void Register(const char name[], Factory, Type); |
michael@0 | 89 | |
michael@0 | 90 | class Registrar { |
michael@0 | 91 | public: |
michael@0 | 92 | Registrar(const char name[], Factory factory, Type type) { |
michael@0 | 93 | SkFlattenable::Register(name, factory, type); |
michael@0 | 94 | } |
michael@0 | 95 | }; |
michael@0 | 96 | |
michael@0 | 97 | /** Override this to write data specific to your subclass into the buffer, |
michael@0 | 98 | being sure to call your super-class' version first. This data will later |
michael@0 | 99 | be passed to your Factory function, returned by getFactory(). |
michael@0 | 100 | */ |
michael@0 | 101 | virtual void flatten(SkWriteBuffer&) const; |
michael@0 | 102 | |
michael@0 | 103 | protected: |
michael@0 | 104 | SkFlattenable(SkReadBuffer&) {} |
michael@0 | 105 | |
michael@0 | 106 | private: |
michael@0 | 107 | static void InitializeFlattenablesIfNeeded(); |
michael@0 | 108 | |
michael@0 | 109 | friend class SkGraphics; |
michael@0 | 110 | |
michael@0 | 111 | typedef SkRefCnt INHERITED; |
michael@0 | 112 | }; |
michael@0 | 113 | |
michael@0 | 114 | #endif |