Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef DeathAwareScriptWrappable_h | |
| 6 #define DeathAwareScriptWrappable_h | |
| 7 | |
| 8 #include "bindings/core/v8/ScriptWrappable.h" | |
| 9 #include "platform/heap/Heap.h" | |
| 10 #include "wtf/text/WTFString.h" | |
| 11 #include <signal.h> | |
| 12 | |
| 13 namespace blink { | |
| 14 | |
| 15 class DeathAwareScriptWrappable : public GarbageCollectedFinalized<DeathAwareScr iptWrappable>, public ScriptWrappable { | |
| 16 DEFINE_WRAPPERTYPEINFO(); | |
| 17 static DeathAwareScriptWrappable* s_instance; | |
| 18 static bool s_hasDied; | |
| 19 | |
| 20 public: | |
| 21 virtual ~DeathAwareScriptWrappable() | |
| 22 { | |
| 23 if (this == s_instance) { | |
| 24 s_hasDied = true; | |
| 25 } | |
| 26 } | |
| 27 | |
| 28 static DeathAwareScriptWrappable* create() | |
| 29 { | |
| 30 return new DeathAwareScriptWrappable(); | |
| 31 } | |
| 32 | |
| 33 static bool hasDied() { return s_hasDied; } | |
| 34 static void observeDeathsOf(DeathAwareScriptWrappable* instance) | |
| 35 { | |
|
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
| |
| 36 s_hasDied = false; | |
| 37 s_instance = instance; | |
| 38 } | |
| 39 | |
| 40 DEFINE_INLINE_VIRTUAL_TRACE() {} | |
| 41 DEFINE_INLINE_VIRTUAL_TRACE_WRAPPERS() {} | |
| 42 }; | |
| 43 | |
| 44 } // namespace blink | |
| 45 | |
| 46 #endif // DeathAwareScriptWrappable_h | |
| OLD | NEW |