Chromium Code Reviews| Index: third_party/WebKit/Source/core/testing/DeathAwareScriptWrappable.h |
| diff --git a/third_party/WebKit/Source/core/testing/DeathAwareScriptWrappable.h b/third_party/WebKit/Source/core/testing/DeathAwareScriptWrappable.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..cf2ed164eb8b99675ebb5f9181f14881811525ee |
| --- /dev/null |
| +++ b/third_party/WebKit/Source/core/testing/DeathAwareScriptWrappable.h |
| @@ -0,0 +1,46 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef DeathAwareScriptWrappable_h |
| +#define DeathAwareScriptWrappable_h |
| + |
| +#include "bindings/core/v8/ScriptWrappable.h" |
| +#include "platform/heap/Heap.h" |
| +#include "wtf/text/WTFString.h" |
| +#include <signal.h> |
| + |
| +namespace blink { |
| + |
| +class DeathAwareScriptWrappable : public GarbageCollectedFinalized<DeathAwareScriptWrappable>, public ScriptWrappable { |
| + DEFINE_WRAPPERTYPEINFO(); |
| + static DeathAwareScriptWrappable* s_instance; |
| + static bool s_hasDied; |
| + |
| +public: |
| + virtual ~DeathAwareScriptWrappable() |
| + { |
| + if (this == s_instance) { |
| + s_hasDied = true; |
| + } |
| + } |
| + |
| + static DeathAwareScriptWrappable* create() |
| + { |
| + return new DeathAwareScriptWrappable(); |
| + } |
| + |
| + static bool hasDied() { return s_hasDied; } |
| + static void observeDeathsOf(DeathAwareScriptWrappable* instance) |
| + { |
|
haraken
2016/09/02 10:53:15
Shall we add DCHECK(!s_instance) (i.e., we're not
Marcel Hlopko
2016/09/02 12:12:40
Cannot, it's a static variable, and is reused betw
|
| + s_hasDied = false; |
| + s_instance = instance; |
| + } |
| + |
| + DEFINE_INLINE_VIRTUAL_TRACE() {} |
| + DEFINE_INLINE_VIRTUAL_TRACE_WRAPPERS() {} |
| +}; |
| + |
| +} // namespace blink |
| + |
| +#endif // DeathAwareScriptWrappable_h |