Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(646)

Unified Diff: third_party/WebKit/Source/core/testing/DeathAwareScriptWrappable.h

Issue 2301213003: Add tests for trace wrappers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase master Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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)
+ {
+ s_hasDied = false;
+ s_instance = instance;
+ }
+
+ DEFINE_INLINE_VIRTUAL_TRACE() {}
+ DEFINE_INLINE_VIRTUAL_TRACE_WRAPPERS() {}
+};
+
+} // namespace blink
+
+#endif // DeathAwareScriptWrappable_h

Powered by Google App Engine
This is Rietveld 408576698