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 | #ifndef GrEffectUnitTest_DEFINED |
michael@0 | 9 | #define GrEffectUnitTest_DEFINED |
michael@0 | 10 | |
michael@0 | 11 | #include "SkRandom.h" |
michael@0 | 12 | #include "SkTArray.h" |
michael@0 | 13 | #include "SkTypes.h" |
michael@0 | 14 | |
michael@0 | 15 | class SkMatrix; |
michael@0 | 16 | class GrDrawTargetCaps; |
michael@0 | 17 | |
michael@0 | 18 | namespace GrEffectUnitTest { |
michael@0 | 19 | // Used to access the dummy textures in TestCreate procs. |
michael@0 | 20 | enum { |
michael@0 | 21 | kSkiaPMTextureIdx = 0, |
michael@0 | 22 | kAlphaTextureIdx = 1, |
michael@0 | 23 | }; |
michael@0 | 24 | |
michael@0 | 25 | /** |
michael@0 | 26 | * A helper for use in GrEffect::TestCreate functions. |
michael@0 | 27 | */ |
michael@0 | 28 | const SkMatrix& TestMatrix(SkRandom*); |
michael@0 | 29 | |
michael@0 | 30 | } |
michael@0 | 31 | |
michael@0 | 32 | #if SK_ALLOW_STATIC_GLOBAL_INITIALIZERS |
michael@0 | 33 | |
michael@0 | 34 | class GrContext; |
michael@0 | 35 | class GrEffectRef; |
michael@0 | 36 | class GrTexture; |
michael@0 | 37 | |
michael@0 | 38 | class GrEffectTestFactory : public SkNoncopyable { |
michael@0 | 39 | public: |
michael@0 | 40 | |
michael@0 | 41 | typedef GrEffectRef* (*CreateProc)(SkRandom*, |
michael@0 | 42 | GrContext*, |
michael@0 | 43 | const GrDrawTargetCaps& caps, |
michael@0 | 44 | GrTexture* dummyTextures[]); |
michael@0 | 45 | |
michael@0 | 46 | GrEffectTestFactory(CreateProc createProc) { |
michael@0 | 47 | fCreateProc = createProc; |
michael@0 | 48 | GetFactories()->push_back(this); |
michael@0 | 49 | } |
michael@0 | 50 | |
michael@0 | 51 | static GrEffectRef* CreateStage(SkRandom* random, |
michael@0 | 52 | GrContext* context, |
michael@0 | 53 | const GrDrawTargetCaps& caps, |
michael@0 | 54 | GrTexture* dummyTextures[]) { |
michael@0 | 55 | uint32_t idx = random->nextRangeU(0, GetFactories()->count() - 1); |
michael@0 | 56 | GrEffectTestFactory* factory = (*GetFactories())[idx]; |
michael@0 | 57 | return factory->fCreateProc(random, context, caps, dummyTextures); |
michael@0 | 58 | } |
michael@0 | 59 | |
michael@0 | 60 | private: |
michael@0 | 61 | CreateProc fCreateProc; |
michael@0 | 62 | static SkTArray<GrEffectTestFactory*, true>* GetFactories(); |
michael@0 | 63 | }; |
michael@0 | 64 | |
michael@0 | 65 | /** GrEffect subclasses should insert this macro in their declaration to be included in the |
michael@0 | 66 | * program generation unit test. |
michael@0 | 67 | */ |
michael@0 | 68 | #define GR_DECLARE_EFFECT_TEST \ |
michael@0 | 69 | static GrEffectTestFactory gTestFactory; \ |
michael@0 | 70 | static GrEffectRef* TestCreate(SkRandom*, \ |
michael@0 | 71 | GrContext*, \ |
michael@0 | 72 | const GrDrawTargetCaps&, \ |
michael@0 | 73 | GrTexture* dummyTextures[2]) |
michael@0 | 74 | |
michael@0 | 75 | /** GrEffect subclasses should insert this macro in their implementation file. They must then |
michael@0 | 76 | * also implement this static function: |
michael@0 | 77 | * GrEffect* TestCreate(SkRandom*, |
michael@0 | 78 | * GrContext*, |
michael@0 | 79 | * const GrDrawTargetCaps&, |
michael@0 | 80 | * GrTexture* dummyTextures[2]); |
michael@0 | 81 | * dummyTextures[] are valid textures that can optionally be used to construct GrTextureAccesses. |
michael@0 | 82 | * The first texture has config kSkia8888_GrPixelConfig and the second has |
michael@0 | 83 | * kAlpha_8_GrPixelConfig. TestCreate functions are also free to create additional textures using |
michael@0 | 84 | * the GrContext. |
michael@0 | 85 | */ |
michael@0 | 86 | #define GR_DEFINE_EFFECT_TEST(Effect) \ |
michael@0 | 87 | GrEffectTestFactory Effect :: gTestFactory(Effect :: TestCreate) |
michael@0 | 88 | |
michael@0 | 89 | #else // !SK_ALLOW_STATIC_GLOBAL_INITIALIZERS |
michael@0 | 90 | |
michael@0 | 91 | // The unit test relies on static initializers. Just declare the TestCreate function so that |
michael@0 | 92 | // its definitions will compile. |
michael@0 | 93 | #define GR_DECLARE_EFFECT_TEST \ |
michael@0 | 94 | static GrEffectRef* TestCreate(SkRandom*, \ |
michael@0 | 95 | GrContext*, \ |
michael@0 | 96 | const GrDrawTargetCaps&, \ |
michael@0 | 97 | GrTexture* dummyTextures[2]) |
michael@0 | 98 | #define GR_DEFINE_EFFECT_TEST(X) |
michael@0 | 99 | |
michael@0 | 100 | #endif // !SK_ALLOW_STATIC_GLOBAL_INITIALIZERS |
michael@0 | 101 | #endif |