Diff
Modified: trunk/Source/WebCore/ChangeLog (109213 => 109214)
--- trunk/Source/WebCore/ChangeLog 2012-02-29 15:36:29 UTC (rev 109213)
+++ trunk/Source/WebCore/ChangeLog 2012-02-29 15:42:10 UTC (rev 109214)
@@ -1,3 +1,62 @@
+2012-02-29 Yury Semikhatsky <yu...@chromium.org>
+
+ Web Inspector: enable Profiles panel for workers
+ https://bugs.webkit.org/show_bug.cgi?id=79908
+
+ Introduced worker profiler agent. Enabled script profiling for
+ workers.
+
+ Reviewed by Pavel Feldman.
+
+ * bindings/js/ScriptProfiler.cpp:
+ (WebCore::ScriptProfiler::startForPage):
+ (WebCore):
+ (WebCore::ScriptProfiler::startForWorkerContext):
+ (WebCore::ScriptProfiler::stopForPage):
+ (WebCore::ScriptProfiler::stopForWorkerContext):
+ * bindings/js/ScriptProfiler.h:
+ (WebCore):
+ (ScriptProfiler):
+ * bindings/v8/ScriptProfiler.cpp:
+ (WebCore::ScriptProfiler::startForPage):
+ (WebCore):
+ (WebCore::ScriptProfiler::startForWorkerContext):
+ (WebCore::ScriptProfiler::stopForPage):
+ (WebCore::ScriptProfiler::stopForWorkerContext):
+ * bindings/v8/ScriptProfiler.h:
+ (WebCore):
+ (ScriptProfiler):
+ * inspector/InspectorProfilerAgent.cpp:
+ (WebCore):
+ (PageProfilerAgent):
+ (WebCore::PageProfilerAgent::PageProfilerAgent):
+ (WebCore::PageProfilerAgent::~PageProfilerAgent):
+ (WebCore::PageProfilerAgent::startProfiling):
+ (WebCore::PageProfilerAgent::stopProfiling):
+ (WebCore::InspectorProfilerAgent::create):
+ (WorkerProfilerAgent):
+ (WebCore::WorkerProfilerAgent::WorkerProfilerAgent):
+ (WebCore::WorkerProfilerAgent::~WorkerProfilerAgent):
+ (WebCore::WorkerProfilerAgent::startProfiling):
+ (WebCore::WorkerProfilerAgent::stopProfiling):
+ (WebCore::InspectorProfilerAgent::InspectorProfilerAgent):
+ (WebCore::InspectorProfilerAgent::start):
+ (WebCore::InspectorProfilerAgent::stop):
+ * inspector/InspectorProfilerAgent.h:
+ (WebCore):
+ (InspectorProfilerAgent):
+ * inspector/WorkerInspectorController.cpp:
+ (WebCore::WorkerInspectorController::WorkerInspectorController):
+ (WebCore::WorkerInspectorController::connectFrontend):
+ (WebCore::WorkerInspectorController::disconnectFrontend):
+ (WebCore::WorkerInspectorController::restoreInspectorStateFromCookie):
+ * inspector/WorkerInspectorController.h:
+ (WebCore):
+ (WorkerInspectorController):
+ * inspector/front-end/ProfilesPanel.js:
+ * inspector/front-end/inspector.js:
+ (WebInspector._createPanels):
+
2012-02-29 Alexander Pavlov <apav...@chromium.org>
Web Inspector: Clicking relative links fails when query string contains a slash
Modified: trunk/Source/WebCore/bindings/js/ScriptProfiler.cpp (109213 => 109214)
--- trunk/Source/WebCore/bindings/js/ScriptProfiler.cpp 2012-02-29 15:36:29 UTC (rev 109213)
+++ trunk/Source/WebCore/bindings/js/ScriptProfiler.cpp 2012-02-29 15:42:10 UTC (rev 109214)
@@ -30,9 +30,13 @@
#include "ScriptProfiler.h"
+#include "Frame.h"
#include "GCController.h"
#include "JSDOMBinding.h"
+#include "JSDOMWindow.h"
+#include "Page.h"
#include "ScriptObject.h"
+#include "ScriptState.h"
#include <profiler/Profiler.h>
namespace WebCore {
@@ -52,12 +56,38 @@
JSC::Profiler::profiler()->startProfiling(state, stringToUString(title));
}
+void ScriptProfiler::startForPage(Page* inspectedPage, const String& title)
+{
+ JSC::ExecState* scriptState = toJSDOMWindow(inspectedPage->mainFrame(), debuggerWorld())->globalExec();
+ start(scriptState, title);
+}
+
+#if ENABLE(WORKERS)
+void ScriptProfiler::startForWorkerContext(WorkerContext* context, const String& title)
+{
+ start(scriptStateFromWorkerContext(context), title);
+}
+#endif
+
PassRefPtr<ScriptProfile> ScriptProfiler::stop(ScriptState* state, const String& title)
{
RefPtr<JSC::Profile> profile = "" stringToUString(title));
return ScriptProfile::create(profile);
}
+PassRefPtr<ScriptProfile> ScriptProfiler::stopForPage(Page* inspectedPage, const String& title)
+{
+ JSC::ExecState* scriptState = toJSDOMWindow(inspectedPage->mainFrame(), debuggerWorld())->globalExec();
+ return stop(scriptState, title);
+}
+
+#if ENABLE(WORKERS)
+PassRefPtr<ScriptProfile> ScriptProfiler::stopForWorkerContext(WorkerContext* context, const String& title)
+{
+ return stop(scriptStateFromWorkerContext(context), title);
+}
+#endif
+
} // namespace WebCore
#endif // ENABLE(_javascript__DEBUGGER)
Modified: trunk/Source/WebCore/bindings/js/ScriptProfiler.h (109213 => 109214)
--- trunk/Source/WebCore/bindings/js/ScriptProfiler.h 2012-02-29 15:36:29 UTC (rev 109213)
+++ trunk/Source/WebCore/bindings/js/ScriptProfiler.h 2012-02-29 15:42:10 UTC (rev 109214)
@@ -37,7 +37,9 @@
namespace WebCore {
class DOMWrapperVisitor;
+class Page;
class ScriptObject;
+class WorkerContext;
class ScriptProfiler {
WTF_MAKE_NONCOPYABLE(ScriptProfiler);
@@ -54,7 +56,15 @@
static void collectGarbage();
static ScriptObject objectByHeapObjectId(unsigned id);
static void start(ScriptState* state, const String& title);
+ static void startForPage(Page*, const String& title);
+#if ENABLE(WORKERS)
+ static void startForWorkerContext(WorkerContext*, const String& title);
+#endif
static PassRefPtr<ScriptProfile> stop(ScriptState* state, const String& title);
+ static PassRefPtr<ScriptProfile> stopForPage(Page*, const String& title);
+#if ENABLE(WORKERS)
+ static PassRefPtr<ScriptProfile> stopForWorkerContext(WorkerContext*, const String& title);
+#endif
static PassRefPtr<ScriptHeapSnapshot> takeHeapSnapshot(const String&, HeapSnapshotProgress*) { return 0; }
static bool causesRecompilation() { return true; }
static bool isSampling() { return false; }
Modified: trunk/Source/WebCore/bindings/v8/ScriptProfiler.cpp (109213 => 109214)
--- trunk/Source/WebCore/bindings/v8/ScriptProfiler.cpp 2012-02-29 15:36:29 UTC (rev 109213)
+++ trunk/Source/WebCore/bindings/v8/ScriptProfiler.cpp 2012-02-29 15:42:10 UTC (rev 109214)
@@ -49,6 +49,18 @@
v8::CpuProfiler::StartProfiling(v8String(title));
}
+void ScriptProfiler::startForPage(Page*, const String& title)
+{
+ return start(0, title);
+}
+
+#if ENABLE(WORKERS)
+void ScriptProfiler::startForWorkerContext(WorkerContext*, const String& title)
+{
+ return start(0, title);
+}
+#endif
+
PassRefPtr<ScriptProfile> ScriptProfiler::stop(ScriptState* state, const String& title)
{
v8::HandleScope hs;
@@ -58,6 +70,20 @@
return profile ? ScriptProfile::create(profile) : 0;
}
+PassRefPtr<ScriptProfile> ScriptProfiler::stopForPage(Page*, const String& title)
+{
+ // Use null script state to avoid filtering by context security token.
+ // All functions from all iframes should be visible from Inspector UI.
+ return stop(0, title);
+}
+
+#if ENABLE(WORKERS)
+PassRefPtr<ScriptProfile> ScriptProfiler::stopForWorkerContext(WorkerContext*, const String& title)
+{
+ return stop(0, title);
+}
+#endif
+
void ScriptProfiler::collectGarbage()
{
v8::V8::LowMemoryNotification();
Modified: trunk/Source/WebCore/bindings/v8/ScriptProfiler.h (109213 => 109214)
--- trunk/Source/WebCore/bindings/v8/ScriptProfiler.h 2012-02-29 15:36:29 UTC (rev 109213)
+++ trunk/Source/WebCore/bindings/v8/ScriptProfiler.h 2012-02-29 15:42:10 UTC (rev 109214)
@@ -41,7 +41,9 @@
namespace WebCore {
class DOMWrapperVisitor;
+class Page;
class ScriptObject;
+class WorkerContext;
class ScriptProfiler {
WTF_MAKE_NONCOPYABLE(ScriptProfiler);
@@ -58,7 +60,15 @@
static void collectGarbage();
static ScriptObject objectByHeapObjectId(unsigned id);
static void start(ScriptState* state, const String& title);
+ static void startForPage(Page*, const String& title);
+#if ENABLE(WORKERS)
+ static void startForWorkerContext(WorkerContext*, const String& title);
+#endif
static PassRefPtr<ScriptProfile> stop(ScriptState* state, const String& title);
+ static PassRefPtr<ScriptProfile> stopForPage(Page*, const String& title);
+#if ENABLE(WORKERS)
+ static PassRefPtr<ScriptProfile> stopForWorkerContext(WorkerContext*, const String& title);
+#endif
static PassRefPtr<ScriptHeapSnapshot> takeHeapSnapshot(const String& title, HeapSnapshotProgress*);
static bool causesRecompilation() { return false; }
static bool isSampling() { return true; }
Modified: trunk/Source/WebCore/inspector/InspectorProfilerAgent.cpp (109213 => 109214)
--- trunk/Source/WebCore/inspector/InspectorProfilerAgent.cpp 2012-02-29 15:36:29 UTC (rev 109213)
+++ trunk/Source/WebCore/inspector/InspectorProfilerAgent.cpp 2012-02-29 15:42:10 UTC (rev 109214)
@@ -50,10 +50,6 @@
#include <wtf/OwnPtr.h>
#include <wtf/text/StringConcatenate.h>
-#if USE(JSC)
-#include "JSDOMWindow.h"
-#endif
-
namespace WebCore {
namespace ProfilerAgentState {
@@ -65,15 +61,63 @@
static const char* const CPUProfileType = "CPU";
static const char* const HeapProfileType = "HEAP";
+
+class PageProfilerAgent : public InspectorProfilerAgent {
+public:
+ PageProfilerAgent(InstrumentingAgents* instrumentingAgents, InspectorConsoleAgent* consoleAgent, Page* inspectedPage, InspectorState* state, InjectedScriptManager* injectedScriptManager)
+ : InspectorProfilerAgent(instrumentingAgents, consoleAgent, state, injectedScriptManager), m_inspectedPage(inspectedPage) { }
+ virtual ~PageProfilerAgent() { }
+
+private:
+ virtual void startProfiling(const String& title)
+ {
+ ScriptProfiler::startForPage(m_inspectedPage, title);
+ }
+
+ virtual PassRefPtr<ScriptProfile> stopProfiling(const String& title)
+ {
+ return ScriptProfiler::stopForPage(m_inspectedPage, title);
+ }
+
+ Page* m_inspectedPage;
+};
+
PassOwnPtr<InspectorProfilerAgent> InspectorProfilerAgent::create(InstrumentingAgents* instrumentingAgents, InspectorConsoleAgent* consoleAgent, Page* inspectedPage, InspectorState* inspectorState, InjectedScriptManager* injectedScriptManager)
{
- return adoptPtr(new InspectorProfilerAgent(instrumentingAgents, consoleAgent, inspectedPage, inspectorState, injectedScriptManager));
+ return adoptPtr(new PageProfilerAgent(instrumentingAgents, consoleAgent, inspectedPage, inspectorState, injectedScriptManager));
}
-InspectorProfilerAgent::InspectorProfilerAgent(InstrumentingAgents* instrumentingAgents, InspectorConsoleAgent* consoleAgent, Page* inspectedPage, InspectorState* inspectorState, InjectedScriptManager* injectedScriptManager)
+
+#if ENABLE(WORKERS)
+class WorkerProfilerAgent : public InspectorProfilerAgent {
+public:
+ WorkerProfilerAgent(InstrumentingAgents* instrumentingAgents, InspectorConsoleAgent* consoleAgent, WorkerContext* workerContext, InspectorState* state, InjectedScriptManager* injectedScriptManager)
+ : InspectorProfilerAgent(instrumentingAgents, consoleAgent, state, injectedScriptManager), m_workerContext(workerContext) { }
+ virtual ~WorkerProfilerAgent() { }
+
+private:
+ virtual void startProfiling(const String& title)
+ {
+ ScriptProfiler::startForWorkerContext(m_workerContext, title);
+ }
+
+ virtual PassRefPtr<ScriptProfile> stopProfiling(const String& title)
+ {
+ return ScriptProfiler::stopForWorkerContext(m_workerContext, title);
+ }
+
+ WorkerContext* m_workerContext;
+};
+
+PassOwnPtr<InspectorProfilerAgent> InspectorProfilerAgent::create(InstrumentingAgents* instrumentingAgents, InspectorConsoleAgent* consoleAgent, WorkerContext* workerContext, InspectorState* inspectorState, InjectedScriptManager* injectedScriptManager)
+{
+ return adoptPtr(new WorkerProfilerAgent(instrumentingAgents, consoleAgent, workerContext, inspectorState, injectedScriptManager));
+}
+#endif
+
+InspectorProfilerAgent::InspectorProfilerAgent(InstrumentingAgents* instrumentingAgents, InspectorConsoleAgent* consoleAgent, InspectorState* inspectorState, InjectedScriptManager* injectedScriptManager)
: InspectorBaseAgent<InspectorProfilerAgent>("Profiler", instrumentingAgents, inspectorState)
, m_consoleAgent(consoleAgent)
- , m_inspectedPage(inspectedPage)
, m_injectedScriptManager(injectedScriptManager)
, m_frontend(0)
, m_enabled(false)
@@ -318,12 +362,7 @@
}
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);
+ startProfiling(title);
addStartProfilingMessageToConsole(title, 0, String());
toggleRecordButton(true);
m_state->setBoolean(ProfilerAgentState::userInitiatedProfiling, true);
@@ -335,14 +374,7 @@
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 = "" title);
+ RefPtr<ScriptProfile> profile = ""
if (profile)
addProfile(profile, 0, String());
toggleRecordButton(false);
Modified: trunk/Source/WebCore/inspector/InspectorProfilerAgent.h (109213 => 109214)
--- trunk/Source/WebCore/inspector/InspectorProfilerAgent.h 2012-02-29 15:36:29 UTC (rev 109213)
+++ trunk/Source/WebCore/inspector/InspectorProfilerAgent.h 2012-02-29 15:42:10 UTC (rev 109214)
@@ -52,6 +52,7 @@
class Page;
class ScriptHeapSnapshot;
class ScriptProfile;
+class WorkerContext;
typedef String ErrorString;
@@ -59,6 +60,9 @@
WTF_MAKE_NONCOPYABLE(InspectorProfilerAgent); WTF_MAKE_FAST_ALLOCATED;
public:
static PassOwnPtr<InspectorProfilerAgent> create(InstrumentingAgents*, InspectorConsoleAgent*, Page*, InspectorState*, InjectedScriptManager*);
+#if ENABLE(WORKERS)
+ static PassOwnPtr<InspectorProfilerAgent> create(InstrumentingAgents*, InspectorConsoleAgent*, WorkerContext*, InspectorState*, InjectedScriptManager*);
+#endif
virtual ~InspectorProfilerAgent();
void addProfile(PassRefPtr<ScriptProfile> prpProfile, unsigned lineNumber, const String& sourceURL);
@@ -94,6 +98,11 @@
virtual void getObjectByHeapObjectId(ErrorString*, int id, const String* objectGroup, RefPtr<InspectorObject>& result);
+protected:
+ InspectorProfilerAgent(InstrumentingAgents*, InspectorConsoleAgent*, InspectorState*, InjectedScriptManager*);
+ virtual void startProfiling(const String& title) = 0;
+ virtual PassRefPtr<ScriptProfile> stopProfiling(const String& title) = 0;
+
private:
typedef HashMap<unsigned int, RefPtr<ScriptProfile> > ProfilesMap;
typedef HashMap<unsigned int, RefPtr<ScriptHeapSnapshot> > HeapSnapshotsMap;
@@ -101,12 +110,10 @@
void resetFrontendProfiles();
void restoreEnablement();
- InspectorProfilerAgent(InstrumentingAgents*, InspectorConsoleAgent*, Page*, InspectorState*, InjectedScriptManager*);
PassRefPtr<InspectorObject> createProfileHeader(const ScriptProfile& profile);
PassRefPtr<InspectorObject> createSnapshotHeader(const ScriptHeapSnapshot& snapshot);
InspectorConsoleAgent* m_consoleAgent;
- Page* m_inspectedPage;
InjectedScriptManager* m_injectedScriptManager;
InspectorFrontend::Profiler* m_frontend;
bool m_enabled;
Modified: trunk/Source/WebCore/inspector/WorkerInspectorController.cpp (109213 => 109214)
--- trunk/Source/WebCore/inspector/WorkerInspectorController.cpp 2012-02-29 15:36:29 UTC (rev 109213)
+++ trunk/Source/WebCore/inspector/WorkerInspectorController.cpp 2012-02-29 15:42:10 UTC (rev 109214)
@@ -41,6 +41,7 @@
#include "InspectorConsoleAgent.h"
#include "InspectorFrontend.h"
#include "InspectorFrontendChannel.h"
+#include "InspectorProfilerAgent.h"
#include "InspectorState.h"
#include "InspectorStateClient.h"
#include "InstrumentingAgents.h"
@@ -93,11 +94,13 @@
, m_injectedScriptManager(InjectedScriptManager::createForWorker())
{
+ m_runtimeAgent = WorkerRuntimeAgent::create(m_instrumentingAgents.get(), m_state.get(), m_injectedScriptManager.get(), workerContext);
+ m_consoleAgent = WorkerConsoleAgent::create(m_instrumentingAgents.get(), m_state.get(), m_injectedScriptManager.get());
+
#if ENABLE(_javascript__DEBUGGER)
m_debuggerAgent = WorkerDebuggerAgent::create(m_instrumentingAgents.get(), m_state.get(), workerContext, m_injectedScriptManager.get());
+ m_profilerAgent = InspectorProfilerAgent::create(m_instrumentingAgents.get(), m_consoleAgent.get(), workerContext, m_state.get(), m_injectedScriptManager.get());
#endif
- m_runtimeAgent = WorkerRuntimeAgent::create(m_instrumentingAgents.get(), m_state.get(), m_injectedScriptManager.get(), workerContext);
- m_consoleAgent = WorkerConsoleAgent::create(m_instrumentingAgents.get(), m_state.get(), m_injectedScriptManager.get());
m_injectedScriptManager->injectedScriptHost()->init(0
, 0
@@ -127,11 +130,13 @@
m_consoleAgent->registerInDispatcher(m_backendDispatcher.get());
#if ENABLE(_javascript__DEBUGGER)
m_debuggerAgent->registerInDispatcher(m_backendDispatcher.get());
+ m_profilerAgent->registerInDispatcher(m_backendDispatcher.get());
#endif
m_runtimeAgent->registerInDispatcher(m_backendDispatcher.get());
#if ENABLE(_javascript__DEBUGGER)
m_debuggerAgent->setFrontend(m_frontend.get());
+ m_profilerAgent->setFrontend(m_frontend.get());
#endif
m_consoleAgent->setFrontend(m_frontend.get());
}
@@ -147,6 +152,7 @@
m_state->mute();
#if ENABLE(_javascript__DEBUGGER)
m_debuggerAgent->clearFrontend();
+ m_profilerAgent->clearFrontend();
#endif
m_consoleAgent->clearFrontend();
@@ -162,6 +168,7 @@
#if ENABLE(_javascript__DEBUGGER)
m_debuggerAgent->restore();
+ m_profilerAgent->restore();
#endif
m_consoleAgent->restore();
}
Modified: trunk/Source/WebCore/inspector/WorkerInspectorController.h (109213 => 109214)
--- trunk/Source/WebCore/inspector/WorkerInspectorController.h 2012-02-29 15:36:29 UTC (rev 109213)
+++ trunk/Source/WebCore/inspector/WorkerInspectorController.h 2012-02-29 15:42:10 UTC (rev 109214)
@@ -51,6 +51,7 @@
class InspectorFrontendChannel;
class InspectorConsoleAgent;
class InspectorInstrumentation;
+class InspectorProfilerAgent;
class InspectorRuntimeAgent;
class InspectorState;
class InspectorStateClient;
@@ -83,6 +84,7 @@
OwnPtr<InjectedScriptManager> m_injectedScriptManager;
#if ENABLE(_javascript__DEBUGGER)
OwnPtr<InspectorDebuggerAgent> m_debuggerAgent;
+ OwnPtr<InspectorProfilerAgent> m_profilerAgent;
#endif
OwnPtr<InspectorRuntimeAgent> m_runtimeAgent;
OwnPtr<InspectorConsoleAgent> m_consoleAgent;
Modified: trunk/Source/WebCore/inspector/front-end/ProfilesPanel.js (109213 => 109214)
--- trunk/Source/WebCore/inspector/front-end/ProfilesPanel.js 2012-02-29 15:36:29 UTC (rev 109213)
+++ trunk/Source/WebCore/inspector/front-end/ProfilesPanel.js 2012-02-29 15:42:10 UTC (rev 109214)
@@ -142,7 +142,8 @@
this._launcherView.setUpEventListeners();
this._registerProfileType(new WebInspector.CPUProfileType());
- this._registerProfileType(new WebInspector.CSSSelectorProfileType());
+ if (!WebInspector.WorkerManager.isWorkerFrontend())
+ this._registerProfileType(new WebInspector.CSSSelectorProfileType());
if (Capabilities.heapProfilerPresent)
this._registerProfileType(new WebInspector.DetailedHeapshotProfileType());
Modified: trunk/Source/WebCore/inspector/front-end/inspector.js (109213 => 109214)
--- trunk/Source/WebCore/inspector/front-end/inspector.js 2012-02-29 15:36:29 UTC (rev 109213)
+++ trunk/Source/WebCore/inspector/front-end/inspector.js 2012-02-29 15:42:10 UTC (rev 109214)
@@ -39,6 +39,7 @@
if (WebInspector.WorkerManager.isWorkerFrontend()) {
this.panels.scripts = new WebInspector.ScriptsPanel(this.debuggerPresentationModel);
+ this.panels.profiles = new WebInspector.ProfilesPanel();
this.panels.console = new WebInspector.ConsolePanel();
return;
}