[DevTools] Removed ScriptState from createScriptCallTackForConsole

In method createScriptCallTackFromConsole we can get current execution context in function body without passing it in arguments.

Removed canGenerateCallStack argument from InspectorConsoleMessage cstor which uses the transmitted stack.

Review URL: https://codereview.chromium.org/458253002

git-svn-id: svn://svn.chromium.org/blink/trunk@180057 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent d789c8a2
......@@ -111,11 +111,14 @@ PassRefPtrWillBeRawPtr<ScriptCallStack> createScriptCallStack(size_t maxStackSiz
return createScriptCallStack(stackTrace, maxStackSize, emptyStackIsAllowed, isolate);
}
PassRefPtrWillBeRawPtr<ScriptCallStack> createScriptCallStackForConsole(ScriptState* scriptState, size_t maxStackSize)
PassRefPtrWillBeRawPtr<ScriptCallStack> createScriptCallStackForConsole(size_t maxStackSize)
{
size_t stackSize = 1;
if (InspectorInstrumentation::hasFrontends()) {
if (InspectorInstrumentation::consoleAgentEnabled(scriptState->executionContext()))
v8::Isolate* isolate = v8::Isolate::GetCurrent();
if (!isolate->InContext())
return nullptr;
if (InspectorInstrumentation::consoleAgentEnabled(currentExecutionContext(isolate)))
stackSize = maxStackSize;
}
return createScriptCallStack(stackSize);
......
......@@ -50,7 +50,7 @@ const v8::StackTrace::StackTraceOptions stackTraceOptions = static_cast<v8::Stac
PassRefPtrWillBeRawPtr<ScriptCallStack> createScriptCallStack(v8::Handle<v8::StackTrace>, size_t maxStackSize, v8::Isolate*);
PassRefPtrWillBeRawPtr<ScriptCallStack> createScriptCallStack(size_t maxStackSize, bool emptyStackIsAllowed = false);
PassRefPtrWillBeRawPtr<ScriptCallStack> createScriptCallStackForConsole(ScriptState*, size_t maxStackSize = ScriptCallStack::maxCallStackSizeToCapture);
PassRefPtrWillBeRawPtr<ScriptCallStack> createScriptCallStackForConsole(size_t maxStackSize = ScriptCallStack::maxCallStackSizeToCapture);
PassRefPtrWillBeRawPtr<ScriptArguments> createScriptArguments(ScriptState*, const v8::FunctionCallbackInfo<v8::Value>& v8arguments, unsigned skipArgumentCount);
} // namespace blink
......
......@@ -111,14 +111,14 @@ void ConsoleBase::markTimeline(const String& title)
timeStamp(title);
}
void ConsoleBase::profile(ScriptState* scriptState, const String& title)
void ConsoleBase::profile(const String& title)
{
InspectorInstrumentation::consoleProfile(context(), title, scriptState);
InspectorInstrumentation::consoleProfile(context(), title);
}
void ConsoleBase::profileEnd(ScriptState* scriptState, const String& title)
void ConsoleBase::profileEnd(const String& title)
{
InspectorInstrumentation::consoleProfileEnd(context(), title, scriptState);
InspectorInstrumentation::consoleProfileEnd(context(), title);
}
void ConsoleBase::time(const String& title)
......@@ -175,7 +175,7 @@ void ConsoleBase::internalAddMessage(MessageType type, MessageLevel level, Scrip
return;
size_t stackSize = printTrace ? ScriptCallStack::maxCallStackSizeToCapture : 1;
RefPtrWillBeRawPtr<ScriptCallStack> callStack(createScriptCallStackForConsole(scriptState, stackSize));
RefPtrWillBeRawPtr<ScriptCallStack> callStack(createScriptCallStackForConsole(stackSize));
String message;
bool gotStringMessage = arguments->getFirstArgumentAsString(message);
......
......@@ -60,8 +60,8 @@ public:
void assertCondition(ScriptState*, PassRefPtrWillBeRawPtr<ScriptArguments>, bool condition);
void count(ScriptState*, PassRefPtrWillBeRawPtr<ScriptArguments>);
void markTimeline(const String&);
void profile(ScriptState*, const String&);
void profileEnd(ScriptState*, const String&);
void profile(const String&);
void profileEnd(const String&);
void time(const String&);
void timeEnd(ScriptState*, const String&);
void timeStamp(const String&);
......
......@@ -44,8 +44,8 @@
[CallWith=(ScriptArguments,ScriptState)] void count();
[DeprecateAs=ConsoleMarkTimeline] void markTimeline(optional DOMString title = null);
[CallWith=ScriptState] void profile(optional DOMString title = null);
[CallWith=ScriptState] void profileEnd(optional DOMString title = null);
void profile(optional DOMString title = null);
void profileEnd(optional DOMString title = null);
void time(optional DOMString title = null);
[CallWith=ScriptState] void timeEnd(optional DOMString title = null);
......
......@@ -170,7 +170,7 @@ void InspectorConsoleAgent::clearFrontend()
void InspectorConsoleAgent::addMessageToConsole(ConsoleMessage* consoleMessage)
{
if (consoleMessage->callStack()) {
addConsoleMessage(adoptPtr(new InspectorConsoleMessage(!isWorkerAgent(), consoleMessage->source(), LogMessageType, consoleMessage->level(), consoleMessage->message(), consoleMessage->callStack(), consoleMessage->requestIdentifier())));
addConsoleMessage(adoptPtr(new InspectorConsoleMessage(consoleMessage->source(), LogMessageType, consoleMessage->level(), consoleMessage->message(), consoleMessage->callStack(), consoleMessage->requestIdentifier())));
} else {
bool canGenerateCallStack = !isWorkerAgent() && m_frontend;
addConsoleMessage(adoptPtr(new InspectorConsoleMessage(canGenerateCallStack, consoleMessage->source(), LogMessageType, consoleMessage->level(), consoleMessage->message(), consoleMessage->url(), consoleMessage->lineNumber(), consoleMessage->columnNumber(), consoleMessage->scriptState(), consoleMessage->requestIdentifier())));
......@@ -248,7 +248,7 @@ void InspectorConsoleAgent::consoleTimelineEnd(ExecutionContext* context, const
void InspectorConsoleAgent::consoleCount(ScriptState* scriptState, PassRefPtrWillBeRawPtr<ScriptArguments> arguments)
{
RefPtrWillBeRawPtr<ScriptCallStack> callStack(createScriptCallStackForConsole(scriptState, 1));
RefPtrWillBeRawPtr<ScriptCallStack> callStack(createScriptCallStack(1));
const ScriptCallFrame& lastCaller = callStack->at(0);
// Follow Firebug's behavior of counting with null and undefined title in
// the same bucket as no argument
......
......@@ -75,7 +75,7 @@ InspectorConsoleMessage::InspectorConsoleMessage(bool canGenerateCallStack, Mess
autogenerateMetadata(canGenerateCallStack, scriptState);
}
InspectorConsoleMessage::InspectorConsoleMessage(bool, MessageSource source, MessageType type, MessageLevel level, const String& message, PassRefPtrWillBeRawPtr<ScriptCallStack> callStack, unsigned long requestIdentifier)
InspectorConsoleMessage::InspectorConsoleMessage(MessageSource source, MessageType type, MessageLevel level, const String& message, PassRefPtrWillBeRawPtr<ScriptCallStack> callStack, unsigned long requestIdentifier)
: m_source(source)
, m_type(type)
, m_level(level)
......@@ -122,7 +122,7 @@ void InspectorConsoleMessage::autogenerateMetadata(bool canGenerateCallStack, Sc
return;
if (scriptState)
m_callStack = createScriptCallStackForConsole(scriptState);
m_callStack = createScriptCallStackForConsole();
else if (canGenerateCallStack)
m_callStack = createScriptCallStack(ScriptCallStack::maxCallStackSizeToCapture, true);
else
......
......@@ -52,7 +52,7 @@ class InspectorConsoleMessage {
public:
InspectorConsoleMessage(bool canGenerateCallStack, MessageSource, MessageType, MessageLevel, const String& message);
InspectorConsoleMessage(bool canGenerateCallStack, MessageSource, MessageType, MessageLevel, const String& message, const String& url, unsigned line, unsigned column, ScriptState*, unsigned long requestIdentifier);
InspectorConsoleMessage(bool canGenerateCallStack, MessageSource, MessageType, MessageLevel, const String& message, PassRefPtrWillBeRawPtr<ScriptCallStack>, unsigned long requestIdentifier);
InspectorConsoleMessage(MessageSource, MessageType, MessageLevel, const String& message, PassRefPtrWillBeRawPtr<ScriptCallStack>, unsigned long requestIdentifier);
InspectorConsoleMessage(bool canGenerateCallStack, MessageSource, MessageType, MessageLevel, const String& message, PassRefPtrWillBeRawPtr<ScriptArguments>, ScriptState*, unsigned long requestIdentifier);
~InspectorConsoleMessage();
......
......@@ -506,10 +506,10 @@ class ConsoleMessage;
void consoleTimelineEnd([Keep] ExecutionContext* context, const String& title, ScriptState* state);
[Profiler, Inline=FastReturn]
void consoleProfile([Keep] ExecutionContext* context, const String& title, ScriptState* state);
void consoleProfile([Keep] ExecutionContext* context, const String& title);
[Profiler, Inline=FastReturn]
void consoleProfileEnd(ExecutionContext* context, const String& title, ScriptState* state);
void consoleProfileEnd(ExecutionContext* context, const String& title);
}
interface InspectorOverrides {
......
......@@ -64,9 +64,9 @@ static PassRefPtr<TypeBuilder::Profiler::CPUProfile> createCPUProfile(const Scri
return profile.release();
}
static PassRefPtr<TypeBuilder::Debugger::Location> currentDebugLocation(ScriptState* scriptState)
static PassRefPtr<TypeBuilder::Debugger::Location> currentDebugLocation()
{
RefPtrWillBeRawPtr<ScriptCallStack> callStack(createScriptCallStackForConsole(scriptState, 1));
RefPtrWillBeRawPtr<ScriptCallStack> callStack(createScriptCallStack(1));
const ScriptCallFrame& lastCaller = callStack->at(0);
RefPtr<TypeBuilder::Debugger::Location> location = TypeBuilder::Debugger::Location::create()
.setScriptId(lastCaller.scriptId())
......@@ -104,17 +104,17 @@ InspectorProfilerAgent::~InspectorProfilerAgent()
{
}
void InspectorProfilerAgent::consoleProfile(ExecutionContext* context, const String& title, ScriptState* scriptState)
void InspectorProfilerAgent::consoleProfile(ExecutionContext* context, const String& title)
{
UseCounter::count(context, UseCounter::DevToolsConsoleProfile);
ASSERT(m_frontend && enabled());
String id = nextProfileId();
m_startedProfiles.append(ProfileDescriptor(id, title));
ScriptProfiler::start(id);
m_frontend->consoleProfileStarted(id, currentDebugLocation(scriptState), title.isNull() ? 0 : &title);
m_frontend->consoleProfileStarted(id, currentDebugLocation(), title.isNull() ? 0 : &title);
}
void InspectorProfilerAgent::consoleProfileEnd(const String& title, ScriptState* scriptState)
void InspectorProfilerAgent::consoleProfileEnd(const String& title)
{
ASSERT(m_frontend && enabled());
String id;
......@@ -141,7 +141,7 @@ void InspectorProfilerAgent::consoleProfileEnd(const String& title, ScriptState*
RefPtrWillBeRawPtr<ScriptProfile> profile = ScriptProfiler::stop(id);
if (!profile)
return;
RefPtr<TypeBuilder::Debugger::Location> location = currentDebugLocation(scriptState);
RefPtr<TypeBuilder::Debugger::Location> location = currentDebugLocation();
m_frontend->consoleProfileFinished(id, location, createCPUProfile(*profile), resolvedTitle.isNull() ? 0 : &resolvedTitle);
}
......
......@@ -60,8 +60,8 @@ public:
virtual ~InspectorProfilerAgent();
virtual void trace(Visitor*) OVERRIDE;
void consoleProfile(ExecutionContext*, const String& title, ScriptState*);
void consoleProfileEnd(const String& title, ScriptState*);
void consoleProfile(ExecutionContext*, const String& title);
void consoleProfileEnd(const String& title);
virtual void enable(ErrorString*) OVERRIDE;
virtual void disable(ErrorString*) OVERRIDE;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment