Revert "Make leak counters thread-safe and turn them on by default for Debug"

iThis CL is breaking the Android debug test bots by firing an assert.

BUG=skia:1219

Review URL: https://codereview.chromium.org/138683006

git-svn-id: http://skia.googlecode.com/svn/trunk@13076 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/gm/colormatrix.cpp b/gm/colormatrix.cpp
index 2f98693..9ab6563 100644
--- a/gm/colormatrix.cpp
+++ b/gm/colormatrix.cpp
@@ -12,9 +12,9 @@
 #define WIDTH 500
 #define HEIGHT 500
 
-class SkDoOnce {
+class SkOnce {
 public:
-    SkDoOnce() : fOnce(false) {};
+    SkOnce() : fOnce(false) {};
 
     bool once() const {
         if (fOnce) {
@@ -39,7 +39,7 @@
 namespace skiagm {
 
 class ColorMatrixGM : public GM {
-    SkDoOnce fOnce;
+    SkOnce fOnce;
     void init() {
         if (fOnce.once()) {
             fSolidBitmap = this->createSolidBitmap(64, 64);
diff --git a/gm/convexpaths.cpp b/gm/convexpaths.cpp
index 91afbfe..8eb4cba 100644
--- a/gm/convexpaths.cpp
+++ b/gm/convexpaths.cpp
@@ -9,9 +9,9 @@
 #include "SkRandom.h"
 #include "SkTArray.h"
 
-class SkDoOnce : SkNoncopyable {
+class SkOnce : SkNoncopyable {
 public:
-    SkDoOnce() { fDidOnce = false; }
+    SkOnce() { fDidOnce = false; }
 
     bool needToDo() const { return !fDidOnce; }
     bool alreadyDone() const { return fDidOnce; }
@@ -27,7 +27,7 @@
 namespace skiagm {
 
 class ConvexPathsGM : public GM {
-    SkDoOnce fOnce;
+    SkOnce fOnce;
 public:
     ConvexPathsGM() {
         this->setBGColor(0xFF000000);
diff --git a/gyp/core.gypi b/gyp/core.gypi
index 55447fe..56ea42a 100644
--- a/gyp/core.gypi
+++ b/gyp/core.gypi
@@ -114,6 +114,7 @@
         '<(skia_src_path)/core/SkMessageBus.h',
         '<(skia_src_path)/core/SkMetaData.cpp',
         '<(skia_src_path)/core/SkMipMap.cpp',
+        '<(skia_src_path)/core/SkOnce.h',
         '<(skia_src_path)/core/SkOrderedReadBuffer.cpp',
         '<(skia_src_path)/core/SkOrderedWriteBuffer.cpp',
         '<(skia_src_path)/core/SkPackBits.cpp',
@@ -255,7 +256,6 @@
         '<(skia_include_path)/core/SkMath.h',
         '<(skia_include_path)/core/SkMatrix.h',
         '<(skia_include_path)/core/SkMetaData.h',
-        '<(skia_include_path)/core/SkOnce.h',
         '<(skia_include_path)/core/SkOSFile.h',
         '<(skia_include_path)/core/SkPackBits.h',
         '<(skia_include_path)/core/SkPaint.h',
diff --git a/include/core/SkInstCnt.h b/include/core/SkInstCnt.h
index 1c1770a..89bbfa1 100644
--- a/include/core/SkInstCnt.h
+++ b/include/core/SkInstCnt.h
@@ -20,7 +20,6 @@
 #include "SkTypes.h"
 
 #if SK_ENABLE_INST_COUNT
-#include "SkOnce.h"
 #include "SkTArray.h"
 #include "SkThread.h"
 
@@ -39,16 +38,17 @@
 #define SK_DECLARE_INST_COUNT_INTERNAL(className, initStep)                 \
     class SkInstanceCountHelper {                                           \
     public:                                                                 \
+        typedef int (*PFCheckInstCnt)(int level, bool cleanUp);             \
         SkInstanceCountHelper() {                                           \
-            SK_DECLARE_STATIC_ONCE(once);                                   \
-            SkOnce(&once, init, 0);                                         \
+            static bool gInited;                                            \
+            if (!gInited) {                                                 \
+                initStep                                                    \
+                GetChildren() = new SkTArray<PFCheckInstCnt>;               \
+                gInited = true;                                             \
+            }                                                               \
             sk_atomic_inc(GetInstanceCountPtr());                           \
         }                                                                   \
                                                                             \
-        static void init(int) {                                             \
-            initStep                                                        \
-        }                                                                   \
-                                                                            \
         SkInstanceCountHelper(const SkInstanceCountHelper&) {               \
             sk_atomic_inc(GetInstanceCountPtr());                           \
         }                                                                   \
@@ -62,16 +62,11 @@
             return &gInstanceCount;                                         \
         }                                                                   \
                                                                             \
-        static SkTArray<int (*)(int, bool)>*& GetChildren() {               \
-            static SkTArray<int (*)(int, bool)>* gChildren;                 \
+        static SkTArray<PFCheckInstCnt>*& GetChildren() {                   \
+            static SkTArray<PFCheckInstCnt>* gChildren;                     \
             return gChildren;                                               \
         }                                                                   \
                                                                             \
-        static SkBaseMutex& GetChildrenMutex() {                            \
-            SK_DECLARE_STATIC_MUTEX(childrenMutex);                         \
-            return childrenMutex;                                           \
-        }                                                                   \
-                                                                            \
     } fInstanceCountHelper;                                                 \
                                                                             \
     static int32_t GetInstanceCount() {                                     \
@@ -91,7 +86,7 @@
         if (NULL == SkInstanceCountHelper::GetChildren()) {                 \
             return GetInstanceCount();                                      \
         }                                                                   \
-        SkTArray<int (*)(int, bool)>* children = \
+        SkTArray<int (*)(int, bool)>* children =                            \
             SkInstanceCountHelper::GetChildren();                           \
         int childCount = children->count();                                 \
         int count = GetInstanceCount();                                     \
@@ -110,12 +105,8 @@
     }                                                                       \
                                                                             \
     static void AddInstChild(int (*childCheckInstCnt)(int, bool)) {         \
-        if (CheckInstanceCount != childCheckInstCnt) {                      \
-            SkAutoMutexAcquire ama(SkInstanceCountHelper::GetChildrenMutex()); \
-            if (NULL == SkInstanceCountHelper::GetChildren()) {             \
-                SkInstanceCountHelper::GetChildren() =                      \
-                    new SkTArray<int (*)(int, bool)>;                       \
-            }                                                               \
+        if (CheckInstanceCount != childCheckInstCnt &&                      \
+            NULL != SkInstanceCountHelper::GetChildren()) {                 \
             SkInstanceCountHelper::GetChildren()->push_back(childCheckInstCnt); \
         }                                                                   \
     }
diff --git a/include/core/SkPostConfig.h b/include/core/SkPostConfig.h
index f08e6e1..2156519 100644
--- a/include/core/SkPostConfig.h
+++ b/include/core/SkPostConfig.h
@@ -120,10 +120,12 @@
  * SK_ENABLE_INST_COUNT controlls printing how many reference counted objects
  * are still held on exit.
  * Defaults to 1 in DEBUG and 0 in RELEASE.
+ * FIXME: currently always 0, since it fails if multiple threads run at once
+ * (see skbug.com/1219 ).
  */
 #ifndef SK_ENABLE_INST_COUNT
 #  ifdef SK_DEBUG
-#    define SK_ENABLE_INST_COUNT 1
+#    define SK_ENABLE_INST_COUNT 0
 #  else
 #    define SK_ENABLE_INST_COUNT 0
 #  endif
diff --git a/include/core/SkOnce.h b/src/core/SkOnce.h
similarity index 100%
rename from include/core/SkOnce.h
rename to src/core/SkOnce.h