| Index: Source/bindings/core/dart/DartJsInteropData.cpp
|
| diff --git a/Source/modules/crypto/WorkerGlobalScopeCrypto.cpp b/Source/bindings/core/dart/DartJsInteropData.cpp
|
| similarity index 54%
|
| copy from Source/modules/crypto/WorkerGlobalScopeCrypto.cpp
|
| copy to Source/bindings/core/dart/DartJsInteropData.cpp
|
| index 015c612582b717b04b569c42dfa171c1124dae59..ddad8454cfe4cbfd15fe5a12e62484bead3e6e8b 100644
|
| --- a/Source/modules/crypto/WorkerGlobalScopeCrypto.cpp
|
| +++ b/Source/bindings/core/dart/DartJsInteropData.cpp
|
| @@ -27,50 +27,50 @@
|
| * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| */
|
| -
|
| #include "config.h"
|
| -#include "modules/crypto/WorkerGlobalScopeCrypto.h"
|
| -
|
| -#include "core/dom/ExecutionContext.h"
|
| -#include "modules/crypto/Crypto.h"
|
|
|
| -namespace blink {
|
| +#include "bindings/core/dart/DartJsInteropData.h"
|
|
|
| -WorkerGlobalScopeCrypto::WorkerGlobalScopeCrypto()
|
| -{
|
| -}
|
| +#include <string.h>
|
|
|
| -const char* WorkerGlobalScopeCrypto::supplementName()
|
| -{
|
| - return "WorkerGlobalScopeCrypto";
|
| -}
|
| +namespace blink {
|
|
|
| -WorkerGlobalScopeCrypto& WorkerGlobalScopeCrypto::from(WillBeHeapSupplementable<WorkerGlobalScope>& context)
|
| +v8::Local<v8::Function> DartJsInteropData::cacheFunction(v8::Persistent<v8::Function>* cache, const char* scriptSrc)
|
| {
|
| - WorkerGlobalScopeCrypto* supplement = static_cast<WorkerGlobalScopeCrypto*>(WillBeHeapSupplement<WorkerGlobalScope>::from(context, supplementName()));
|
| - if (!supplement) {
|
| - supplement = new WorkerGlobalScopeCrypto();
|
| - provideTo(context, supplementName(), adoptPtrWillBeNoop(supplement));
|
| + v8::Isolate* v8Isolate = v8::Isolate::GetCurrent();
|
| + if (cache->IsEmpty()) {
|
| + v8::Local<v8::Function> localFunction = v8::Local<v8::Function>::Cast(v8::Script::Compile(v8::String::NewFromUtf8(v8Isolate, scriptSrc))->Run());
|
| + cache->Reset(v8Isolate, localFunction);
|
| + return localFunction;
|
| }
|
| - return *supplement;
|
| + return v8::Local<v8::Function>::New(v8Isolate, *cache);
|
| }
|
|
|
| -Crypto* WorkerGlobalScopeCrypto::crypto(WillBeHeapSupplementable<WorkerGlobalScope>& context)
|
| +v8::Local<v8::Function> DartJsInteropData::captureThisFunction()
|
| {
|
| - return WorkerGlobalScopeCrypto::from(context).crypto();
|
| + const char* scriptSrc = "(function () {"
|
| + " var func = this;"
|
| + " return function () {"
|
| + " return func(this, Array.prototype.slice.apply(arguments));"
|
| + " };"
|
| + "})";
|
| + return cacheFunction(&m_captureThisFunction, scriptSrc);
|
| }
|
|
|
| -Crypto* WorkerGlobalScopeCrypto::crypto() const
|
| +v8::Local<v8::Function> DartJsInteropData::wrapDartFunction()
|
| {
|
| - if (!m_crypto)
|
| - m_crypto = Crypto::create();
|
| - return m_crypto.get();
|
| + const char* scriptSrc = "(function () {"
|
| + " var func = this;"
|
| + " return function () {"
|
| + " return func(Array.prototype.slice.apply(arguments));"
|
| + " };"
|
| + "})";
|
| + return cacheFunction(&m_wrapDartFunction, scriptSrc);
|
| }
|
|
|
| -DEFINE_TRACE(WorkerGlobalScopeCrypto)
|
| +v8::Local<v8::Function> DartJsInteropData::instanceofFunction()
|
| {
|
| - visitor->trace(m_crypto);
|
| - WillBeHeapSupplement<WorkerGlobalScope>::trace(visitor);
|
| + return cacheFunction(&m_instanceofFunction, "(function (type) { return this instanceof type; })");
|
| }
|
|
|
| -} // namespace blink
|
| +}
|
|
|