| Index: Source/bindings/core/v8/inspector/V8InjectedScriptHost.cpp
|
| diff --git a/Source/bindings/core/v8/custom/V8InjectedScriptHostCustom.cpp b/Source/bindings/core/v8/inspector/V8InjectedScriptHost.cpp
|
| similarity index 73%
|
| rename from Source/bindings/core/v8/custom/V8InjectedScriptHostCustom.cpp
|
| rename to Source/bindings/core/v8/inspector/V8InjectedScriptHost.cpp
|
| index 711660a221e95b51290102b292feee5fc94e3a2f..5d585333fe492aa596dbe20e8fb636a05881b19e 100644
|
| --- a/Source/bindings/core/v8/custom/V8InjectedScriptHostCustom.cpp
|
| +++ b/Source/bindings/core/v8/inspector/V8InjectedScriptHost.cpp
|
| @@ -1,35 +1,9 @@
|
| -/*
|
| - * Copyright (C) 2007-2011 Google Inc. All rights reserved.
|
| - *
|
| - * Redistribution and use in source and binary forms, with or without
|
| - * modification, are permitted provided that the following conditions are
|
| - * met:
|
| - *
|
| - * * Redistributions of source code must retain the above copyright
|
| - * notice, this list of conditions and the following disclaimer.
|
| - * * Redistributions in binary form must reproduce the above
|
| - * copyright notice, this list of conditions and the following disclaimer
|
| - * in the documentation and/or other materials provided with the
|
| - * distribution.
|
| - * * Neither the name of Google Inc. nor the names of its
|
| - * contributors may be used to endorse or promote products derived from
|
| - * this software without specific prior written permission.
|
| - *
|
| - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
| - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
| - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
| - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
| - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
| - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
| - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
| - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
| - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
| - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| - */
|
| +// Copyright 2015 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 "config.h"
|
| -#include "bindings/core/v8/V8InjectedScriptHost.h"
|
| +#include "bindings/core/v8/inspector/V8InjectedScriptHost.h"
|
|
|
| #include "bindings/core/v8/BindingSecurity.h"
|
| #include "bindings/core/v8/ExceptionState.h"
|
| @@ -41,7 +15,6 @@
|
| #include "bindings/core/v8/V8Debugger.h"
|
| #include "bindings/core/v8/V8Event.h"
|
| #include "bindings/core/v8/V8EventTarget.h"
|
| -#include "bindings/core/v8/V8EventTarget.h"
|
| #include "bindings/core/v8/V8HTMLAllCollection.h"
|
| #include "bindings/core/v8/V8HTMLCollection.h"
|
| #include "bindings/core/v8/V8Node.h"
|
| @@ -53,6 +26,7 @@
|
| #include "core/inspector/InjectedScriptHost.h"
|
| #include "core/inspector/JavaScriptCallFrame.h"
|
| #include "platform/JSONValues.h"
|
| +#include "wtf/RefPtr.h"
|
|
|
| namespace blink {
|
|
|
| @@ -93,7 +67,13 @@ EventTarget* InjectedScriptHost::scriptValueAsEventTarget(ScriptState* scriptSta
|
| return eventTargetFromScriptValue(scriptState->isolate(), value.v8Value());
|
| }
|
|
|
| -void V8InjectedScriptHost::inspectedObjectMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
|
| +void V8InjectedScriptHost::clearConsoleMessagesCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
|
| +{
|
| + InjectedScriptHost* impl = V8InjectedScriptHost::toImpl(info.Holder());
|
| + impl->clearConsoleMessages();
|
| +}
|
| +
|
| +void V8InjectedScriptHost::inspectedObjectCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
|
| {
|
| if (info.Length() < 1)
|
| return;
|
| @@ -125,7 +105,7 @@ static v8::Local<v8::String> functionDisplayName(v8::Local<v8::Function> functio
|
| return v8::Local<v8::String>();
|
| }
|
|
|
| -void V8InjectedScriptHost::internalConstructorNameMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
|
| +void V8InjectedScriptHost::internalConstructorNameCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
|
| {
|
| if (info.Length() < 1 || !info[0]->IsObject())
|
| return;
|
| @@ -151,7 +131,7 @@ void V8InjectedScriptHost::internalConstructorNameMethodCustom(const v8::Functio
|
| v8SetReturnValue(info, result);
|
| }
|
|
|
| -void V8InjectedScriptHost::isDOMWrapperMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
|
| +void V8InjectedScriptHost::isDOMWrapperCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
|
| {
|
| if (info.Length() < 1)
|
| return;
|
| @@ -159,7 +139,7 @@ void V8InjectedScriptHost::isDOMWrapperMethodCustom(const v8::FunctionCallbackIn
|
| v8SetReturnValue(info, V8DOMWrapper::isWrapper(info.GetIsolate(), info[0]));
|
| }
|
|
|
| -void V8InjectedScriptHost::isHTMLAllCollectionMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
|
| +void V8InjectedScriptHost::isHTMLAllCollectionCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
|
| {
|
| if (info.Length() < 1)
|
| return;
|
| @@ -172,14 +152,14 @@ void V8InjectedScriptHost::isHTMLAllCollectionMethodCustom(const v8::FunctionCal
|
| v8SetReturnValue(info, V8HTMLAllCollection::hasInstance(info[0], info.GetIsolate()));
|
| }
|
|
|
| -void V8InjectedScriptHost::isTypedArrayMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
|
| +void V8InjectedScriptHost::isTypedArrayCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
|
| {
|
| if (info.Length() < 1)
|
| return;
|
| v8SetReturnValue(info, info[0]->IsTypedArray());
|
| }
|
|
|
| -void V8InjectedScriptHost::subtypeMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
|
| +void V8InjectedScriptHost::subtypeCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
|
| {
|
| if (info.Length() < 1)
|
| return;
|
| @@ -231,7 +211,7 @@ void V8InjectedScriptHost::subtypeMethodCustom(const v8::FunctionCallbackInfo<v8
|
| }
|
| }
|
|
|
| -void V8InjectedScriptHost::functionDetailsMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
|
| +void V8InjectedScriptHost::functionDetailsCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
|
| {
|
| if (info.Length() < 1 || !info[0]->IsFunction())
|
| return;
|
| @@ -263,7 +243,7 @@ void V8InjectedScriptHost::functionDetailsMethodCustom(const v8::FunctionCallbac
|
| v8SetReturnValue(info, result);
|
| }
|
|
|
| -void V8InjectedScriptHost::generatorObjectDetailsMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
|
| +void V8InjectedScriptHost::generatorObjectDetailsCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
|
| {
|
| if (info.Length() < 1 || !info[0]->IsObject())
|
| return;
|
| @@ -275,7 +255,7 @@ void V8InjectedScriptHost::generatorObjectDetailsMethodCustom(const v8::Function
|
| v8SetReturnValue(info, debugger.generatorObjectDetails(object));
|
| }
|
|
|
| -void V8InjectedScriptHost::collectionEntriesMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
|
| +void V8InjectedScriptHost::collectionEntriesCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
|
| {
|
| if (info.Length() < 1 || !info[0]->IsObject())
|
| return;
|
| @@ -287,7 +267,7 @@ void V8InjectedScriptHost::collectionEntriesMethodCustom(const v8::FunctionCallb
|
| v8SetReturnValue(info, debugger.collectionEntries(object));
|
| }
|
|
|
| -void V8InjectedScriptHost::getInternalPropertiesMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
|
| +void V8InjectedScriptHost::getInternalPropertiesCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
|
| {
|
| if (info.Length() < 1 || !info[0]->IsObject())
|
| return;
|
| @@ -329,7 +309,7 @@ static v8::Local<v8::Array> getJSListenerFunctions(v8::Isolate* isolate, Executi
|
| return result;
|
| }
|
|
|
| -void V8InjectedScriptHost::getEventListenersMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
|
| +void V8InjectedScriptHost::getEventListenersCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
|
| {
|
| if (info.Length() < 1)
|
| return;
|
| @@ -353,7 +333,7 @@ void V8InjectedScriptHost::getEventListenersMethodCustom(const v8::FunctionCallb
|
| v8SetReturnValue(info, result);
|
| }
|
|
|
| -void V8InjectedScriptHost::inspectMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
|
| +void V8InjectedScriptHost::inspectCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
|
| {
|
| if (info.Length() < 2)
|
| return;
|
| @@ -365,7 +345,7 @@ void V8InjectedScriptHost::inspectMethodCustom(const v8::FunctionCallbackInfo<v8
|
| host->inspectImpl(toJSONValue(object), toJSONValue(hints));
|
| }
|
|
|
| -void V8InjectedScriptHost::evalMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
|
| +void V8InjectedScriptHost::evalCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
|
| {
|
| v8::Isolate* isolate = info.GetIsolate();
|
| if (info.Length() < 1) {
|
| @@ -397,7 +377,7 @@ static void setExceptionAsReturnValue(const v8::FunctionCallbackInfo<v8::Value>&
|
| v8SetReturnValue(info, returnValue);
|
| }
|
|
|
| -void V8InjectedScriptHost::evaluateWithExceptionDetailsMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
|
| +void V8InjectedScriptHost::evaluateWithExceptionDetailsCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
|
| {
|
| v8::Isolate* isolate = info.GetIsolate();
|
| if (info.Length() < 1) {
|
| @@ -432,7 +412,7 @@ void V8InjectedScriptHost::evaluateWithExceptionDetailsMethodCustom(const v8::Fu
|
| v8SetReturnValue(info, wrappedResult);
|
| }
|
|
|
| -void V8InjectedScriptHost::setFunctionVariableValueMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
|
| +void V8InjectedScriptHost::setFunctionVariableValueCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
|
| {
|
| if (info.Length() < 4 || !info[0]->IsFunction() || !info[1]->IsInt32() || !info[2]->IsString())
|
| return;
|
| @@ -460,7 +440,7 @@ static bool getFunctionLocation(const v8::FunctionCallbackInfo<v8::Value>& info,
|
| return true;
|
| }
|
|
|
| -void V8InjectedScriptHost::debugFunctionMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
|
| +void V8InjectedScriptHost::debugFunctionCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
|
| {
|
| String scriptId;
|
| int lineNumber;
|
| @@ -472,7 +452,7 @@ void V8InjectedScriptHost::debugFunctionMethodCustom(const v8::FunctionCallbackI
|
| host->debugFunction(scriptId, lineNumber, columnNumber);
|
| }
|
|
|
| -void V8InjectedScriptHost::undebugFunctionMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
|
| +void V8InjectedScriptHost::undebugFunctionCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
|
| {
|
| String scriptId;
|
| int lineNumber;
|
| @@ -484,7 +464,7 @@ void V8InjectedScriptHost::undebugFunctionMethodCustom(const v8::FunctionCallbac
|
| host->undebugFunction(scriptId, lineNumber, columnNumber);
|
| }
|
|
|
| -void V8InjectedScriptHost::monitorFunctionMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
|
| +void V8InjectedScriptHost::monitorFunctionCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
|
| {
|
| String scriptId;
|
| int lineNumber;
|
| @@ -504,7 +484,7 @@ void V8InjectedScriptHost::monitorFunctionMethodCustom(const v8::FunctionCallbac
|
| host->monitorFunction(scriptId, lineNumber, columnNumber, toCoreStringWithUndefinedOrNullCheck(name));
|
| }
|
|
|
| -void V8InjectedScriptHost::unmonitorFunctionMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
|
| +void V8InjectedScriptHost::unmonitorFunctionCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
|
| {
|
| String scriptId;
|
| int lineNumber;
|
| @@ -516,7 +496,7 @@ void V8InjectedScriptHost::unmonitorFunctionMethodCustom(const v8::FunctionCallb
|
| host->unmonitorFunction(scriptId, lineNumber, columnNumber);
|
| }
|
|
|
| -void V8InjectedScriptHost::callFunctionMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
|
| +void V8InjectedScriptHost::callFunctionCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
|
| {
|
| if (info.Length() < 2 || info.Length() > 3 || !info[0]->IsFunction()) {
|
| ASSERT_NOT_REACHED();
|
| @@ -549,17 +529,17 @@ void V8InjectedScriptHost::callFunctionMethodCustom(const v8::FunctionCallbackIn
|
| v8SetReturnValue(info, result);
|
| }
|
|
|
| -void V8InjectedScriptHost::suppressWarningsAndCallFunctionMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
|
| +void V8InjectedScriptHost::suppressWarningsAndCallFunctionCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
|
| {
|
| InjectedScriptHost* host = V8InjectedScriptHost::toImpl(info.Holder());
|
| host->client()->muteWarningsAndDeprecations();
|
|
|
| - callFunctionMethodCustom(info);
|
| + callFunctionCallback(info);
|
|
|
| host->client()->unmuteWarningsAndDeprecations();
|
| }
|
|
|
| -void V8InjectedScriptHost::setNonEnumPropertyMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
|
| +void V8InjectedScriptHost::setNonEnumPropertyCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
|
| {
|
| if (info.Length() < 3 || !info[0]->IsObject() || !info[1]->IsString())
|
| return;
|
| @@ -568,7 +548,7 @@ void V8InjectedScriptHost::setNonEnumPropertyMethodCustom(const v8::FunctionCall
|
| object->ForceSet(info.GetIsolate()->GetCurrentContext(), info[1], info[2], v8::DontEnum);
|
| }
|
|
|
| -void V8InjectedScriptHost::bindMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
|
| +void V8InjectedScriptHost::bindCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
|
| {
|
| if (info.Length() < 2 || !info[1]->IsString())
|
| return;
|
| @@ -582,7 +562,7 @@ void V8InjectedScriptHost::bindMethodCustom(const v8::FunctionCallbackInfo<v8::V
|
| info.GetReturnValue().Set(id);
|
| }
|
|
|
| -void V8InjectedScriptHost::objectForIdMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
|
| +void V8InjectedScriptHost::objectForIdCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
|
| {
|
| if (info.Length() < 1 || !info[0]->IsInt32())
|
| return;
|
| @@ -595,7 +575,7 @@ void V8InjectedScriptHost::objectForIdMethodCustom(const v8::FunctionCallbackInf
|
| info.GetReturnValue().Set(value);
|
| }
|
|
|
| -void V8InjectedScriptHost::idToObjectGroupNameMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
|
| +void V8InjectedScriptHost::idToObjectGroupNameCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
|
| {
|
| if (info.Length() < 1 || !info[0]->IsInt32())
|
| return;
|
| @@ -608,4 +588,115 @@ void V8InjectedScriptHost::idToObjectGroupNameMethodCustom(const v8::FunctionCal
|
| info.GetReturnValue().Set(v8String(info.GetIsolate(), groupName));
|
| }
|
|
|
| +namespace {
|
| +
|
| +struct V8MethodConfiguration {
|
| + const char* name;
|
| + v8::FunctionCallback callback;
|
| +};
|
| +
|
| +const V8MethodConfiguration V8InjectedScriptHostMethods[] = {
|
| + {"clearConsoleMessages", V8InjectedScriptHost::clearConsoleMessagesCallback},
|
| + {"inspect", V8InjectedScriptHost::inspectCallback},
|
| + {"inspectedObject", V8InjectedScriptHost::inspectedObjectCallback},
|
| + {"internalConstructorName", V8InjectedScriptHost::internalConstructorNameCallback},
|
| + {"isDOMWrapper", V8InjectedScriptHost::isDOMWrapperCallback},
|
| + {"isHTMLAllCollection", V8InjectedScriptHost::isHTMLAllCollectionCallback},
|
| + {"isTypedArray", V8InjectedScriptHost::isTypedArrayCallback},
|
| + {"subtype", V8InjectedScriptHost::subtypeCallback},
|
| + {"functionDetails", V8InjectedScriptHost::functionDetailsCallback},
|
| + {"generatorObjectDetails", V8InjectedScriptHost::generatorObjectDetailsCallback},
|
| + {"collectionEntries", V8InjectedScriptHost::collectionEntriesCallback},
|
| + {"getInternalProperties", V8InjectedScriptHost::getInternalPropertiesCallback},
|
| + {"getEventListeners", V8InjectedScriptHost::getEventListenersCallback},
|
| + {"eval", V8InjectedScriptHost::evalCallback},
|
| + {"evaluateWithExceptionDetails", V8InjectedScriptHost::evaluateWithExceptionDetailsCallback},
|
| + {"debugFunction", V8InjectedScriptHost::debugFunctionCallback},
|
| + {"undebugFunction", V8InjectedScriptHost::undebugFunctionCallback},
|
| + {"monitorFunction", V8InjectedScriptHost::monitorFunctionCallback},
|
| + {"unmonitorFunction", V8InjectedScriptHost::unmonitorFunctionCallback},
|
| + {"callFunction", V8InjectedScriptHost::callFunctionCallback},
|
| + {"suppressWarningsAndCallFunction", V8InjectedScriptHost::suppressWarningsAndCallFunctionCallback},
|
| + {"setNonEnumProperty", V8InjectedScriptHost::setNonEnumPropertyCallback},
|
| + {"setFunctionVariableValue", V8InjectedScriptHost::setFunctionVariableValueCallback},
|
| + {"bind", V8InjectedScriptHost::bindCallback},
|
| + {"objectForId", V8InjectedScriptHost::objectForIdCallback},
|
| + {"idToObjectGroupName", V8InjectedScriptHost::idToObjectGroupNameCallback},
|
| +};
|
| +
|
| +class WeakCallbackData final {
|
| +public:
|
| + WeakCallbackData(v8::Isolate* isolate, PassRefPtr<InjectedScriptHost> host, v8::Local<v8::Object> wrapper)
|
| + : m_host(host)
|
| + , m_persistent(isolate, wrapper)
|
| + {
|
| + m_persistent.SetWeak(this, &WeakCallbackData::weakCallback, v8::WeakCallbackType::kParameter);
|
| + }
|
| +
|
| + RefPtr<InjectedScriptHost> m_host;
|
| +
|
| +private:
|
| + static void weakCallback(const v8::WeakCallbackInfo<WeakCallbackData>& info)
|
| + {
|
| + delete info.GetParameter();
|
| + }
|
| +
|
| + v8::Global<v8::Object> m_persistent;
|
| +};
|
| +
|
| +} // namespace
|
| +
|
| +v8::Local<v8::FunctionTemplate> V8InjectedScriptHost::createWrapperTemplate(v8::Isolate* isolate)
|
| +{
|
| + v8::Local<v8::FunctionTemplate> functionTemplate = v8::FunctionTemplate::New(isolate);
|
| +
|
| + functionTemplate->SetClassName(v8::String::NewFromUtf8(isolate, "InjectedScriptHost", v8::NewStringType::kInternalized).ToLocalChecked());
|
| + v8::Local<v8::ObjectTemplate> instanceTemplate = functionTemplate->InstanceTemplate();
|
| +
|
| + for (auto& config : V8InjectedScriptHostMethods) {
|
| + v8::Local<v8::Name> v8name = v8::String::NewFromUtf8(isolate, config.name, v8::NewStringType::kInternalized).ToLocalChecked();
|
| + v8::Local<v8::FunctionTemplate> functionTemplate = v8::FunctionTemplate::New(isolate, config.callback);
|
| + functionTemplate->RemovePrototype();
|
| + instanceTemplate->Set(v8name, functionTemplate, static_cast<v8::PropertyAttribute>(v8::DontDelete | v8::DontEnum | v8::ReadOnly));
|
| + }
|
| +
|
| + return functionTemplate;
|
| +}
|
| +
|
| +v8::Local<v8::Object> V8InjectedScriptHost::wrap(v8::Isolate* isolate, v8::Local<v8::FunctionTemplate> constructorTemplate, PassRefPtr<InjectedScriptHost> host)
|
| +{
|
| + RefPtr<InjectedScriptHost> impl(host);
|
| + v8::Local<v8::Function> function;
|
| + if (!constructorTemplate->GetFunction(isolate->GetCurrentContext()).ToLocal(&function))
|
| + return v8::Local<v8::Object>();
|
| +
|
| + // FIXME: don't depend on V8ScriptRunner
|
| + v8::MaybeLocal<v8::Object> maybeResult = V8ScriptRunner::instantiateObject(isolate, function);
|
| + v8::Local<v8::Object> result;
|
| + if (!maybeResult.ToLocal(&result))
|
| + return v8::Local<v8::Object>();
|
| +
|
| + v8::Local<v8::External> objectReference = v8::External::New(isolate, new WeakCallbackData(isolate, impl, result));
|
| + result->SetHiddenValue(hiddenPropertyName(isolate), objectReference);
|
| +
|
| + return result;
|
| +}
|
| +
|
| +InjectedScriptHost* V8InjectedScriptHost::toImpl(v8::Local<v8::Object> object)
|
| +{
|
| + v8::Isolate* isolate = object->GetIsolate();
|
| + v8::Local<v8::Value> value = object->GetHiddenValue(hiddenPropertyName(isolate));
|
| + if (value.IsEmpty())
|
| + return nullptr;
|
| + if (!value->IsExternal())
|
| + return nullptr;
|
| + void* data = value.As<v8::External>()->Value();
|
| + return reinterpret_cast<WeakCallbackData*>(data)->m_host.get();
|
| +}
|
| +
|
| +v8::Local<v8::String> V8InjectedScriptHost::hiddenPropertyName(v8::Isolate* isolate)
|
| +{
|
| + return v8::String::NewFromUtf8(isolate, "v8inspector::InjectedScriptHost", v8::NewStringType::kInternalized).ToLocalChecked();
|
| +}
|
| +
|
| } // namespace blink
|
|
|