Commit 02c23fc6 authored by dgozman's avatar dgozman Committed by Commit bot

[DevTools] Replace profiling{Started,Stopped} with explicit setOverlaySuspended call.

BUG=631162

Review-Url: https://codereview.chromium.org/2189263004
Cr-Commit-Position: refs/heads/master@{#408856}
parent 5414cc34
Test that if a profiler is working all the agents are disabled. Test that if a profiler is working all the agents are disabled.
--> WebInspector.targetManager.suspendAllTargets(); --> WebInspector.targetManager.suspendAllTargets();
frontend: {"id":<number>,"method":"Page.configureOverlay","params":{"suspended":true}}
frontend: {"id":<number>,"method":"Worker.setWaitForDebuggerOnStart","params":{"value":false}} frontend: {"id":<number>,"method":"Worker.setWaitForDebuggerOnStart","params":{"value":false}}
frontend: {"id":<number>,"method":"Debugger.disable"} frontend: {"id":<number>,"method":"Debugger.disable"}
frontend: {"id":<number>,"method":"Debugger.setAsyncCallStackDepth","params":{"maxDepth":0}} frontend: {"id":<number>,"method":"Debugger.setAsyncCallStackDepth","params":{"maxDepth":0}}
frontend: {"id":<number>,"method":"Page.setOverlayMessage"} frontend: {"id":<number>,"method":"Page.configureOverlay","params":{"suspended":true}}
frontend: {"id":<number>,"method":"DOM.disable"} frontend: {"id":<number>,"method":"DOM.disable"}
frontend: {"id":<number>,"method":"CSS.disable"} frontend: {"id":<number>,"method":"CSS.disable"}
--> WebInspector.targetManager.resumeAllTargets(); --> WebInspector.targetManager.resumeAllTargets();
frontend: {"id":<number>,"method":"Page.configureOverlay","params":{"suspended":false}}
frontend: {"id":<number>,"method":"Worker.setWaitForDebuggerOnStart","params":{"value":true}} frontend: {"id":<number>,"method":"Worker.setWaitForDebuggerOnStart","params":{"value":true}}
frontend: {"id":<number>,"method":"Debugger.enable"} frontend: {"id":<number>,"method":"Debugger.enable"}
frontend: {"id":<number>,"method":"Debugger.setPauseOnExceptions","params":{"state":"none"}} frontend: {"id":<number>,"method":"Debugger.setPauseOnExceptions","params":{"state":"none"}}
......
...@@ -80,6 +80,8 @@ static const char pageAgentScriptsToEvaluateOnLoad[] = "pageAgentScriptsToEvalua ...@@ -80,6 +80,8 @@ static const char pageAgentScriptsToEvaluateOnLoad[] = "pageAgentScriptsToEvalua
static const char screencastEnabled[] = "screencastEnabled"; static const char screencastEnabled[] = "screencastEnabled";
static const char autoAttachToCreatedPages[] = "autoAttachToCreatedPages"; static const char autoAttachToCreatedPages[] = "autoAttachToCreatedPages";
static const char blockedEventsWarningThreshold[] = "blockedEventsWarningThreshold"; static const char blockedEventsWarningThreshold[] = "blockedEventsWarningThreshold";
static const char overlaySuspended[] = "overlaySuspended";
static const char overlayMessage[] = "overlayMessage";
} }
namespace { namespace {
...@@ -349,6 +351,11 @@ void InspectorPageAgent::restore() ...@@ -349,6 +351,11 @@ void InspectorPageAgent::restore()
if (m_state->booleanProperty(PageAgentState::pageAgentEnabled, false)) if (m_state->booleanProperty(PageAgentState::pageAgentEnabled, false))
enable(&error); enable(&error);
setBlockedEventsWarningThreshold(&error, m_state->doubleProperty(PageAgentState::blockedEventsWarningThreshold, 0.0)); setBlockedEventsWarningThreshold(&error, m_state->doubleProperty(PageAgentState::blockedEventsWarningThreshold, 0.0));
if (m_client) {
String16 overlayMessage;
m_state->getString(PageAgentState::overlayMessage, &overlayMessage);
m_client->configureOverlay(m_state->booleanProperty(PageAgentState::overlaySuspended, false), overlayMessage.isEmpty() ? String() : String(overlayMessage));
}
} }
void InspectorPageAgent::enable(ErrorString*) void InspectorPageAgent::enable(ErrorString*)
...@@ -369,6 +376,7 @@ void InspectorPageAgent::disable(ErrorString*) ...@@ -369,6 +376,7 @@ void InspectorPageAgent::disable(ErrorString*)
m_inspectorResourceContentLoader->cancel(m_resourceContentLoaderClientId); m_inspectorResourceContentLoader->cancel(m_resourceContentLoaderClientId);
stopScreencast(0); stopScreencast(0);
configureOverlay(nullptr, false, String());
finishReload(); finishReload();
} }
...@@ -739,10 +747,12 @@ void InspectorPageAgent::stopScreencast(ErrorString*) ...@@ -739,10 +747,12 @@ void InspectorPageAgent::stopScreencast(ErrorString*)
m_state->setBoolean(PageAgentState::screencastEnabled, false); m_state->setBoolean(PageAgentState::screencastEnabled, false);
} }
void InspectorPageAgent::setOverlayMessage(ErrorString*, const Maybe<String>& message) void InspectorPageAgent::configureOverlay(ErrorString*, const Maybe<bool>& suspended, const Maybe<String>& message)
{ {
m_state->setBoolean(PageAgentState::overlaySuspended, suspended.fromMaybe(false));
m_state->setString(PageAgentState::overlaySuspended, message.fromMaybe(String()));
if (m_client) if (m_client)
m_client->setPausedInDebuggerMessage(message.fromMaybe(String())); m_client->configureOverlay(suspended.fromMaybe(false), message.fromMaybe(String()));
} }
void InspectorPageAgent::setBlockedEventsWarningThreshold(ErrorString*, double threshold) void InspectorPageAgent::setBlockedEventsWarningThreshold(ErrorString*, double threshold)
......
...@@ -62,7 +62,7 @@ public: ...@@ -62,7 +62,7 @@ public:
public: public:
virtual ~Client() { } virtual ~Client() { }
virtual void pageLayoutInvalidated(bool resized) { } virtual void pageLayoutInvalidated(bool resized) { }
virtual void setPausedInDebuggerMessage(const String&) { } virtual void configureOverlay(bool suspended, const String& message) { }
virtual void waitForCreateWindow(LocalFrame*) { } virtual void waitForCreateWindow(LocalFrame*) { }
}; };
...@@ -108,7 +108,7 @@ public: ...@@ -108,7 +108,7 @@ public:
void setDocumentContent(ErrorString*, const String& frameId, const String& html) override; void setDocumentContent(ErrorString*, const String& frameId, const String& html) override;
void startScreencast(ErrorString*, const Maybe<String>& format, const Maybe<int>& quality, const Maybe<int>& maxWidth, const Maybe<int>& maxHeight, const Maybe<int>& everyNthFrame) override; void startScreencast(ErrorString*, const Maybe<String>& format, const Maybe<int>& quality, const Maybe<int>& maxWidth, const Maybe<int>& maxHeight, const Maybe<int>& everyNthFrame) override;
void stopScreencast(ErrorString*) override; void stopScreencast(ErrorString*) override;
void setOverlayMessage(ErrorString*, const Maybe<String>& message) override; void configureOverlay(ErrorString*, const Maybe<bool>& suspended, const Maybe<String>& message) override;
void setBlockedEventsWarningThreshold(ErrorString*, double threshold) override; void setBlockedEventsWarningThreshold(ErrorString*, double threshold) override;
// InspectorInstrumentation API // InspectorInstrumentation API
......
...@@ -134,16 +134,6 @@ bool InspectorSession::canExecuteScripts() ...@@ -134,16 +134,6 @@ bool InspectorSession::canExecuteScripts()
return m_inspectedFrames ? m_inspectedFrames->root()->script().canExecuteScripts(NotAboutToExecuteScript) : true; return m_inspectedFrames ? m_inspectedFrames->root()->script().canExecuteScripts(NotAboutToExecuteScript) : true;
} }
void InspectorSession::profilingStarted()
{
m_client->profilingStarted();
}
void InspectorSession::profilingStopped()
{
m_client->profilingStopped();
}
DEFINE_TRACE(InspectorSession) DEFINE_TRACE(InspectorSession)
{ {
visitor->trace(m_instrumentingAgents); visitor->trace(m_instrumentingAgents);
......
...@@ -35,8 +35,6 @@ public: ...@@ -35,8 +35,6 @@ public:
public: public:
virtual void sendProtocolMessage(int sessionId, int callId, const String& response, const String& state) = 0; virtual void sendProtocolMessage(int sessionId, int callId, const String& response, const String& state) = 0;
virtual void resumeStartup() { } virtual void resumeStartup() { }
virtual void profilingStarted() { }
virtual void profilingStopped() { }
virtual ~Client() {} virtual ~Client() {}
}; };
...@@ -62,8 +60,6 @@ private: ...@@ -62,8 +60,6 @@ private:
// V8InspectorSessionClient implementation. // V8InspectorSessionClient implementation.
void resumeStartup() override; void resumeStartup() override;
bool canExecuteScripts() override; bool canExecuteScripts() override;
void profilingStarted() override;
void profilingStopped() override;
Client* m_client; Client* m_client;
std::unique_ptr<V8InspectorSession> m_v8Session; std::unique_ptr<V8InspectorSession> m_v8Session;
......
...@@ -460,12 +460,13 @@ ...@@ -460,12 +460,13 @@
"handlers": ["browser"] "handlers": ["browser"]
}, },
{ {
"name": "setOverlayMessage", "name": "configureOverlay",
"parameters": [ "parameters": [
{ "name": "message", "type": "string", "optional": true, "description": "Overlay message to display when paused in debugger." } { "name": "suspended", "type": "boolean", "optional": true, "description": "Whether overlay should be suspended and not consume any resources." },
{ "name": "message", "type": "string", "optional": true, "description": "Overlay message to display." }
], ],
"hidden": true, "hidden": true,
"description": "Sets overlay message." "description": "Configures overlay."
}, },
{ {
"name": "getAppManifest", "name": "getAppManifest",
......
...@@ -7,35 +7,37 @@ ...@@ -7,35 +7,37 @@
*/ */
WebInspector.OverlayController = function() WebInspector.OverlayController = function()
{ {
WebInspector.moduleSetting("disablePausedStateOverlay").addChangeListener(this._updateAllOverlayMessages, this); WebInspector.moduleSetting("disablePausedStateOverlay").addChangeListener(this._updateAllOverlays, this);
WebInspector.targetManager.addModelListener(WebInspector.DebuggerModel, WebInspector.DebuggerModel.Events.DebuggerPaused, this._updateOverlayMessage, this); WebInspector.targetManager.addModelListener(WebInspector.DebuggerModel, WebInspector.DebuggerModel.Events.DebuggerPaused, this._updateOverlay, this);
WebInspector.targetManager.addModelListener(WebInspector.DebuggerModel, WebInspector.DebuggerModel.Events.DebuggerResumed, this._updateOverlayMessage, this); WebInspector.targetManager.addModelListener(WebInspector.DebuggerModel, WebInspector.DebuggerModel.Events.DebuggerResumed, this._updateOverlay, this);
WebInspector.targetManager.addModelListener(WebInspector.DebuggerModel, WebInspector.DebuggerModel.Events.GlobalObjectCleared, this._updateOverlayMessage, this); // TODO(dgozman): we should get DebuggerResumed on navigations instead of listening to GlobalObjectCleared.
WebInspector.targetManager.addModelListener(WebInspector.DebuggerModel, WebInspector.DebuggerModel.Events.GlobalObjectCleared, this._updateOverlay, this);
WebInspector.targetManager.addEventListener(WebInspector.TargetManager.Events.SuspendStateChanged, this._updateAllOverlays, this);
} }
WebInspector.OverlayController.prototype = { WebInspector.OverlayController.prototype = {
_updateAllOverlayMessages: function() _updateAllOverlays: function()
{ {
for (var target of WebInspector.targetManager.targets(WebInspector.Target.Capability.Browser)) for (var target of WebInspector.targetManager.targets(WebInspector.Target.Capability.Browser))
this._updateTargetOverlayMessage(/** @type {!WebInspector.DebuggerModel} */ (WebInspector.DebuggerModel.fromTarget(target))); this._updateTargetOverlay(/** @type {!WebInspector.DebuggerModel} */ (WebInspector.DebuggerModel.fromTarget(target)));
}, },
/** /**
* @param {!WebInspector.Event} event * @param {!WebInspector.Event} event
*/ */
_updateOverlayMessage: function(event) _updateOverlay: function(event)
{ {
this._updateTargetOverlayMessage(/** @type {!WebInspector.DebuggerModel} */ (event.target)); this._updateTargetOverlay(/** @type {!WebInspector.DebuggerModel} */ (event.target));
}, },
/** /**
* @param {!WebInspector.DebuggerModel} debuggerModel * @param {!WebInspector.DebuggerModel} debuggerModel
*/ */
_updateTargetOverlayMessage: function(debuggerModel) _updateTargetOverlay: function(debuggerModel)
{ {
if (!debuggerModel.target().hasBrowserCapability()) if (!debuggerModel.target().hasBrowserCapability())
return; return;
var message = debuggerModel.isPaused() && !WebInspector.moduleSetting("disablePausedStateOverlay").get() ? WebInspector.UIString("Paused in debugger") : undefined; var message = debuggerModel.isPaused() && !WebInspector.moduleSetting("disablePausedStateOverlay").get() ? WebInspector.UIString("Paused in debugger") : undefined;
debuggerModel.target().pageAgent().setOverlayMessage(message); debuggerModel.target().pageAgent().configureOverlay(WebInspector.targetManager.allTargetsSuspended(), message);
} }
} }
...@@ -259,7 +259,6 @@ void V8ProfilerAgentImpl::start(ErrorString* error) ...@@ -259,7 +259,6 @@ void V8ProfilerAgentImpl::start(ErrorString* error)
m_frontendInitiatedProfileId = nextProfileId(); m_frontendInitiatedProfileId = nextProfileId();
startProfiling(m_frontendInitiatedProfileId); startProfiling(m_frontendInitiatedProfileId);
m_state->setBoolean(ProfilerAgentState::userInitiatedProfiling, true); m_state->setBoolean(ProfilerAgentState::userInitiatedProfiling, true);
m_session->client()->profilingStarted();
} }
void V8ProfilerAgentImpl::stop(ErrorString* errorString, std::unique_ptr<protocol::Profiler::CPUProfile>* profile) void V8ProfilerAgentImpl::stop(ErrorString* errorString, std::unique_ptr<protocol::Profiler::CPUProfile>* profile)
...@@ -278,7 +277,6 @@ void V8ProfilerAgentImpl::stop(ErrorString* errorString, std::unique_ptr<protoco ...@@ -278,7 +277,6 @@ void V8ProfilerAgentImpl::stop(ErrorString* errorString, std::unique_ptr<protoco
} }
m_frontendInitiatedProfileId = String16(); m_frontendInitiatedProfileId = String16();
m_state->setBoolean(ProfilerAgentState::userInitiatedProfiling, false); m_state->setBoolean(ProfilerAgentState::userInitiatedProfiling, false);
m_session->client()->profilingStopped();
} }
String16 V8ProfilerAgentImpl::nextProfileId() String16 V8ProfilerAgentImpl::nextProfileId()
......
...@@ -17,8 +17,6 @@ public: ...@@ -17,8 +17,6 @@ public:
virtual void resumeStartup() = 0; virtual void resumeStartup() = 0;
// TODO(dgozman): this was added to support service worker shadow page. We should not connect at all. // TODO(dgozman): this was added to support service worker shadow page. We should not connect at all.
virtual bool canExecuteScripts() = 0; virtual bool canExecuteScripts() = 0;
virtual void profilingStarted() = 0;
virtual void profilingStopped() = 0;
}; };
} // namespace blink } // namespace blink
......
...@@ -178,7 +178,7 @@ InspectorOverlay::InspectorOverlay(WebViewImpl* webViewImpl) ...@@ -178,7 +178,7 @@ InspectorOverlay::InspectorOverlay(WebViewImpl* webViewImpl)
, m_resizeTimerActive(false) , m_resizeTimerActive(false)
, m_omitTooltip(false) , m_omitTooltip(false)
, m_timer(this, &InspectorOverlay::onTimer) , m_timer(this, &InspectorOverlay::onTimer)
, m_suspendCount(0) , m_suspended(false)
, m_inLayout(false) , m_inLayout(false)
, m_needsUpdate(false) , m_needsUpdate(false)
, m_inspectMode(InspectorDOMAgent::NotSearching) , m_inspectMode(InspectorDOMAgent::NotSearching)
...@@ -354,7 +354,7 @@ void InspectorOverlay::highlightQuad(std::unique_ptr<FloatQuad> quad, const Insp ...@@ -354,7 +354,7 @@ void InspectorOverlay::highlightQuad(std::unique_ptr<FloatQuad> quad, const Insp
bool InspectorOverlay::isEmpty() bool InspectorOverlay::isEmpty()
{ {
if (m_suspendCount) if (m_suspended)
return true; return true;
bool hasVisibleElements = m_highlightNode || m_eventTargetNode || m_highlightQuad || (m_resizeTimerActive && m_drawViewSize) || !m_pausedInDebuggerMessage.isNull(); bool hasVisibleElements = m_highlightNode || m_eventTargetNode || m_highlightQuad || (m_resizeTimerActive && m_drawViewSize) || !m_pausedInDebuggerMessage.isNull();
return !hasVisibleElements && m_inspectMode == InspectorDOMAgent::NotSearching; return !hasVisibleElements && m_inspectMode == InspectorDOMAgent::NotSearching;
...@@ -672,13 +672,15 @@ void InspectorOverlay::overlayClearSelection(bool commitChanges) ...@@ -672,13 +672,15 @@ void InspectorOverlay::overlayClearSelection(bool commitChanges)
void InspectorOverlay::suspend() void InspectorOverlay::suspend()
{ {
if (!m_suspendCount++) if (!m_suspended) {
m_suspended = true;
clearInternal(); clearInternal();
}
} }
void InspectorOverlay::resume() void InspectorOverlay::resume()
{ {
--m_suspendCount; m_suspended = false;
} }
void InspectorOverlay::pageLayoutInvalidated(bool resized) void InspectorOverlay::pageLayoutInvalidated(bool resized)
......
...@@ -155,7 +155,7 @@ private: ...@@ -155,7 +155,7 @@ private:
bool m_resizeTimerActive; bool m_resizeTimerActive;
bool m_omitTooltip; bool m_omitTooltip;
Timer<InspectorOverlay> m_timer; Timer<InspectorOverlay> m_timer;
int m_suspendCount; bool m_suspended;
bool m_inLayout; bool m_inLayout;
bool m_needsUpdate; bool m_needsUpdate;
V8InspectorSession* m_v8Session; V8InspectorSession* m_v8Session;
......
...@@ -594,28 +594,21 @@ void WebDevToolsAgentImpl::resumeStartup() ...@@ -594,28 +594,21 @@ void WebDevToolsAgentImpl::resumeStartup()
m_client->resumeStartup(); m_client->resumeStartup();
} }
void WebDevToolsAgentImpl::profilingStarted()
{
if (m_overlay)
m_overlay->suspend();
}
void WebDevToolsAgentImpl::profilingStopped()
{
if (m_overlay)
m_overlay->resume();
}
void WebDevToolsAgentImpl::pageLayoutInvalidated(bool resized) void WebDevToolsAgentImpl::pageLayoutInvalidated(bool resized)
{ {
if (m_overlay) if (m_overlay)
m_overlay->pageLayoutInvalidated(resized); m_overlay->pageLayoutInvalidated(resized);
} }
void WebDevToolsAgentImpl::setPausedInDebuggerMessage(const String& message) void WebDevToolsAgentImpl::configureOverlay(bool suspended, const String& message)
{ {
if (m_overlay) if (!m_overlay)
m_overlay->setPausedInDebuggerMessage(message); return;
m_overlay->setPausedInDebuggerMessage(message);
if (suspended)
m_overlay->suspend();
else
m_overlay->resume();
} }
void WebDevToolsAgentImpl::waitForCreateWindow(LocalFrame* frame) void WebDevToolsAgentImpl::waitForCreateWindow(LocalFrame* frame)
......
...@@ -118,14 +118,12 @@ private: ...@@ -118,14 +118,12 @@ private:
// InspectorPageAgent::Client implementation. // InspectorPageAgent::Client implementation.
void pageLayoutInvalidated(bool resized) override; void pageLayoutInvalidated(bool resized) override;
void setPausedInDebuggerMessage(const String&) override; void configureOverlay(bool suspended, const String& message) override;
void waitForCreateWindow(LocalFrame*) override; void waitForCreateWindow(LocalFrame*) override;
// InspectorSession::Client implementation. // InspectorSession::Client implementation.
void sendProtocolMessage(int sessionId, int callId, const String& response, const String& state) override; void sendProtocolMessage(int sessionId, int callId, const String& response, const String& state) override;
void resumeStartup() override; void resumeStartup() override;
void profilingStarted() override;
void profilingStopped() override;
// WebThread::TaskObserver implementation. // WebThread::TaskObserver implementation.
void willProcessTask() override; void willProcessTask() override;
......
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