Web Inspector: do not send profile headers to the front-end until explicitly requested.
[WebKit-https.git] / Source / WebCore / inspector / InspectorProfilerAgent.cpp
index 997dd4a..42cde85 100644 (file)
@@ -123,6 +123,7 @@ InspectorProfilerAgent::InspectorProfilerAgent(InstrumentingAgents* instrumentin
     , m_frontend(0)
     , m_enabled(false)
     , m_recordingUserInitiatedProfile(false)
+    , m_headersRequested(false)
     , m_currentUserInitiatedProfileNumber(-1)
     , m_nextUserInitiatedProfileNumber(1)
     , m_nextUserInitiatedHeapSnapshotNumber(1)
@@ -139,7 +140,7 @@ void InspectorProfilerAgent::addProfile(PassRefPtr<ScriptProfile> prpProfile, un
 {
     RefPtr<ScriptProfile> profile = prpProfile;
     m_profiles.add(profile->uid(), profile);
-    if (m_frontend)
+    if (m_frontend && m_headersRequested)
         m_frontend->addProfileHeader(createProfileHeader(*profile));
     addProfileFinishedMessageToConsole(profile, lineNumber, sourceURL);
 }
@@ -220,6 +221,7 @@ void InspectorProfilerAgent::disable()
     if (!m_enabled)
         return;
     m_enabled = false;
+    m_headersRequested = false;
     PageScriptDebugServer::shared().recompileAllJSFunctionsSoon();
 }
 
@@ -242,6 +244,7 @@ String InspectorProfilerAgent::getCurrentUserInitiatedProfileName(bool increment
 
 void InspectorProfilerAgent::getProfileHeaders(ErrorString*, RefPtr<TypeBuilder::Array<TypeBuilder::Profiler::ProfileHeader> >& headers)
 {
+    m_headersRequested = true;
     headers = TypeBuilder::Array<TypeBuilder::Profiler::ProfileHeader>::create();
 
     ProfilesMap::iterator profilesEnd = m_profiles.end();
@@ -321,7 +324,7 @@ void InspectorProfilerAgent::resetState()
 
 void InspectorProfilerAgent::resetFrontendProfiles()
 {
-    if (m_frontend && enabled()
+    if (m_headersRequested && m_frontend
         && m_profiles.begin() == m_profiles.end()
         && m_snapshots.begin() == m_snapshots.end())
         m_frontend->resetProfiles();