Commit d0b7c222 authored by loislo@chromium.org's avatar loislo@chromium.org

DevTools: disable DOMAgent when profiler is active

BUG=381115

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

git-svn-id: svn://svn.chromium.org/blink/trunk@177102 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 65ce2fb2
......@@ -276,9 +276,10 @@ void InspectorDOMAgent::clearFrontend()
void InspectorDOMAgent::restore()
{
// Reset document to avoid early return from setDocument.
m_document = nullptr;
setDocument(m_pageAgent->mainFrame()->document());
if (!enabled())
return;
innerEnable();
notifyDocumentUpdated();
}
Vector<Document*> InspectorDOMAgent::documents()
......@@ -486,15 +487,27 @@ Element* InspectorDOMAgent::assertEditableElement(ErrorString* errorString, int
return element;
}
void InspectorDOMAgent::enable(ErrorString*)
void InspectorDOMAgent::innerEnable()
{
if (enabled())
return;
m_state->setBoolean(DOMAgentState::domAgentEnabled, true);
if (m_listener)
m_listener->domAgentWasEnabled();
}
void InspectorDOMAgent::enable(ErrorString*)
{
if (enabled())
return;
innerEnable();
notifyDocumentUpdated();
}
void InspectorDOMAgent::notifyDocumentUpdated()
{
m_document = nullptr;
setDocument(m_pageAgent->mainFrame()->document());
}
bool InspectorDOMAgent::enabled() const
{
return m_state->getBoolean(DOMAgentState::domAgentEnabled);
......@@ -513,7 +526,8 @@ void InspectorDOMAgent::disable(ErrorString*)
void InspectorDOMAgent::getDocument(ErrorString* errorString, RefPtr<TypeBuilder::DOM::Node>& root)
{
// Backward compatibility. Mark agent as enabled when it requests document.
enable(errorString);
if (!enabled())
innerEnable();
if (!m_document) {
*errorString = "Document is not available";
......
......@@ -217,6 +217,9 @@ private:
InspectorDOMAgent(InspectorPageAgent*, InjectedScriptManager*, InspectorOverlay*);
void innerEnable();
void notifyDocumentUpdated();
void setSearchingForNode(ErrorString*, SearchMode, JSONObject* highlightConfig);
PassOwnPtr<HighlightConfig> highlightConfigFromInspectorObject(ErrorString*, JSONObject* highlightInspectorObject);
......
......@@ -903,6 +903,10 @@ WebInspector.DOMModel = function(target) {
this._defaultHighlighter = new WebInspector.DefaultDOMNodeHighlighter(this._agent);
this._highlighter = this._defaultHighlighter;
if (WebInspector.experimentsSettings.disableAgentsWhenProfile.isEnabled())
target.profilingLock.addEventListener(WebInspector.Lock.Events.StateChanged, this._profilingStateChanged, this);
this._agent.enable();
}
......@@ -919,6 +923,14 @@ WebInspector.DOMModel.Events = {
}
WebInspector.DOMModel.prototype = {
_profilingStateChanged: function()
{
if (this.target().profilingLock.isAcquired())
this._agent.disable();
else
this._agent.enable();
},
/**
* @param {function(!WebInspector.DOMDocument)=} callback
*/
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment