本文整理汇总了C++中InjectedScript::wrapObject方法的典型用法代码示例。如果您正苦于以下问题:C++ InjectedScript::wrapObject方法的具体用法?C++ InjectedScript::wrapObject怎么用?C++ InjectedScript::wrapObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类InjectedScript
的用法示例。
在下文中一共展示了InjectedScript::wrapObject方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: didPause
void InspectorDebuggerAgent::didPause(JSC::ExecState* scriptState, const ScriptValue& callFrames, const ScriptValue& exception)
{
ASSERT(scriptState && !m_pausedScriptState);
m_pausedScriptState = scriptState;
m_currentCallStack = callFrames;
if (!exception.hasNoValue()) {
InjectedScript injectedScript = m_injectedScriptManager->injectedScriptFor(scriptState);
if (!injectedScript.hasNoValue()) {
m_breakReason = InspectorFrontend::Debugger::Reason::Exception;
m_breakAuxData = injectedScript.wrapObject(exception, "backtrace")->openAccessors();
// m_breakAuxData might be null after this.
}
}
m_frontend->paused(currentCallFrames(), m_breakReason, m_breakAuxData);
m_javaScriptPauseScheduled = false;
if (!m_continueToLocationBreakpointId.isEmpty()) {
scriptDebugServer().removeBreakpoint(m_continueToLocationBreakpointId);
m_continueToLocationBreakpointId = "";
}
if (m_listener)
m_listener->didPause();
}
示例2: null
PassRefPtr<InspectorValue> ScriptProfiler::objectByHeapObjectId(unsigned id, InjectedScriptManager* injectedScriptManager)
{
// As ids are unique, it doesn't matter which HeapSnapshot owns HeapGraphNode.
// We need to find first HeapSnapshot containing a node with the specified id.
const v8::HeapGraphNode* node = 0;
for (int i = 0, l = v8::HeapProfiler::GetSnapshotsCount(); i < l; ++i) {
const v8::HeapSnapshot* snapshot = v8::HeapProfiler::GetSnapshot(i);
node = snapshot->GetNodeById(id);
if (node)
break;
}
if (!node)
return InspectorValue::null();
v8::HandleScope scope;
v8::Handle<v8::Value> value = node->GetHeapValue();
if (!value->IsObject())
return InspectorValue::null();
v8::Handle<v8::Object> object(value.As<v8::Object>());
v8::Local<v8::Context> creationContext = object->CreationContext();
v8::Context::Scope creationScope(creationContext);
ScriptState* scriptState = ScriptState::forContext(creationContext);
InjectedScript injectedScript = injectedScriptManager->injectedScriptFor(scriptState);
return !injectedScript.hasNoValue() ?
RefPtr<InspectorValue>(injectedScript.wrapObject(value, "")).release() : InspectorValue::null();
}
示例3: runScript
void InspectorDebuggerAgent::runScript(ErrorString* errorString, const ScriptId& scriptId, const int* executionContextId, const String* const objectGroup, const bool* const doNotPauseOnExceptionsAndMuteConsole, RefPtr<TypeBuilder::Runtime::RemoteObject>& result, TypeBuilder::OptOutput<bool>* wasThrown)
{
InjectedScript injectedScript = injectedScriptForEval(errorString, executionContextId);
if (injectedScript.hasNoValue()) {
*errorString = "Inspected frame has gone";
return;
}
ScriptDebugServer::PauseOnExceptionsState previousPauseOnExceptionsState = scriptDebugServer().pauseOnExceptionsState();
if (doNotPauseOnExceptionsAndMuteConsole && *doNotPauseOnExceptionsAndMuteConsole) {
if (previousPauseOnExceptionsState != ScriptDebugServer::DontPauseOnExceptions)
scriptDebugServer().setPauseOnExceptionsState(ScriptDebugServer::DontPauseOnExceptions);
muteConsole();
}
ScriptValue value;
bool wasThrownValue;
String exceptionMessage;
scriptDebugServer().runScript(injectedScript.scriptState(), scriptId, &value, &wasThrownValue, &exceptionMessage);
*wasThrown = wasThrownValue;
if (value.hasNoValue()) {
*errorString = "Script execution failed";
return;
}
result = injectedScript.wrapObject(value, objectGroup ? *objectGroup : "");
if (wasThrownValue)
result->setDescription(exceptionMessage);
if (doNotPauseOnExceptionsAndMuteConsole && *doNotPauseOnExceptionsAndMuteConsole) {
unmuteConsole();
if (scriptDebugServer().pauseOnExceptionsState() != previousPauseOnExceptionsState)
scriptDebugServer().setPauseOnExceptionsState(previousPauseOnExceptionsState);
}
}
示例4: resolveAnimation
void InspectorAnimationAgent::resolveAnimation(ErrorString* errorString, const String& animationId, RefPtr<TypeBuilder::Runtime::RemoteObject>& result)
{
Animation* animation = assertAnimation(errorString, animationId);
if (!animation)
return;
if (m_idToAnimationClone.get(animationId))
animation = m_idToAnimationClone.get(animationId);
const Element* element = toKeyframeEffect(animation->effect())->target();
Document* document = element->ownerDocument();
LocalFrame* frame = document ? document->frame() : nullptr;
if (!frame) {
*errorString = "Element not associated with a document.";
return;
}
ScriptState* scriptState = ScriptState::forMainWorld(frame);
InjectedScript injectedScript = m_injectedScriptManager->injectedScriptFor(scriptState);
if (injectedScript.isEmpty())
return;
ScriptState::Scope scope(scriptState);
v8::Isolate* isolate = scriptState->isolate();
ScriptValue scriptValue = ScriptValue(scriptState, toV8(animation, scriptState->context()->Global(), isolate));
injectedScript.releaseObjectGroup("animation");
result = injectedScript.wrapObject(scriptValue, "animation");
}
示例5: addToFrontend
void ConsoleMessage::addToFrontend(InspectorFrontend::Console* frontend, InjectedScriptManager* injectedScriptManager)
{
RefPtr<TypeBuilder::Console::ConsoleMessage> jsonObj = TypeBuilder::Console::ConsoleMessage::create()
.setSource(messageSourceValue(m_source))
.setLevel(messageLevelValue(m_level))
.setText(m_message);
// FIXME: only send out type for ConsoleAPI source messages.
jsonObj->setType(messageTypeValue(m_type));
jsonObj->setLine(static_cast<int>(m_line));
jsonObj->setUrl(m_url);
jsonObj->setRepeatCount(static_cast<int>(m_repeatCount));
if (m_source == NetworkMessageSource && !m_requestId.isEmpty())
jsonObj->setNetworkRequestId(m_requestId);
if (m_arguments && m_arguments->argumentCount()) {
InjectedScript injectedScript = injectedScriptManager->injectedScriptFor(m_arguments->globalState());
if (!injectedScript.hasNoValue()) {
RefPtr<InspectorArray> jsonArgs = InspectorArray::create();
for (unsigned i = 0; i < m_arguments->argumentCount(); ++i) {
RefPtr<InspectorValue> inspectorValue = injectedScript.wrapObject(m_arguments->argumentAt(i), "console");
if (!inspectorValue) {
ASSERT_NOT_REACHED();
return;
}
jsonArgs->pushValue(inspectorValue);
}
jsonObj->setParameters(jsonArgs);
}
}
if (m_callStack)
jsonObj->setStackTrace(m_callStack->buildInspectorArray());
frontend->messageAdded(jsonObj);
}
示例6: addToFrontend
void ConsoleMessage::addToFrontend(InspectorFrontend::Console* frontend, InjectedScriptManager* injectedScriptManager)
{
RefPtr<InspectorObject> jsonObj = InspectorObject::create();
jsonObj->setString("source", messageSourceValue(m_source));
jsonObj->setString("type", messageTypeValue(m_type));
jsonObj->setString("level", messageLevelValue(m_level));
jsonObj->setNumber("line", static_cast<int>(m_line));
jsonObj->setString("url", m_url);
jsonObj->setNumber("repeatCount", static_cast<int>(m_repeatCount));
jsonObj->setString("text", m_message);
if (m_type == NetworkErrorMessageType)
jsonObj->setNumber("networkIdentifier", m_requestId);
if (m_arguments && m_arguments->argumentCount()) {
InjectedScript injectedScript = injectedScriptManager->injectedScriptFor(m_arguments->globalState());
if (!injectedScript.hasNoValue()) {
RefPtr<InspectorArray> jsonArgs = InspectorArray::create();
for (unsigned i = 0; i < m_arguments->argumentCount(); ++i) {
RefPtr<InspectorValue> inspectorValue = injectedScript.wrapObject(m_arguments->argumentAt(i), "console");
if (!inspectorValue) {
ASSERT_NOT_REACHED();
return;
}
jsonArgs->pushValue(inspectorValue);
}
jsonObj->setArray("parameters", jsonArgs);
}
}
if (m_callStack)
jsonObj->setArray("stackTrace", m_callStack->buildInspectorArray());
frontend->messageAdded(jsonObj);
}
示例7: getRemoteObject
void InspectorHeapAgent::getRemoteObject(ErrorString& errorString, int heapObjectId, const String* optionalObjectGroup, RefPtr<Inspector::Protocol::Runtime::RemoteObject>& result)
{
// Prevent the cell from getting collected as we look it up.
VM& vm = m_environment.vm();
JSLockHolder lock(vm);
DeferGC deferGC(vm.heap);
unsigned heapObjectIdentifier = static_cast<unsigned>(heapObjectId);
const Optional<HeapSnapshotNode> optionalNode = nodeForHeapObjectIdentifier(errorString, heapObjectIdentifier);
if (!optionalNode)
return;
JSCell* cell = optionalNode->cell;
Structure* structure = cell->structure(m_environment.vm());
if (!structure) {
errorString = ASCIILiteral("Unable to get object details");
return;
}
JSGlobalObject* globalObject = structure->globalObject();
if (!globalObject) {
errorString = ASCIILiteral("Unable to get object details");
return;
}
InjectedScript injectedScript = m_injectedScriptManager.injectedScriptFor(globalObject->globalExec());
if (injectedScript.hasNoValue()) {
errorString = ASCIILiteral("Unable to get object details - InjectedScript");
return;
}
Deprecated::ScriptValue cellScriptValue(m_environment.vm(), JSValue(cell));
String objectGroup = optionalObjectGroup ? *optionalObjectGroup : String();
result = injectedScript.wrapObject(cellScriptValue, objectGroup, true);
}
示例8: ASSERT
RefPtr<InspectorObject> InspectorDebuggerAgent::buildExceptionPauseReason(const Deprecated::ScriptValue& exception, const InjectedScript& injectedScript)
{
ASSERT(!exception.hasNoValue());
if (exception.hasNoValue())
return nullptr;
ASSERT(!injectedScript.hasNoValue());
if (injectedScript.hasNoValue())
return nullptr;
return injectedScript.wrapObject(exception, InspectorDebuggerAgent::backtraceObjectGroup)->openAccessors();
}
示例9: addToFrontend
void ConsoleMessage::addToFrontend(ConsoleFrontendDispatcher* consoleFrontendDispatcher, InjectedScriptManager* injectedScriptManager, bool generatePreview)
{
Ref<Inspector::Protocol::Console::ConsoleMessage> jsonObj = Inspector::Protocol::Console::ConsoleMessage::create()
.setSource(messageSourceValue(m_source))
.setLevel(messageLevelValue(m_level))
.setText(m_message)
.release();
// FIXME: only send out type for ConsoleAPI source messages.
jsonObj->setType(messageTypeValue(m_type));
jsonObj->setLine(static_cast<int>(m_line));
jsonObj->setColumn(static_cast<int>(m_column));
jsonObj->setUrl(m_url);
jsonObj->setRepeatCount(static_cast<int>(m_repeatCount));
if (m_source == MessageSource::Network && !m_requestId.isEmpty())
jsonObj->setNetworkRequestId(m_requestId);
if (m_arguments && m_arguments->argumentCount()) {
InjectedScript injectedScript = injectedScriptManager->injectedScriptFor(m_arguments->globalState());
if (!injectedScript.hasNoValue()) {
Ref<Inspector::Protocol::Array<Inspector::Protocol::Runtime::RemoteObject>> jsonArgs = Inspector::Protocol::Array<Inspector::Protocol::Runtime::RemoteObject>::create();
if (m_type == MessageType::Table && generatePreview && m_arguments->argumentCount()) {
Deprecated::ScriptValue table = m_arguments->argumentAt(0);
Deprecated::ScriptValue columns = m_arguments->argumentCount() > 1 ? m_arguments->argumentAt(1) : Deprecated::ScriptValue();
RefPtr<Inspector::Protocol::Runtime::RemoteObject> inspectorValue = injectedScript.wrapTable(table, columns);
if (!inspectorValue) {
ASSERT_NOT_REACHED();
return;
}
jsonArgs->addItem(inspectorValue.copyRef());
if (m_arguments->argumentCount() > 1)
jsonArgs->addItem(injectedScript.wrapObject(columns, ASCIILiteral("console"), true));
} else {
for (unsigned i = 0; i < m_arguments->argumentCount(); ++i) {
RefPtr<Inspector::Protocol::Runtime::RemoteObject> inspectorValue = injectedScript.wrapObject(m_arguments->argumentAt(i), ASCIILiteral("console"), generatePreview);
if (!inspectorValue) {
ASSERT_NOT_REACHED();
return;
}
jsonArgs->addItem(inspectorValue.copyRef());
}
}
jsonObj->setParameters(WTF::move(jsonArgs));
}
}
if (m_callStack)
jsonObj->setStackTrace(m_callStack->buildInspectorArray());
consoleFrontendDispatcher->messageAdded(WTF::move(jsonObj));
}
示例10: breakpointActionProbe
void InspectorDebuggerAgent::breakpointActionProbe(JSC::ExecState* scriptState, const ScriptBreakpointAction& action, unsigned batchId, unsigned sampleId, const Deprecated::ScriptValue& sample)
{
InjectedScript injectedScript = m_injectedScriptManager->injectedScriptFor(scriptState);
RefPtr<Protocol::Runtime::RemoteObject> payload = injectedScript.wrapObject(sample, objectGroupForBreakpointAction(action), true);
auto result = Protocol::Debugger::ProbeSample::create()
.setProbeId(action.identifier)
.setBatchId(batchId)
.setSampleId(sampleId)
.setTimestamp(m_injectedScriptManager->inspectorEnvironment().executionStopwatch()->elapsedTime())
.setPayload(payload.release())
.release();
m_frontendDispatcher->didSampleProbe(WTF::move(result));
}
示例11: breakpointActionProbe
void InspectorDebuggerAgent::breakpointActionProbe(JSC::ExecState* scriptState, const ScriptBreakpointAction& action, int hitCount, const Deprecated::ScriptValue& sample)
{
int sampleId = m_nextProbeSampleId++;
InjectedScript injectedScript = m_injectedScriptManager->injectedScriptFor(scriptState);
RefPtr<Protocol::Runtime::RemoteObject> payload = injectedScript.wrapObject(sample, objectGroupForBreakpointAction(action));
RefPtr<Protocol::Debugger::ProbeSample> result = Protocol::Debugger::ProbeSample::create()
.setProbeId(action.identifier)
.setSampleId(sampleId)
.setBatchId(hitCount)
.setTimestamp(monotonicallyIncreasingTime())
.setPayload(payload.release());
m_frontendDispatcher->didSampleProbe(result.release());
}
示例12: addToFrontend
void ConsoleMessage::addToFrontend(InspectorFrontend::Console* frontend, InjectedScriptManager* injectedScriptManager, bool generatePreview)
{
RefPtr<TypeBuilder::Console::ConsoleMessage> jsonObj = TypeBuilder::Console::ConsoleMessage::create()
.setSource(messageSourceValue(m_source))
.setLevel(messageLevelValue(m_level))
.setText(m_message)
.setTimestamp(m_timestamp);
// FIXME: only send out type for ConsoleAPI source messages.
jsonObj->setType(messageTypeValue(m_type));
jsonObj->setLine(static_cast<int>(m_line));
jsonObj->setColumn(static_cast<int>(m_column));
jsonObj->setUrl(m_url);
ScriptState* scriptState = m_scriptState.get();
if (scriptState && scriptState->executionContext()->isDocument())
jsonObj->setExecutionContextId(injectedScriptManager->injectedScriptIdFor(scriptState));
if (m_source == NetworkMessageSource && !m_requestId.isEmpty())
jsonObj->setNetworkRequestId(m_requestId);
if (m_arguments && m_arguments->argumentCount()) {
InjectedScript injectedScript = injectedScriptManager->injectedScriptFor(m_arguments->scriptState());
if (!injectedScript.isEmpty()) {
RefPtr<TypeBuilder::Array<TypeBuilder::Runtime::RemoteObject> > jsonArgs = TypeBuilder::Array<TypeBuilder::Runtime::RemoteObject>::create();
if (m_type == TableMessageType && generatePreview && m_arguments->argumentCount()) {
ScriptValue table = m_arguments->argumentAt(0);
ScriptValue columns = m_arguments->argumentCount() > 1 ? m_arguments->argumentAt(1) : ScriptValue();
RefPtr<TypeBuilder::Runtime::RemoteObject> inspectorValue = injectedScript.wrapTable(table, columns);
if (!inspectorValue) {
ASSERT_NOT_REACHED();
return;
}
jsonArgs->addItem(inspectorValue);
} else {
for (unsigned i = 0; i < m_arguments->argumentCount(); ++i) {
RefPtr<TypeBuilder::Runtime::RemoteObject> inspectorValue = injectedScript.wrapObject(m_arguments->argumentAt(i), "console", generatePreview);
if (!inspectorValue) {
ASSERT_NOT_REACHED();
return;
}
jsonArgs->addItem(inspectorValue);
}
}
jsonObj->setParameters(jsonArgs);
}
}
if (m_callStack)
jsonObj->setStackTrace(m_callStack->buildInspectorArray());
frontend->messageAdded(jsonObj);
frontend->flush();
}
示例13: getObjectByHeapObjectId
void InspectorProfilerAgent::getObjectByHeapObjectId(ErrorString* error, int id, const String* objectGroup, RefPtr<TypeBuilder::Runtime::RemoteObject>& result)
{
ScriptObject heapObject = ScriptProfiler::objectByHeapObjectId(id);
if (heapObject.hasNoValue()) {
*error = "Object is not available";
return;
}
InjectedScript injectedScript = m_injectedScriptManager->injectedScriptFor(heapObject.scriptState());
if (injectedScript.hasNoValue()) {
*error = "Object is not available. Inspected context is gone";
return;
}
result = injectedScript.wrapObject(heapObject, objectGroup ? *objectGroup : "");
if (!result)
*error = "Failed to wrap object";
}
示例14: didPause
void InspectorDebuggerAgent::didPause(ScriptState* scriptState, const ScriptValue& callFrames, const ScriptValue& exception, const Vector<String>& hitBreakpoints)
{
ASSERT(scriptState && !m_pausedScriptState);
m_pausedScriptState = scriptState;
m_currentCallStack = callFrames;
m_skipStepInCount = numberOfStepsBeforeStepOut;
if (!exception.hasNoValue()) {
InjectedScript injectedScript = m_injectedScriptManager->injectedScriptFor(scriptState);
if (!injectedScript.hasNoValue()) {
m_breakReason = InspectorFrontend::Debugger::Reason::Exception;
m_breakAuxData = injectedScript.wrapObject(exception, "backtrace")->openAccessors();
// m_breakAuxData might be null after this.
}
}
RefPtr<Array<String> > hitBreakpointIds = Array<String>::create();
for (Vector<String>::const_iterator i = hitBreakpoints.begin(); i != hitBreakpoints.end(); ++i) {
DebugServerBreakpointToBreakpointIdAndSourceMap::iterator breakpointIterator = m_serverBreakpoints.find(*i);
if (breakpointIterator != m_serverBreakpoints.end()) {
const String& localId = breakpointIterator->value.first;
hitBreakpointIds->addItem(localId);
BreakpointSource source = breakpointIterator->value.second;
if (m_breakReason == InspectorFrontend::Debugger::Reason::Other && source == DebugCommandBreakpointSource)
m_breakReason = InspectorFrontend::Debugger::Reason::DebugCommand;
}
}
m_frontend->paused(currentCallFrames(), m_breakReason, m_breakAuxData, hitBreakpointIds);
m_javaScriptPauseScheduled = false;
if (!m_continueToLocationBreakpointId.isEmpty()) {
scriptDebugServer().removeBreakpoint(m_continueToLocationBreakpointId);
m_continueToLocationBreakpointId = "";
}
if (m_listener)
m_listener->didPause();
}
示例15: didPause
void InspectorDebuggerAgent::didPause(ScriptState* scriptState, const ScriptValue& callFrames, const ScriptValue& exception)
{
ASSERT(scriptState && !m_pausedScriptState);
m_pausedScriptState = scriptState;
m_currentCallStack = callFrames;
if (!exception.hasNoValue()) {
InjectedScript injectedScript = m_injectedScriptManager->injectedScriptFor(scriptState);
if (!injectedScript.hasNoValue()) {
m_breakReason = "exception";
m_breakAuxData = injectedScript.wrapObject(exception, "backtrace");
}
}
m_frontend->paused(currentCallFrames(), m_breakReason, m_breakAuxData);
m_javaScriptPauseScheduled = false;
if (!m_continueToLocationBreakpointId.isEmpty()) {
scriptDebugServer().removeBreakpoint(m_continueToLocationBreakpointId);
m_continueToLocationBreakpointId = "";
}
}