Chromium Code Reviews| 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..9a9a7c72db7fb1c3f47fe31c8e7e6f1ee812bf9c |
| --- /dev/null |
| +++ b/third_party/WebKit/Source/bindings/core/v8/ActiveScriptWrappable.cpp |
| @@ -0,0 +1,40 @@ |
| +// 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/HashMap.h" |
| +#include "wtf/ThreadSpecific.h" |
| +#include "wtf/Threading.h" |
| + |
| +namespace blink { |
| + |
| +namespace { |
| + |
| +using FinalizerHashMap = HashMap<const ActiveScriptWrappable*, ScriptWrappable*>; |
| + |
| +FinalizerHashMap& finalizerList() |
| +{ |
| + DEFINE_THREAD_SAFE_STATIC_LOCAL(ThreadSpecific<FinalizerHashMap>, finalizerMap, new ThreadSpecific<FinalizerHashMap>()); |
|
haraken
2016/03/18 08:07:28
I'm just curious but why do you call this a "final
jochen (gone - plz use gerrit)
2016/03/18 13:18:01
rename to activeScriptWrappables
|
| + return *finalizerMap; |
| +} |
| + |
| +} // namespace |
| + |
| +ActiveScriptWrappable::ActiveScriptWrappable(ScriptWrappable* wrappable) |
| +{ |
| + finalizerList().add(this, wrappable); |
| +} |
| + |
| +ActiveScriptWrappable::~ActiveScriptWrappable() |
| +{ |
| + finalizerList().remove(this); |
| +} |
| + |
| +ScriptWrappable* ActiveScriptWrappable::toScriptWrappable() const |
|
haraken
2016/03/18 08:07:28
For performance reasons, would it be better to mak
jochen (gone - plz use gerrit)
2016/03/18 13:18:01
done
|
| +{ |
| + return finalizerList().get(this); |
| +} |
| + |
| +} // namespace blink |