Index: third_party/WebKit/Source/bindings/core/v8/ActiveScriptWrappable.cpp |
diff --git a/third_party/WebKit/Source/bindings/core/v8/ActiveScriptWrappable.cpp b/third_party/WebKit/Source/bindings/core/v8/ActiveScriptWrappable.cpp |
new file mode 100644 |
index 0000000000000000000000000000000000000000..437bf83932da2186d80e05737591d455cae89909 |
--- /dev/null |
+++ b/third_party/WebKit/Source/bindings/core/v8/ActiveScriptWrappable.cpp |
@@ -0,0 +1,41 @@ |
+// 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. |
+ |
+#include "bindings/core/v8/ActiveScriptWrappable.h" |
+ |
+#include "wtf/HashSet.h" |
+#include "wtf/ThreadSpecific.h" |
+#include "wtf/Threading.h" |
+ |
+namespace blink { |
+ |
+namespace { |
+ |
+using ActiveScriptWrappableSetType = HashSet<const ActiveScriptWrappable*>; |
+ |
+ActiveScriptWrappableSetType& activeScriptWrappables() |
+{ |
+ DEFINE_THREAD_SAFE_STATIC_LOCAL(ThreadSpecific<ActiveScriptWrappableSetType>, activeScriptWrappableSet, new ThreadSpecific<ActiveScriptWrappableSetType>()); |
+ return *activeScriptWrappableSet; |
+} |
+ |
+} // namespace |
+ |
+ActiveScriptWrappable::ActiveScriptWrappable(ScriptWrappable* self) |
+ : m_scriptWrappable(self) |
+{ |
+ activeScriptWrappables().add(this); |
+} |
+ |
+ActiveScriptWrappable::~ActiveScriptWrappable() |
sof
2016/05/10 05:22:26
haraken@: is it guaranteed that this global set of
|
+{ |
+ activeScriptWrappables().remove(this); |
+} |
+ |
+ScriptWrappable* ActiveScriptWrappable::toScriptWrappable() const |
+{ |
+ return m_scriptWrappable; |
+} |
+ |
+} // namespace blink |