Chromium Code Reviews| Index: Source/core/inspector/InspectorTimelineAgent.cpp |
| diff --git a/Source/core/inspector/InspectorTimelineAgent.cpp b/Source/core/inspector/InspectorTimelineAgent.cpp |
| index 08c88721f1402ae30bf78ca011d3a2525798eaa5..35be30cd9cd1b87778da45b8f47888ce9dfd3f3b 100644 |
| --- a/Source/core/inspector/InspectorTimelineAgent.cpp |
| +++ b/Source/core/inspector/InspectorTimelineAgent.cpp |
| @@ -61,6 +61,7 @@ |
| #include "platform/network/ResourceRequest.h" |
| #include "wtf/CurrentTime.h" |
| #include "wtf/DateMath.h" |
| +#include "wtf/ProcessID.h" |
| namespace WebCore { |
| @@ -73,6 +74,7 @@ static const char includeCounters[] = "includeCounters"; |
| static const char includeGPUEvents[] = "includeGPUEvents"; |
| static const char bufferEvents[] = "bufferEvents"; |
| static const char liveEvents[] = "liveEvents"; |
| +static const char sessionId[] = "sessionId"; |
| static const char traceEventCategoryFilter[] = "traceEventCategoryFilter"; |
| } |
| @@ -341,10 +343,11 @@ void InspectorTimelineAgent::start(ErrorString* errorString, const int* maxCallS |
| m_state->setBoolean(TimelineAgentState::includeGPUEvents, includeGPUEvents && *includeGPUEvents); |
| m_state->setBoolean(TimelineAgentState::bufferEvents, bufferEvents && *bufferEvents); |
| m_state->setString(TimelineAgentState::liveEvents, liveEvents ? *liveEvents : ""); |
| + initializeSessionId(); |
| innerStart(); |
| bool fromConsole = false; |
| - m_frontend->started(&fromConsole); |
| + m_frontend->started(sessionId(), &fromConsole); |
| } |
| bool InspectorTimelineAgent::isStarted() |
| @@ -366,6 +369,10 @@ void InspectorTimelineAgent::innerStart() |
| } |
| m_instrumentingAgents->setInspectorTimelineAgent(this); |
| ScriptGCEvent::addEventListener(this); |
| + TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "TimelineStarted", "sessionId", sessionId().utf8()); |
| + if (m_layerTreeId) { |
|
pfeldman
2014/04/22 17:59:50
call setLayerTreeId instead?
|
| + TRACE_EVENT_INSTANT2(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "SetLayerTreeId", "sessionId", sessionId().utf8(), "layerTreeId", m_layerTreeId); |
| + } |
| if (m_client) { |
| TraceEventDispatcher* dispatcher = TraceEventDispatcher::instance(); |
| dispatcher->addListener(InstrumentationEvents::BeginFrame, TRACE_EVENT_PHASE_INSTANT, this, &InspectorTimelineAgent::onBeginImplSideFrame, m_client); |
| @@ -398,6 +405,7 @@ void InspectorTimelineAgent::stop(ErrorString* errorString, RefPtr<TypeBuilder:: |
| m_state->setBoolean(TimelineAgentState::startedFromProtocol, false); |
| m_state->setBoolean(TimelineAgentState::bufferEvents, false); |
| m_state->setString(TimelineAgentState::liveEvents, ""); |
| + m_state->setString(TimelineAgentState::sessionId, ""); |
| if (!isStarted()) { |
| *errorString = "Timeline was not started"; |
| @@ -446,6 +454,24 @@ void InspectorTimelineAgent::innerStop(bool fromConsole) |
| m_overlay->finishedRecordingProfile(); |
| } |
| +String InspectorTimelineAgent::sessionId() const |
| +{ |
| + return m_state->getString(TimelineAgentState::sessionId); |
| +} |
| + |
| +void InspectorTimelineAgent::initializeSessionId() |
| +{ |
| + static unsigned lastTimelineSessionId; |
| + String token = String::number(getCurrentProcessID()) + "." + String::number(++lastTimelineSessionId); |
|
yurys
2014/04/23 07:05:38
What if pid is reused after a few navigations? Gen
|
| + m_state->setString(TimelineAgentState::sessionId, token); |
| +} |
| + |
| +void InspectorTimelineAgent::setLayerTreeId(int layerTreeId) |
| +{ |
| + m_layerTreeId = layerTreeId; |
| + TRACE_EVENT_INSTANT2(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "setLayerTreeId", "sessionId", sessionId().utf8(), "layerTreeId", m_layerTreeId); |
|
yurys
2014/04/23 07:05:38
Are we going to leave this instrumentation here af
|
| +} |
| + |
| void InspectorTimelineAgent::didBeginFrame(int frameId) |
| { |
| TraceEventDispatcher::instance()->processBackgroundEvents(); |
| @@ -830,9 +856,10 @@ void InspectorTimelineAgent::consoleTimeline(ExecutionContext* context, const St |
| mainFrame()->console().addMessage(ConsoleAPIMessageSource, DebugMessageLevel, message, String(), 0, 0, nullptr, state); |
| m_consoleTimelines.append(title); |
| if (!isStarted()) { |
| + initializeSessionId(); |
| innerStart(); |
| bool fromConsole = true; |
| - m_frontend->started(&fromConsole); |
| + m_frontend->started(sessionId(), &fromConsole); |
| } |
| appendRecord(TimelineRecordFactory::createTimeStampData(message), TimelineRecordType::TimeStamp, true, frameForExecutionContext(context)); |
| } |