Skip to content

Commit

Permalink
DevTools: use InspectorClient methods to enable/disable tracing
Browse files Browse the repository at this point in the history
Instead of sending Tracing.started/Tracing.stopped events which are intercepted in the browser explicit API is used for enabling/disabling trace event recording.

BUG=398787

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

git-svn-id: svn://svn.chromium.org/blink/trunk@181029 bbb929c8-8fbe-4397-9dbb-9b2b20218538
  • Loading branch information
yury-s committed Aug 28, 2014
1 parent e1fb4e1 commit 2cda1a2
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Tests the Timeline API instrumentation of a SendRequest, ReceiveResponse etc.

FunctionCall
FunctionCall
ResourceSendRequest
FunctionCall
ResourceReceiveResponse
ResourceReceivedData
ResourceFinish
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ Test that checks location resolving mechanics for TimerInstall TimerRemove and F

It expects two FunctionCall for InjectedScript, two TimerInstall events, two FunctionCall events and one TimerRemove event to be logged with performActions.js script name and some line number.

details.textContent for FunctionCall event: 'InjectedScript:1'
details.textContent for FunctionCall event: 'InjectedScript:1'
details.textContent for TimerInstall event: 'performActions.js:3'
details.textContent for TimerInstall event: 'performActions.js:4'
details.textContent for FunctionCall event: 'InjectedScript:1'
details.textContent for FunctionCall event: 'performActions.js:7'
details.textContent for FunctionCall event: 'performActions.js:7'
details.textContent for TimerRemove event: 'performActions.js:11'
Expand Down
2 changes: 1 addition & 1 deletion LayoutTests/inspector/tracing/timeline-timer-expected.txt
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ TimerRemove Properties:
}
FunctionCall Properties:
{
children : <object>
data : {
frame : <string>
scriptId : <string>
Expand All @@ -98,7 +99,6 @@ FunctionCall Properties:
}
FunctionCall Properties:
{
children : <object>
data : {
frame : <string>
scriptId : <string>
Expand Down
3 changes: 3 additions & 0 deletions Source/core/inspector/InspectorTracingAgent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ void InspectorTracingAgent::innerStart(const String& categoryFilter, bool fromCo
m_state->setBoolean(TracingAgentState::tracingStarted, true);
m_client->enableTracing(categoryFilter);
emitMetadataEvents();
// FIXME(398787): remove once Tracing.started event is sent from browser.
m_frontend->started();
}

Expand Down Expand Up @@ -107,6 +108,8 @@ void InspectorTracingAgent::consoleTimelineEnd(const String& title)

void InspectorTracingAgent::notifyTracingStopped()
{
m_client->disableTracing();
// FIXME(398787): remove once disableTracing stops tracing in the browser.
m_frontend->stopped();
m_workerAgent->setTracingSessionId(String());
}
Expand Down
14 changes: 12 additions & 2 deletions Source/devtools/front_end/sdk/TracingModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,18 +125,22 @@ WebInspector.TracingModel.prototype = {
start: function(categoryFilter, options, callback)
{
WebInspector.profilingLock().acquire();
this._shouldReleaseLock = true;
this.reset();
var bufferUsageReportingIntervalMs = 500;
TracingAgent.start(categoryFilter, options, bufferUsageReportingIntervalMs, callback);
this._active = true;
this._tracingStarted();
},

stop: function()
{
if (!this._active)
return;
TracingAgent.end(this._onStop.bind(this));
WebInspector.profilingLock().release();
if (this._shouldReleaseLock) {
this._shouldReleaseLock = false;
WebInspector.profilingLock().release();
}
},

/**
Expand Down Expand Up @@ -170,6 +174,7 @@ WebInspector.TracingModel.prototype = {
*/
_eventsCollected: function(events)
{
this._onStop();
for (var i = 0; i < events.length; ++i) {
this._addEvent(events[i]);
this._rawEvents.push(events[i]);
Expand All @@ -185,6 +190,9 @@ WebInspector.TracingModel.prototype = {

_tracingStarted: function()
{
// FIXME(398787): remove once Tracing.started event is sent from browser.
if (this._active)
return;
this.reset();
this._active = true;
this._sessionId = null;
Expand All @@ -193,6 +201,8 @@ WebInspector.TracingModel.prototype = {

_onStop: function()
{
if (!this._active)
return;
this.dispatchEventToListeners(WebInspector.TracingModel.Events.TracingStopped);
this._active = false;
},
Expand Down

0 comments on commit 2cda1a2

Please sign in to comment.