Commit 00743c3f authored by mnaganov@chromium.org's avatar mnaganov@chromium.org

2010-08-23 Mikhail Naganov <mnaganov@chromium.org>

        Reviewed by Pavel Feldman.

        Extract profiler-related code and data from InspectorController into
        InspectorProfilerAgent.

        https://bugs.webkit.org/show_bug.cgi?id=44174

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@65797 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent bb2e0894
......@@ -1075,6 +1075,7 @@ SET(WebCore_SOURCES
inspector/InspectorDebuggerAgent.cpp
inspector/InspectorFrontendClientLocal.cpp
inspector/InspectorFrontendHost.cpp
inspector/InspectorProfilerAgent.cpp
inspector/InspectorResource.cpp
inspector/InspectorValues.cpp
inspector/InspectorStorageAgent.cpp
......
2010-08-23 Mikhail Naganov <mnaganov@chromium.org>
Reviewed by Pavel Feldman.
Extract profiler-related code and data from InspectorController into
InspectorProfilerAgent.
https://bugs.webkit.org/show_bug.cgi?id=44174
* CMakeLists.txt:
* GNUmakefile.am:
* WebCore.exp.in:
* WebCore.gypi:
* WebCore.pro:
* WebCore.vcproj/WebCore.vcproj:
* WebCore.xcodeproj/project.pbxproj:
* bindings/js/ScriptProfiler.cpp:
(WebCore::ScriptProfiler::isProfilerAlwaysEnabled):
* bindings/js/ScriptProfiler.h:
* bindings/v8/ScriptProfiler.cpp:
(WebCore::ScriptProfiler::isProfilerAlwaysEnabled):
* bindings/v8/ScriptProfiler.h:
* inspector/CodeGeneratorInspector.pm:
* inspector/Inspector.idl:
* inspector/InspectorController.cpp:
(WebCore::InspectorController::InspectorController):
(WebCore::InspectorController::connectFrontend):
(WebCore::InspectorController::disconnectFrontend):
(WebCore::InspectorController::populateScriptObjects):
(WebCore::InspectorController::didCommitLoad):
(WebCore::InspectorController::addProfile):
(WebCore::InspectorController::addProfileFinishedMessageToConsole):
(WebCore::InspectorController::addStartProfilingMessageToConsole):
(WebCore::InspectorController::isRecordingUserInitiatedProfile):
(WebCore::InspectorController::getCurrentUserInitiatedProfileName):
(WebCore::InspectorController::startUserInitiatedProfiling):
(WebCore::InspectorController::stopUserInitiatedProfiling):
(WebCore::InspectorController::profilerEnabled):
(WebCore::InspectorController::enableProfiler):
(WebCore::InspectorController::disableProfiler):
* inspector/InspectorController.h:
(WebCore::InspectorController::profilerAgent):
* inspector/InspectorProfilerAgent.cpp: Added.
(WebCore::InspectorProfilerAgent::create):
(WebCore::InspectorProfilerAgent::InspectorProfilerAgent):
(WebCore::InspectorProfilerAgent::~InspectorProfilerAgent):
(WebCore::InspectorProfilerAgent::addProfile):
(WebCore::InspectorProfilerAgent::addProfileFinishedMessageToConsole):
(WebCore::InspectorProfilerAgent::addStartProfilingMessageToConsole):
(WebCore::InspectorProfilerAgent::createProfileHeader):
(WebCore::InspectorProfilerAgent::disable):
(WebCore::InspectorProfilerAgent::enable):
(WebCore::InspectorProfilerAgent::getCurrentUserInitiatedProfileName):
(WebCore::InspectorProfilerAgent::getProfileHeaders):
(WebCore::InspectorProfilerAgent::getProfile):
(WebCore::InspectorProfilerAgent::removeProfile):
(WebCore::InspectorProfilerAgent::resetState):
(WebCore::InspectorProfilerAgent::startUserInitiatedProfiling):
(WebCore::InspectorProfilerAgent::stopUserInitiatedProfiling):
(WebCore::InspectorProfilerAgent::toggleRecordButton):
* inspector/InspectorProfilerAgent.h: Added.
(WebCore::InspectorProfilerAgent::clearProfiles):
(WebCore::InspectorProfilerAgent::enabled):
(WebCore::InspectorProfilerAgent::isRecordingUserInitiatedProfile):
(WebCore::InspectorProfilerAgent::setRemoteFrontend):
(WebCore::InspectorProfilerAgent::startProfiling):
(WebCore::InspectorProfilerAgent::stopProfiling):
2010-08-23 Ariya Hidayat <ariya@sencha.com>
Reviewed by Kenneth Rohde Christiansen.
......@@ -1628,6 +1628,8 @@ webcore_sources += \
WebCore/inspector/InspectorFrontendClientLocal.h \
WebCore/inspector/InspectorFrontendHost.cpp \
WebCore/inspector/InspectorFrontendHost.h \
WebCore/inspector/InspectorProfilerAgent.cpp \
WebCore/inspector/InspectorProfilerAgent.h \
WebCore/inspector/InspectorResource.cpp \
WebCore/inspector/InspectorResource.h \
WebCore/inspector/InspectorStorageAgent.cpp \
......
......@@ -1189,10 +1189,12 @@ __ZN7WebCore19InspectorController20stopTimelineProfilerEv
__ZN7WebCore19InspectorController21startTimelineProfilerEv
__ZN7WebCore19InspectorController25evaluateForTestInFrontendElRKN3WTF6StringE
__ZN7WebCore19InspectorController26setInspectorFrontendClientEN3WTF10PassOwnPtrINS_23InspectorFrontendClientEEE
__ZN7WebCore19InspectorController27startUserInitiatedProfilingEv
__ZN7WebCore19InspectorController26stopUserInitiatedProfilingEv
__ZN7WebCore19InspectorController27startUserInitiatedProfilingEPNS_5TimerIS0_EE
__ZN7WebCore19InspectorController34inspectorStartsAttachedSettingNameEv
__ZN7WebCore19InspectorController34inspectorStartsAttachedSettingNameEv
__ZNK7WebCore19InspectorController31isRecordingUserInitiatedProfileEv
__ZNK7WebCore19InspectorController15profilerEnabledEv
__ZN7WebCore19InspectorController4showEv
__ZN7WebCore19InspectorController5closeEv
__ZN7WebCore19InspectorController7inspectEPNS_4NodeE
......
......@@ -1770,6 +1770,8 @@
'inspector/InspectorFrontendClient.h',
'inspector/InspectorFrontendHost.cpp',
'inspector/InspectorFrontendHost.h',
'inspector/InspectorProfilerAgent.cpp',
'inspector/InspectorProfilerAgent.h',
'inspector/InspectorResource.cpp',
'inspector/InspectorResource.h',
'inspector/InspectorStorageAgent.cpp',
......
......@@ -762,6 +762,7 @@ SOURCES += \
inspector/InspectorDOMStorageResource.cpp \
inspector/InspectorFrontendClientLocal.cpp \
inspector/InspectorFrontendHost.cpp \
inspector/InspectorProfilerAgent.cpp \
inspector/InspectorResource.cpp \
inspector/InspectorStorageAgent.cpp \
inspector/InspectorTimelineAgent.cpp \
......@@ -1532,6 +1533,7 @@ HEADERS += \
inspector/InspectorFrontendClient.h \
inspector/InspectorFrontendClientLocal.h \
inspector/InspectorFrontendHost.h \
inspector/InspectorProfilerAgent.h \
inspector/InspectorResource.h \
inspector/InspectorStorageAgent.h \
inspector/InspectorTimelineAgent.h \
......
......@@ -51873,6 +51873,14 @@
>
</File>
<File
RelativePath="..\inspector\InspectorProfilerAgent.cpp"
>
</File>
<File
RelativePath="..\inspector\InspectorProfilerAgent.h"
>
</File>
<File
RelativePath="..\inspector\InspectorResource.cpp"
>
</File>
......@@ -2745,6 +2745,8 @@
97EF561011E40783007E026F /* HTMLConstructionSite.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 97EF560E11E40783007E026F /* HTMLConstructionSite.cpp */; };
97EF561111E40783007E026F /* HTMLConstructionSite.h in Headers */ = {isa = PBXBuildFile; fileRef = 97EF560F11E40783007E026F /* HTMLConstructionSite.h */; };
97EF7DFE107E55B700D7C49C /* ScriptControllerBase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 97EF7DFD107E55B700D7C49C /* ScriptControllerBase.cpp */; };
9F0D6B2E121BFEBA006C0288 /* InspectorProfilerAgent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9F0D6B2C121BFEBA006C0288 /* InspectorProfilerAgent.cpp */; };
9F0D6B2F121BFEBA006C0288 /* InspectorProfilerAgent.h in Headers */ = {isa = PBXBuildFile; fileRef = 9F0D6B2D121BFEBA006C0288 /* InspectorProfilerAgent.h */; };
9F6FC1961122E82A00E80196 /* ScriptDebugServer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9F6FC1941122E82A00E80196 /* ScriptDebugServer.cpp */; };
9F6FC1971122E82A00E80196 /* ScriptDebugServer.h in Headers */ = {isa = PBXBuildFile; fileRef = 9F6FC1951122E82A00E80196 /* ScriptDebugServer.h */; settings = {ATTRIBUTES = (Private, ); }; };
9F72304F11184B4100AD0126 /* ScriptProfile.h in Headers */ = {isa = PBXBuildFile; fileRef = 9F72304C11184B4100AD0126 /* ScriptProfile.h */; settings = {ATTRIBUTES = (Private, ); }; };
......@@ -8605,6 +8607,8 @@
97EF560E11E40783007E026F /* HTMLConstructionSite.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLConstructionSite.cpp; sourceTree = "<group>"; };
97EF560F11E40783007E026F /* HTMLConstructionSite.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTMLConstructionSite.h; sourceTree = "<group>"; };
97EF7DFD107E55B700D7C49C /* ScriptControllerBase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScriptControllerBase.cpp; sourceTree = "<group>"; };
9F0D6B2C121BFEBA006C0288 /* InspectorProfilerAgent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InspectorProfilerAgent.cpp; sourceTree = "<group>"; };
9F0D6B2D121BFEBA006C0288 /* InspectorProfilerAgent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorProfilerAgent.h; sourceTree = "<group>"; };
9F6FC1941122E82A00E80196 /* ScriptDebugServer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScriptDebugServer.cpp; sourceTree = "<group>"; };
9F6FC1951122E82A00E80196 /* ScriptDebugServer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScriptDebugServer.h; sourceTree = "<group>"; };
9F72304C11184B4100AD0126 /* ScriptProfile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScriptProfile.h; sourceTree = "<group>"; };
......@@ -11799,6 +11803,8 @@
7A0E770B10C00A8800A0276E /* InspectorFrontendHost.cpp */,
7A0E770C10C00A8800A0276E /* InspectorFrontendHost.h */,
7A0E770D10C00A8800A0276E /* InspectorFrontendHost.idl */,
9F0D6B2C121BFEBA006C0288 /* InspectorProfilerAgent.cpp */,
9F0D6B2D121BFEBA006C0288 /* InspectorProfilerAgent.h */,
41F062000F5F0B6600A07EAC /* InspectorResource.cpp */,
41F061FF0F5F0B6600A07EAC /* InspectorResource.h */,
7AB0B1BE1211A62200A76940 /* InspectorStorageAgent.cpp */,
......@@ -20347,6 +20353,7 @@
2EF1BFF9121CB0CE00C27627 /* FileStreamClient.h in Headers */,
89C0DD7B121F0C69009E17CA /* FileSystemCallbacks.h in Headers */,
CE057FA61220731100A476D5 /* DocumentMarkerController.h in Headers */,
9F0D6B2F121BFEBA006C0288 /* InspectorProfilerAgent.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -22800,6 +22807,7 @@
46A26905121B6B4300C41F3A /* FileWriter.cpp in Sources */,
89C0DD7A121F0C69009E17CA /* FileSystemCallbacks.cpp in Sources */,
CE057FA51220731100A476D5 /* DocumentMarkerController.cpp in Sources */,
9F0D6B2E121BFEBA006C0288 /* InspectorProfilerAgent.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -46,6 +46,11 @@ PassRefPtr<ScriptProfile> ScriptProfiler::stop(ScriptState* state, const String&
return ScriptProfile::create(profile);
}
bool ScriptProfiler::isProfilerAlwaysEnabled()
{
return false;
}
} // namespace WebCore
#endif // ENABLE(JAVASCRIPT_DEBUGGER)
......@@ -41,6 +41,7 @@ public:
static PassRefPtr<ScriptProfile> stop(ScriptState* state, const String& title);
static void takeHeapSnapshot() { }
static long getProfilerLogLines(long, String*) { return 0; }
static bool isProfilerAlwaysEnabled();
};
} // namespace WebCore
......
......@@ -69,4 +69,9 @@ long ScriptProfiler::getProfilerLogLines(long position, String* data)
return position;
}
bool ScriptProfiler::isProfilerAlwaysEnabled()
{
return true;
}
} // namespace WebCore
......@@ -45,6 +45,7 @@ public:
static PassRefPtr<ScriptProfile> stop(ScriptState* state, const String& title);
static void takeHeapSnapshot();
static long getProfilerLogLines(long position, String* data);
static bool isProfilerAlwaysEnabled();
};
} // namespace WebCore
......
......@@ -38,6 +38,11 @@ $typeTransform{"ApplicationCache"} = {
"header" => "InspectorApplicationCacheAgent.h",
"handlerAccessor" => "m_inspectorController->applicationCacheAgent()",
};
$typeTransform{"Profiler"} = {
"forward" => "InspectorProfilerAgent",
"header" => "InspectorProfilerAgent.h",
"handlerAccessor" => "m_inspectorController->profilerAgent()",
};
$typeTransform{"Frontend"} = {
"forward" => "RemoteInspectorFrontend",
"header" => "RemoteInspectorFrontend.h",
......
......@@ -145,14 +145,14 @@ module core {
[handler=Controller] void enableProfiler(in boolean always);
[handler=Controller] void disableProfiler(in boolean always);
[handler=Controller] void startProfiling();
[handler=Controller] void stopProfiling();
[handler=Profiler] void startProfiling();
[handler=Profiler] void stopProfiling();
[handler=Controller] void getProfileHeaders(in long callId, out Array headers);
[handler=Controller] void getProfile(in long callId, in unsigned long uid, out Object profile);
[handler=Profiler] void getProfileHeaders(in long callId, out Array headers);
[handler=Profiler] void getProfile(in long callId, in unsigned long uid, out Object profile);
[handler=Controller] void removeProfile(in unsigned long uid);
[handler=Controller] void clearProfiles();
[handler=Profiler] void removeProfile(in unsigned long uid);
[handler=Profiler] void clearProfiles();
[handler=Backend] void takeHeapSnapshot();
[handler=Backend] void getProfilerLogLines(in long callId, in long inPosition, out long outPosition, out String log);
......
......@@ -63,6 +63,7 @@
#include "InspectorDOMStorageResource.h"
#include "InspectorDatabaseResource.h"
#include "InspectorDebuggerAgent.h"
#include "InspectorProfilerAgent.h"
#include "InspectorResource.h"
#include "InspectorStorageAgent.h"
#include "InspectorTimelineAgent.h"
......@@ -115,8 +116,6 @@ using namespace std;
namespace WebCore {
static const char* const UserInitiatedProfileName = "org.webkit.profiles.user-initiated";
static const char* const CPUProfileType = "CPU";
static const char* const resourceTrackingEnabledSettingName = "resourceTrackingEnabled";
static const char* const debuggerEnabledSettingName = "debuggerEnabled";
static const char* const profilerEnabledSettingName = "profilerEnabled";
......@@ -170,11 +169,7 @@ InspectorController::InspectorController(Page* page, InspectorClient* client)
, m_injectedScriptHost(InjectedScriptHost::create(this))
#if ENABLE(JAVASCRIPT_DEBUGGER)
, m_attachDebuggerWhenShown(false)
, m_profilerEnabled(!WTF_USE_JSC)
, m_recordingUserInitiatedProfile(false)
, m_currentUserInitiatedProfileNumber(-1)
, m_nextUserInitiatedProfileNumber(1)
, m_startProfiling(this, &InspectorController::startUserInitiatedProfiling)
, m_profilerAgent(InspectorProfilerAgent::create(this))
#endif
{
ASSERT_ARG(page, page);
......@@ -504,8 +499,11 @@ void InspectorController::connectFrontend()
String debuggerEnabled = setting(debuggerEnabledSettingName);
if (debuggerEnabled == "true" || m_attachDebuggerWhenShown)
enableDebugger();
String profilerEnabled = setting(profilerEnabledSettingName);
if (profilerEnabled == "true")
}
m_profilerAgent->setRemoteFrontend(m_remoteFrontend.get());
if (!ScriptProfiler::isProfilerAlwaysEnabled()) {
String profilerEnabledSetting = setting(profilerEnabledSettingName);
if (profilerEnabledSetting == "true")
enableProfiler();
}
#endif
......@@ -594,7 +592,8 @@ void InspectorController::disconnectFrontend()
hideHighlight();
#if ENABLE(JAVASCRIPT_DEBUGGER)
stopUserInitiatedProfiling();
m_profilerAgent->setRemoteFrontend(0);
m_profilerAgent->stopUserInitiatedProfiling();
#endif
releaseFrontendLifetimeAgents();
......@@ -638,7 +637,7 @@ void InspectorController::populateScriptObjects()
m_remoteFrontend->monitoringXHRWasEnabled();
#if ENABLE(JAVASCRIPT_DEBUGGER)
if (m_profilerEnabled)
if (m_profilerAgent->enabled())
m_remoteFrontend->profilerWasEnabled();
#endif
......@@ -745,11 +744,7 @@ void InspectorController::didCommitLoad(DocumentLoader* loader)
m_debuggerAgent->clearForPageNavigation();
#endif
#if ENABLE(JAVASCRIPT_DEBUGGER) && USE(JSC)
m_profiles.clear();
m_currentUserInitiatedProfileNumber = 1;
m_nextUserInitiatedProfileNumber = 1;
if (m_remoteFrontend)
m_remoteFrontend->resetProfilesPanel();
m_profilerAgent->resetState();
#endif
// unbindAllResources should be called before database and DOM storage
// resources are cleared so that it has a chance to unbind them.
......@@ -1458,176 +1453,61 @@ void InspectorController::addProfile(PassRefPtr<ScriptProfile> prpProfile, unsig
{
if (!enabled())
return;
RefPtr<ScriptProfile> profile = prpProfile;
m_profiles.add(profile->uid(), profile);
if (m_remoteFrontend) {
m_remoteFrontend->addProfileHeader(createProfileHeader(*profile));
}
addProfileFinishedMessageToConsole(profile, lineNumber, sourceURL);
m_profilerAgent->addProfile(prpProfile, lineNumber, sourceURL);
}
void InspectorController::addProfileFinishedMessageToConsole(PassRefPtr<ScriptProfile> prpProfile, unsigned lineNumber, const String& sourceURL)
{
RefPtr<ScriptProfile> profile = prpProfile;
String title = profile->title();
String message = String::format("Profile \"webkit-profile://%s/%s#%d\" finished.", CPUProfileType, encodeWithURLEscapeSequences(title).utf8().data(), profile->uid());
addMessageToConsole(JSMessageSource, LogMessageType, LogMessageLevel, message, lineNumber, sourceURL);
m_profilerAgent->addProfileFinishedMessageToConsole(prpProfile, lineNumber, sourceURL);
}
void InspectorController::addStartProfilingMessageToConsole(const String& title, unsigned lineNumber, const String& sourceURL)
{
String message = String::format("Profile \"webkit-profile://%s/%s#0\" started.", CPUProfileType, encodeWithURLEscapeSequences(title).utf8().data());
addMessageToConsole(JSMessageSource, LogMessageType, LogMessageLevel, message, lineNumber, sourceURL);
}
void InspectorController::removeProfile(unsigned uid)
{
if (!enabled())
return;
if (m_profiles.contains(uid))
m_profiles.remove(uid);
}
void InspectorController::clearProfiles()
{
if (!enabled())
return;
m_profiles.clear();
m_currentUserInitiatedProfileNumber = 1;
m_nextUserInitiatedProfileNumber = 1;
m_profilerAgent->addStartProfilingMessageToConsole(title, lineNumber, sourceURL);
}
void InspectorController::getProfileHeaders(RefPtr<InspectorArray>* headers)
{
ProfilesMap::iterator profilesEnd = m_profiles.end();
for (ProfilesMap::iterator it = m_profiles.begin(); it != profilesEnd; ++it)
(*headers)->pushObject(createProfileHeader(*it->second));
}
void InspectorController::getProfile(unsigned uid, RefPtr<InspectorObject>* profileObject)
bool InspectorController::isRecordingUserInitiatedProfile() const
{
ProfilesMap::iterator it = m_profiles.find(uid);
if (it != m_profiles.end()) {
*profileObject = createProfileHeader(*it->second);
(*profileObject)->setObject("head", it->second->buildInspectorObjectForHead());
}
}
PassRefPtr<InspectorObject> InspectorController::createProfileHeader(const ScriptProfile& profile)
{
RefPtr<InspectorObject> header = InspectorObject::create();
header->setString("title", profile.title());
header->setNumber("uid", profile.uid());
header->setString("typeId", String(CPUProfileType));
return header;
}
String InspectorController::getCurrentUserInitiatedProfileName(bool incrementProfileNumber = false)
{
if (incrementProfileNumber)
m_currentUserInitiatedProfileNumber = m_nextUserInitiatedProfileNumber++;
return String::format("%s.%d", UserInitiatedProfileName, m_currentUserInitiatedProfileNumber);
return m_profilerAgent->isRecordingUserInitiatedProfile();
}
void InspectorController::startUserInitiatedProfilingSoon()
String InspectorController::getCurrentUserInitiatedProfileName(bool incrementProfileNumber)
{
m_startProfiling.startOneShot(0);
return m_profilerAgent->getCurrentUserInitiatedProfileName(incrementProfileNumber);
}
void InspectorController::startUserInitiatedProfiling(Timer<InspectorController>*)
void InspectorController::startUserInitiatedProfiling()
{
if (!enabled())
return;
if (!profilerEnabled()) {
enableProfiler(false, true);
ScriptDebugServer::shared().recompileAllJSFunctions();
}
m_recordingUserInitiatedProfile = true;
String title = getCurrentUserInitiatedProfileName(true);
#if USE(JSC)
JSC::ExecState* scriptState = toJSDOMWindow(m_inspectedPage->mainFrame(), debuggerWorld())->globalExec();
#else
ScriptState* scriptState = 0;
#endif
ScriptProfiler::start(scriptState, title);
addStartProfilingMessageToConsole(title, 0, String());
toggleRecordButton(true);
m_profilerAgent->startUserInitiatedProfiling();
}
void InspectorController::stopUserInitiatedProfiling()
{
if (!enabled())
return;
m_recordingUserInitiatedProfile = false;
String title = getCurrentUserInitiatedProfileName();
#if USE(JSC)
JSC::ExecState* scriptState = toJSDOMWindow(m_inspectedPage->mainFrame(), debuggerWorld())->globalExec();
#else
// Use null script state to avoid filtering by context security token.
// All functions from all iframes should be visible from Inspector UI.
ScriptState* scriptState = 0;
#endif
RefPtr<ScriptProfile> profile = ScriptProfiler::stop(scriptState, title);
if (profile)
addProfile(profile, 0, String());
toggleRecordButton(false);
m_profilerAgent->stopUserInitiatedProfiling();
}
void InspectorController::toggleRecordButton(bool isProfiling)
bool InspectorController::profilerEnabled() const
{
if (!m_remoteFrontend)
return;
m_remoteFrontend->setRecordingProfile(isProfiling);
return enabled() && m_profilerAgent->enabled();
}
void InspectorController::enableProfiler(bool always, bool skipRecompile)
{
if (always)
setSetting(profilerEnabledSettingName, "true");
if (m_profilerEnabled)
return;
m_profilerEnabled = true;
if (!skipRecompile)
ScriptDebugServer::shared().recompileAllJSFunctionsSoon();
if (m_remoteFrontend)
m_remoteFrontend->profilerWasEnabled();
m_profilerAgent->enable(skipRecompile);
}
void InspectorController::disableProfiler(bool always)
{
if (always)
setSetting(profilerEnabledSettingName, "false");
if (!m_profilerEnabled)
return;
m_profilerEnabled = false;
ScriptDebugServer::shared().recompileAllJSFunctionsSoon();
if (m_remoteFrontend)
m_remoteFrontend->profilerWasDisabled();
m_profilerAgent->disable();
}
#endif
......
......@@ -33,9 +33,7 @@
#include "Cookie.h"
#include "InspectorDOMAgent.h"
#include "PlatformString.h"
#include "ScriptProfile.h"
#include "ScriptState.h"
#include "Timer.h"
#include <wtf/HashMap.h>
#include <wtf/HashSet.h>
#include <wtf/ListHashSet.h>
......@@ -65,6 +63,7 @@ class InspectorDatabaseResource;
class InspectorDebuggerAgent;
class InspectorFrontendClient;
class InspectorObject;
class InspectorProfilerAgent;
class InspectorResource;
class InspectorStorageAgent;
class InspectorTimelineAgent;
......@@ -78,6 +77,7 @@ class ResourceRequest;
class ResourceResponse;
class ResourceError;
class ScriptCallStack;
class ScriptProfile;
class ScriptString;
class SharedBuffer;
class Storage;
......@@ -228,20 +228,14 @@ public:
void addProfile(PassRefPtr<ScriptProfile>, unsigned lineNumber, const String& sourceURL);
void addProfileFinishedMessageToConsole(PassRefPtr<ScriptProfile>, unsigned lineNumber, const String& sourceURL);
void addStartProfilingMessageToConsole(const String& title, unsigned lineNumber, const String& sourceURL);
void removeProfile(unsigned);
void clearProfiles();
bool isRecordingUserInitiatedProfile() const { return m_recordingUserInitiatedProfile; }
String getCurrentUserInitiatedProfileName(bool incrementProfileNumber);
void startUserInitiatedProfiling(Timer<InspectorController>* = 0);
bool isRecordingUserInitiatedProfile() const;
String getCurrentUserInitiatedProfileName(bool incrementProfileNumber = false);
void startUserInitiatedProfiling();
void stopUserInitiatedProfiling();
void startProfiling() { startUserInitiatedProfiling(); }
void stopProfiling() { stopUserInitiatedProfiling(); }
void enableProfiler(bool always = false, bool skipRecompile = false);
void disableProfiler(bool always = false);
bool profilerEnabled() const { return enabled() && m_profilerEnabled; }
bool profilerEnabled() const;
InspectorProfilerAgent* profilerAgent() const { return m_profilerAgent.get(); }
void enableDebugger();
void disableDebugger(bool always = false);
......@@ -283,14 +277,9 @@ private:
void releaseFrontendLifetimeAgents();
#if ENABLE(JAVASCRIPT_DEBUGGER)
typedef HashMap<unsigned int, RefPtr<ScriptProfile> > ProfilesMap;
void startUserInitiatedProfilingSoon();
void toggleRecordButton(bool);
void enableDebuggerFromFrontend(bool always);
void getProfileHeaders(RefPtr<InspectorArray>* headers);
void getProfile(unsigned uid, RefPtr<InspectorObject>* profileObject);
PassRefPtr<InspectorObject> createProfileHeader(const ScriptProfile& profile);
#endif
#if ENABLE(DATABASE)
void selectDatabase(Database* database);
......@@ -380,12 +369,7 @@ private:
bool m_attachDebuggerWhenShown;
OwnPtr<InspectorDebuggerAgent> m_debuggerAgent;
bool m_profilerEnabled;
bool m_recordingUserInitiatedProfile;
int m_currentUserInitiatedProfileNumber;
unsigned m_nextUserInitiatedProfileNumber;
Timer<InspectorController> m_startProfiling;
ProfilesMap m_profiles;
OwnPtr<InspectorProfilerAgent> m_profilerAgent;
#endif
#if ENABLE(WORKERS)
typedef HashMap<intptr_t, RefPtr<InspectorWorkerResource> > WorkersMap;
......
/*
* Copyright (C) 2010 Apple Inc. All rights reserved.
* Copyright (C) 2010 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:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. 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.
* 3. Neither the name of Apple Computer, Inc. ("Apple") 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 APPLE AND ITS 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 APPLE OR ITS 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,