gfx/skia/trunk/include/core/SkTRegistry.h

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

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.

     2 /*
     3  * Copyright 2009 The Android Open Source Project
     4  *
     5  * Use of this source code is governed by a BSD-style license that can be
     6  * found in the LICENSE file.
     7  */
    10 #ifndef SkTRegistry_DEFINED
    11 #define SkTRegistry_DEFINED
    13 #include "SkTypes.h"
    15 /** Template class that registers itself (in the constructor) into a linked-list
    16     and provides a function-pointer. This can be used to auto-register a set of
    17     services, e.g. a set of image codecs.
    18  */
    19 template <typename T> class SkTRegistry : SkNoncopyable {
    20 public:
    21     typedef T Factory;
    23     explicit SkTRegistry(T fact) : fFact(fact) {
    24 #ifdef SK_BUILD_FOR_ANDROID
    25         // work-around for double-initialization bug
    26         {
    27             SkTRegistry* reg = gHead;
    28             while (reg) {
    29                 if (reg == this) {
    30                     return;
    31                 }
    32                 reg = reg->fChain;
    33             }
    34         }
    35 #endif
    36         fChain = gHead;
    37         gHead  = this;
    38     }
    40     static const SkTRegistry* Head() { return gHead; }
    42     const SkTRegistry* next() const { return fChain; }
    43     const Factory& factory() const { return fFact; }
    45 private:
    46     Factory      fFact;
    47     SkTRegistry* fChain;
    49     static SkTRegistry* gHead;
    50 };
    52 // The caller still needs to declare an instance of this somewhere
    53 template <typename T> SkTRegistry<T>* SkTRegistry<T>::gHead;
    55 #endif

mercurial