diff options
author | Brian Salomon <bsalomon@google.com> | 2017-05-12 12:02:50 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-05-12 16:49:07 +0000 |
commit | 175f588831c3d9f76349af8c27c64ceaa4460871 (patch) | |
tree | fd7733ec3dcc8caae5b4aa732ea1e665b643d909 /include/utils | |
parent | ebb1b5c297e394ab19f99d807095672b7f5d8aef (diff) |
Modify SkEventTracer::SetInstance to fail rather than assert if a tracer has already been installed.
Chromium usually calls SetInstance once per process. However, when run in single process more renderer threads will try to set the instance after the browser process already has done so. This allows them to fail gracefully without asserting.
Bug: skia:6603
Change-Id: Ic8a35422d787335aa67eefc07d0658f0fbe73db4
Reviewed-on: https://skia-review.googlesource.com/16664
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Mike Klein <mtklein@chromium.org>
Diffstat (limited to 'include/utils')
-rw-r--r-- | include/utils/SkEventTracer.h | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/include/utils/SkEventTracer.h b/include/utils/SkEventTracer.h index f4f8676a74..a0289ce9eb 100644 --- a/include/utils/SkEventTracer.h +++ b/include/utils/SkEventTracer.h @@ -27,9 +27,18 @@ public: typedef uint64_t Handle; - static SkEventTracer* GetInstance(); + /** + * If this is the first call to SetInstance or GetInstance then the passed instance is + * installed and true is returned. Otherwise, false is returned. In either case ownership of the + * tracer is transferred and it will be deleted when no longer needed. + */ + static bool SetInstance(SkEventTracer*); - static void SetInstance(SkEventTracer*); + /** + * Gets the event tracer. If this is the first call to SetInstance or GetIntance then a default + * event tracer is installed and returned. + */ + static SkEventTracer* GetInstance(); virtual ~SkEventTracer() { } |