OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef ActiveScriptWrappable_h | 5 // This file has been moved to platform/bindings/ActiveScriptWrappable.h. |
6 #define ActiveScriptWrappable_h | 6 // TODO(adithyas): Remove this file. |
7 | 7 #include "platform/bindings/ActiveScriptWrappable.h" |
8 #include "core/CoreExport.h" | |
9 #include "platform/heap/Handle.h" | |
10 #include "platform/wtf/Noncopyable.h" | |
11 | |
12 namespace v8 { | |
13 class Isolate; | |
14 } | |
15 | |
16 namespace blink { | |
17 | |
18 class ScriptWrappable; | |
19 class ScriptWrappableVisitor; | |
20 | |
21 /** | |
22 * Classes deriving from ActiveScriptWrappable will be registered in a | |
23 * thread-specific list. They keep their wrappers and dependant objects alive | |
24 * as long as they have pending activity. | |
25 */ | |
26 class CORE_EXPORT ActiveScriptWrappableBase : public GarbageCollectedMixin { | |
27 WTF_MAKE_NONCOPYABLE(ActiveScriptWrappableBase); | |
28 | |
29 public: | |
30 ActiveScriptWrappableBase(); | |
31 | |
32 static void TraceActiveScriptWrappables(v8::Isolate*, | |
33 ScriptWrappableVisitor*); | |
34 | |
35 protected: | |
36 virtual bool IsContextDestroyed(ActiveScriptWrappableBase*) const = 0; | |
37 virtual bool DispatchHasPendingActivity(ActiveScriptWrappableBase*) const = 0; | |
38 virtual ScriptWrappable* ToScriptWrappable( | |
39 ActiveScriptWrappableBase*) const = 0; | |
40 }; | |
41 | |
42 template <typename T> | |
43 class ActiveScriptWrappable : public ActiveScriptWrappableBase { | |
44 WTF_MAKE_NONCOPYABLE(ActiveScriptWrappable); | |
45 | |
46 public: | |
47 ActiveScriptWrappable() {} | |
48 | |
49 protected: | |
50 bool IsContextDestroyed(ActiveScriptWrappableBase* object) const final { | |
51 return !(static_cast<T*>(object)->T::GetExecutionContext)() || | |
52 (static_cast<T*>(object)->T::GetExecutionContext)() | |
53 ->IsContextDestroyed(); | |
54 } | |
55 | |
56 bool DispatchHasPendingActivity( | |
57 ActiveScriptWrappableBase* object) const final { | |
58 return static_cast<T*>(object)->T::HasPendingActivity(); | |
59 } | |
60 | |
61 ScriptWrappable* ToScriptWrappable( | |
62 ActiveScriptWrappableBase* object) const final { | |
63 return static_cast<T*>(object); | |
64 } | |
65 }; | |
66 | |
67 } // namespace blink | |
68 | |
69 #endif // ActiveScriptWrappable_h | |
OLD | NEW |