Diff
Modified: trunk/Source/WebCore/ChangeLog (87991 => 87992)
--- trunk/Source/WebCore/ChangeLog 2011-06-03 05:17:28 UTC (rev 87991)
+++ trunk/Source/WebCore/ChangeLog 2011-06-03 07:23:53 UTC (rev 87992)
@@ -1,3 +1,51 @@
+2011-06-02 Yury Semikhatsky <[email protected]>
+
+ Reviewed by Pavel Feldman.
+
+ Web Inspector: add an option for automatically attaching to new workers
+ https://bugs.webkit.org/show_bug.cgi?id=61930
+
+ Worker list is extended with a checkbox that makes inspector attach to each
+ new worker. Whenever a new worker context starts a new inspector window will
+ be opened for it.
+
+ Also worker agent and worker list will be updated when worker context is terminated.
+
+ * inspector/Inspector.json:
+ * inspector/InspectorController.cpp:
+ (WebCore::InspectorController::InspectorController):
+ * inspector/InspectorInstrumentation.cpp:
+ (WebCore::InspectorInstrumentation::workerContextTerminatedImpl):
+ * inspector/InspectorInstrumentation.h:
+ (WebCore::InspectorInstrumentation::workerContextTerminated):
+ * inspector/InspectorWorkerAgent.cpp:
+ (WebCore::InspectorWorkerAgent::WorkerFrontendChannel::~WorkerFrontendChannel):
+ (WebCore::InspectorWorkerAgent::create):
+ (WebCore::InspectorWorkerAgent::InspectorWorkerAgent):
+ (WebCore::InspectorWorkerAgent::clearFrontend):
+ (WebCore::InspectorWorkerAgent::setAutoconnectToWorkers):
+ (WebCore::InspectorWorkerAgent::didStartWorkerContext):
+ (WebCore::InspectorWorkerAgent::workerContextTerminated):
+ * inspector/InspectorWorkerAgent.h:
+ * inspector/front-end/WorkerManager.js:
+ (WebInspector.WorkerManager.prototype._workerCreated):
+ (WebInspector.WorkerManager.prototype._workerTerminated):
+ (WebInspector.WorkerManager.prototype.openWorkerInspector):
+ (WebInspector.WorkerManager.prototype._openInspectorWindow):
+ (WebInspector.WorkerManager.prototype.reset):
+ (WebInspector.WorkerMessageForwarder.prototype.workerCreated):
+ (WebInspector.WorkerMessageForwarder.prototype.workerTerminated):
+ * inspector/front-end/WorkersSidebarPane.js:
+ (WebInspector.WorkerListSidebarPane):
+ (WebInspector.WorkerListSidebarPane.prototype._workerAdded):
+ (WebInspector.WorkerListSidebarPane.prototype._workerRemoved):
+ (WebInspector.WorkerListSidebarPane.prototype._workersCleared):
+ (WebInspector.WorkerListSidebarPane.prototype._addWorker):
+ (WebInspector.WorkerListSidebarPane.prototype._workerItemClicked):
+ (WebInspector.WorkerListSidebarPane.prototype._autoattachToWorkersClicked):
+ * inspector/front-end/inspector.js:
+ (WebInspector.reset):
+
2011-06-02 Hayato Ito <[email protected]>
Reviewed by Ryosuke Niwa.
Modified: trunk/Source/WebCore/inspector/Inspector.json (87991 => 87992)
--- trunk/Source/WebCore/inspector/Inspector.json 2011-06-03 05:17:28 UTC (rev 87991)
+++ trunk/Source/WebCore/inspector/Inspector.json 2011-06-03 07:23:53 UTC (rev 87992)
@@ -1738,17 +1738,31 @@
"parameters": [
{ "name": "workerId", "type": "integer" }
]
+ },
+ {
+ "name": "setAutoconnectToWorkers",
+ "parameters": [
+ { "name": "value", "type": "boolean" }
+ ]
}
+
],
"events": [
{
"name": "workerCreated",
"parameters": [
{ "name": "workerId", "type": "integer" },
- { "name": "url", "type": "string" }
+ { "name": "url", "type": "string" },
+ { "name": "inspectorConnected", "type": "boolean" }
]
},
{
+ "name": "workerTerminated",
+ "parameters": [
+ { "name": "workerId", "type": "integer" }
+ ]
+ },
+ {
"name": "dispatchMessageFromWorker",
"parameters": [
{ "name": "workerId", "type": "integer" },
Modified: trunk/Source/WebCore/inspector/InspectorController.cpp (87991 => 87992)
--- trunk/Source/WebCore/inspector/InspectorController.cpp 2011-06-03 05:17:28 UTC (rev 87991)
+++ trunk/Source/WebCore/inspector/InspectorController.cpp 2011-06-03 07:23:53 UTC (rev 87992)
@@ -110,7 +110,7 @@
, m_profilerAgent(InspectorProfilerAgent::create(m_instrumentingAgents.get(), m_consoleAgent.get(), page, m_state.get()))
#endif
#if ENABLE(WORKERS)
- , m_workerAgent(InspectorWorkerAgent::create(m_instrumentingAgents.get()))
+ , m_workerAgent(InspectorWorkerAgent::create(m_instrumentingAgents.get(), m_state.get()))
#endif
, m_page(page)
, m_inspectorClient(inspectorClient)
Modified: trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp (87991 => 87992)
--- trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp 2011-06-03 05:17:28 UTC (rev 87991)
+++ trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp 2011-06-03 07:23:53 UTC (rev 87992)
@@ -733,6 +733,12 @@
if (InspectorAgent* inspectorAgent = instrumentingAgents->inspectorAgent())
inspectorAgent->didDestroyWorker(id);
}
+
+void InspectorInstrumentation::workerContextTerminatedImpl(InstrumentingAgents* instrumentingAgents, WorkerContextProxy* proxy)
+{
+ if (InspectorWorkerAgent* workerAgent = instrumentingAgents->inspectorWorkerAgent())
+ workerAgent->workerContextTerminated(proxy);
+}
#endif
#if ENABLE(WEB_SOCKETS)
Modified: trunk/Source/WebCore/inspector/InspectorInstrumentation.h (87991 => 87992)
--- trunk/Source/WebCore/inspector/InspectorInstrumentation.h 2011-06-03 05:17:28 UTC (rev 87991)
+++ trunk/Source/WebCore/inspector/InspectorInstrumentation.h 2011-06-03 07:23:53 UTC (rev 87992)
@@ -164,6 +164,7 @@
static void didStartWorkerContext(ScriptExecutionContext*, WorkerContextProxy*, bool paused, const KURL&);
static void didCreateWorker(ScriptExecutionContext*, intptr_t id, const String& url, bool isSharedWorker);
static void didDestroyWorker(ScriptExecutionContext*, intptr_t id);
+ static void workerContextTerminated(ScriptExecutionContext*, WorkerContextProxy*);
#endif
#if ENABLE(WEB_SOCKETS)
@@ -286,6 +287,7 @@
static void didStartWorkerContextImpl(InstrumentingAgents*, WorkerContextProxy*, const KURL&);
static void didCreateWorkerImpl(InstrumentingAgents*, intptr_t id, const String& url, bool isSharedWorker);
static void didDestroyWorkerImpl(InstrumentingAgents*, intptr_t id);
+ static void workerContextTerminatedImpl(InstrumentingAgents*, WorkerContextProxy*);
#endif
#if ENABLE(WEB_SOCKETS)
@@ -884,9 +886,18 @@
didDestroyWorkerImpl(instrumentingAgents, id);
#endif
}
+
+inline void InspectorInstrumentation::workerContextTerminated(ScriptExecutionContext* context, WorkerContextProxy* proxy)
+{
+#if ENABLE(INSPECTOR)
+ if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
+ workerContextTerminatedImpl(instrumentingAgents, proxy);
#endif
+}
+#endif
+
#if ENABLE(WEB_SOCKETS)
inline void InspectorInstrumentation::didCreateWebSocket(ScriptExecutionContext* context, unsigned long identifier, const KURL& requestURL, const KURL& documentURL)
{
Modified: trunk/Source/WebCore/inspector/InspectorWorkerAgent.cpp (87991 => 87992)
--- trunk/Source/WebCore/inspector/InspectorWorkerAgent.cpp 2011-06-03 05:17:28 UTC (rev 87991)
+++ trunk/Source/WebCore/inspector/InspectorWorkerAgent.cpp 2011-06-03 07:23:53 UTC (rev 87992)
@@ -36,6 +36,7 @@
#include "InspectorFrontend.h"
#include "InspectorFrontendChannel.h"
+#include "InspectorState.h"
#include "InspectorValues.h"
#include "InstrumentingAgents.h"
#include "KURL.h"
@@ -45,6 +46,10 @@
namespace WebCore {
+namespace WorkerAgentState {
+static const char autoconnectToWorkers[] = "autoconnectToWorkers";
+};
+
class InspectorWorkerAgent::WorkerFrontendChannel : public WorkerContextProxy::PageInspector {
public:
explicit WorkerFrontendChannel(InspectorFrontend* frontend, WorkerContextProxy* proxy)
@@ -56,7 +61,6 @@
}
virtual ~WorkerFrontendChannel()
{
- disconnectFromWorkerContext();
}
int id() const { return m_id; }
@@ -100,14 +104,15 @@
int InspectorWorkerAgent::WorkerFrontendChannel::s_nextId = 1;
-PassOwnPtr<InspectorWorkerAgent> InspectorWorkerAgent::create(InstrumentingAgents* instrumentingAgents)
+PassOwnPtr<InspectorWorkerAgent> InspectorWorkerAgent::create(InstrumentingAgents* instrumentingAgents, InspectorState* inspectorState)
{
- return adoptPtr(new InspectorWorkerAgent(instrumentingAgents));
+ return adoptPtr(new InspectorWorkerAgent(instrumentingAgents, inspectorState));
}
-InspectorWorkerAgent::InspectorWorkerAgent(InstrumentingAgents* instrumentingAgents)
+InspectorWorkerAgent::InspectorWorkerAgent(InstrumentingAgents* instrumentingAgents, InspectorState* inspectorState)
: m_instrumentingAgents(instrumentingAgents)
, m_inspectorFrontend(0)
+ , m_inspectorState(inspectorState)
{
}
@@ -126,7 +131,11 @@
{
m_inspectorFrontend = 0;
m_instrumentingAgents->setInspectorWorkerAgent(0);
- deleteAllValues(m_idToChannel);
+ m_inspectorState->setBoolean(WorkerAgentState::autoconnectToWorkers, false);
+ for (WorkerChannels::iterator it = m_idToChannel.begin(); it != m_idToChannel.end(); ++it) {
+ it->second->disconnectFromWorkerContext();
+ delete it->second;
+ }
m_idToChannel.clear();
}
@@ -157,15 +166,35 @@
*error = "Worker is gone";
}
+void InspectorWorkerAgent::setAutoconnectToWorkers(ErrorString*, bool value)
+{
+ m_inspectorState->setBoolean(WorkerAgentState::autoconnectToWorkers, value);
+}
+
void InspectorWorkerAgent::didStartWorkerContext(WorkerContextProxy* workerContextProxy, const KURL& url)
{
WorkerFrontendChannel* channel = new WorkerFrontendChannel(m_inspectorFrontend, workerContextProxy);
m_idToChannel.set(channel->id(), channel);
ASSERT(m_inspectorFrontend);
- m_inspectorFrontend->worker()->workerCreated(channel->id(), url.string());
+ bool autoconnectToWorkers = m_inspectorState->getBoolean(WorkerAgentState::autoconnectToWorkers);
+ if (autoconnectToWorkers)
+ channel->connectToWorkerContext();
+ m_inspectorFrontend->worker()->workerCreated(channel->id(), url.string(), autoconnectToWorkers);
}
+void InspectorWorkerAgent::workerContextTerminated(WorkerContextProxy* proxy)
+{
+ for (WorkerChannels::iterator it = m_idToChannel.begin(); it != m_idToChannel.end(); ++it) {
+ if (proxy == it->second->proxy()) {
+ m_inspectorFrontend->worker()->workerTerminated(it->first);
+ delete it->second;
+ m_idToChannel.remove(it);
+ return;
+ }
+ }
+}
+
} // namespace WebCore
#endif // ENABLE(WORKERS)
Modified: trunk/Source/WebCore/inspector/InspectorWorkerAgent.h (87991 => 87992)
--- trunk/Source/WebCore/inspector/InspectorWorkerAgent.h 2011-06-03 05:17:28 UTC (rev 87991)
+++ trunk/Source/WebCore/inspector/InspectorWorkerAgent.h 2011-06-03 07:23:53 UTC (rev 87992)
@@ -39,6 +39,7 @@
namespace WebCore {
class InspectorFrontend;
class InspectorObject;
+class InspectorState;
class InstrumentingAgents;
class KURL;
class WorkerContextProxy;
@@ -47,7 +48,7 @@
class InspectorWorkerAgent {
public:
- static PassOwnPtr<InspectorWorkerAgent> create(InstrumentingAgents*);
+ static PassOwnPtr<InspectorWorkerAgent> create(InstrumentingAgents*, InspectorState*);
~InspectorWorkerAgent();
void setFrontend(InspectorFrontend*);
@@ -55,20 +56,24 @@
// Called from InspectorInstrumentation
void didStartWorkerContext(WorkerContextProxy*, const KURL&);
+ void workerContextTerminated(WorkerContextProxy*);
// Called from InspectorBackendDispatcher
void connectToWorker(ErrorString*, int workerId);
void disconnectFromWorker(ErrorString*, int workerId);
void sendMessageToWorker(ErrorString*, int workerId, PassRefPtr<InspectorObject> message);
+ void setAutoconnectToWorkers(ErrorString*, bool value);
private:
- explicit InspectorWorkerAgent(InstrumentingAgents*);
+ InspectorWorkerAgent(InstrumentingAgents*, InspectorState*);
InstrumentingAgents* m_instrumentingAgents;
InspectorFrontend* m_inspectorFrontend;
+ InspectorState* m_inspectorState;
class WorkerFrontendChannel;
- HashMap<int, WorkerFrontendChannel*> m_idToChannel;
+ typedef HashMap<int, WorkerFrontendChannel*> WorkerChannels;
+ WorkerChannels m_idToChannel;
};
} // namespace WebCore
Modified: trunk/Source/WebCore/inspector/front-end/WorkerManager.js (87991 => 87992)
--- trunk/Source/WebCore/inspector/front-end/WorkerManager.js 2011-06-03 05:17:28 UTC (rev 87991)
+++ trunk/Source/WebCore/inspector/front-end/WorkerManager.js 2011-06-03 07:23:53 UTC (rev 87992)
@@ -69,15 +69,24 @@
WebInspector.WorkerManager.Events = {
WorkerAdded: "worker-added",
WorkerRemoved: "worker-removed",
+ WorkersCleared: "workers-cleared",
WorkerInspectorClosed: "worker-inspector-closed"
}
WebInspector.WorkerManager.prototype = {
- _workerCreated: function(workerId, url)
- {
- this.dispatchEventToListeners(WebInspector.WorkerManager.Events.WorkerAdded, {workerId: workerId, url: url});
- },
+ _workerCreated: function(workerId, url, inspectorConnected)
+ {
+ if (inspectorConnected)
+ this._openInspectorWindow(workerId);
+ this.dispatchEventToListeners(WebInspector.WorkerManager.Events.WorkerAdded, {workerId: workerId, url: url, inspectorConnected: inspectorConnected});
+ },
+ _workerTerminated: function(workerId)
+ {
+ this.closeWorkerInspector(workerId);
+ this.dispatchEventToListeners(WebInspector.WorkerManager.Events.WorkerRemoved, workerId);
+ },
+
_sendMessageToWorkerInspector: function(workerId, message)
{
var workerInspectorWindow = this._workerIdToWindow[workerId];
@@ -87,12 +96,17 @@
openWorkerInspector: function(workerId)
{
+ this._openInspectorWindow(workerId);
+ WorkerAgent.connectToWorker(workerId);
+ },
+
+ _openInspectorWindow: function(workerId)
+ {
var url = "" + "&workerId=" + workerId;
url = "" "");
var workerInspectorWindow = window.open(url);
this._workerIdToWindow[workerId] = workerInspectorWindow;
workerInspectorWindow.addEventListener("beforeunload", this._workerInspectorClosing.bind(this, workerId), true);
- WorkerAgent.connectToWorker(workerId);
},
closeWorkerInspector: function(workerId)
@@ -102,6 +116,13 @@
workerInspectorWindow.close();
},
+ reset: function()
+ {
+ for (var workerId in this._workerIdToWindow)
+ this.closeWorkerInspector(workerId);
+ this.dispatchEventToListeners(WebInspector.WorkerManager.Events.WorkersCleared);
+ },
+
_workerInspectorClosing: function(workerId, event)
{
delete this._workerIdToWindow[workerId];
@@ -130,11 +151,16 @@
WorkerAgent.sendMessageToWorker(workerId, message);
},
- workerCreated: function(workerId, url)
+ workerCreated: function(workerId, url, inspectorConnected)
{
- this._workerManager._workerCreated(workerId, url);
+ this._workerManager._workerCreated(workerId, url, inspectorConnected);
},
+ workerTerminated: function(workerId)
+ {
+ this._workerManager._workerTerminated(workerId);
+ },
+
dispatchMessageFromWorker: function(workerId, message)
{
this._workerManager._sendMessageToWorkerInspector(workerId, message);
Modified: trunk/Source/WebCore/inspector/front-end/WorkersSidebarPane.js (87991 => 87992)
--- trunk/Source/WebCore/inspector/front-end/WorkersSidebarPane.js 2011-06-03 05:17:28 UTC (rev 87991)
+++ trunk/Source/WebCore/inspector/front-end/WorkersSidebarPane.js 2011-06-03 07:23:53 UTC (rev 87992)
@@ -107,6 +107,14 @@
{
WebInspector.SidebarPane.call(this, WebInspector.UIString("Worker inspectors"));
+ this._enableWorkersCheckbox = new WebInspector.Checkbox(
+ WebInspector.UIString("Debug"),
+ "sidebar-pane-subtitle",
+ WebInspector.UIString("Automatically attach to new workers. Enabling this option will force opening inspector for all new workers."));
+ this.titleElement.insertBefore(this._enableWorkersCheckbox.element, this.titleElement.firstChild);
+ this._enableWorkersCheckbox.addEventListener(this._autoattachToWorkersClicked.bind(this));
+ this._enableWorkersCheckbox.checked = false;
+
this._workerListElement = document.createElement("ol");
this._workerListElement.tabIndex = 0;
this._workerListElement.addStyleClass("properties-tree");
@@ -118,19 +126,21 @@
workerManager.addEventListener(WebInspector.WorkerManager.Events.WorkerAdded, this._workerAdded, this);
workerManager.addEventListener(WebInspector.WorkerManager.Events.WorkerRemoved, this._workerRemoved, this);
+ workerManager.addEventListener(WebInspector.WorkerManager.Events.WorkersCleared, this._workersCleared, this);
workerManager.addEventListener(WebInspector.WorkerManager.Events.WorkerInspectorClosed, this._workerInspectorClosed, this);
}
WebInspector.WorkerListSidebarPane.prototype = {
_workerAdded: function(event)
{
- this._addWorker(event.data.workerId, event.data.url);
+ this._addWorker(event.data.workerId, event.data.url, event.data.inspectorConnected);
},
_workerRemoved: function(event)
{
var workerItem = this._idToWorkerItem[event.data];
- workerItem.element.parentElement.removeChild(workerItem.element);
+ delete this._idToWorkerItem[event.data];
+ workerItem.element.parent.removeChild(workerItem.element);
},
_workerInspectorClosed: function(event)
@@ -139,8 +149,14 @@
workerItem.checkbox.checked = false;
},
- _addWorker: function(workerId, url)
+ _workersCleared: function(event)
{
+ this._idToWorkerItem = {};
+ this._workerListTreeOutline.removeChildren();
+ },
+
+ _addWorker: function(workerId, url, inspectorConnected)
+ {
var workerItem = {};
workerItem.workerId = workerId;
workerItem.element = new TreeElement(url);
@@ -148,6 +164,7 @@
workerItem.element.selectable = true;
workerItem.checkbox = this._createCheckbox(workerItem.element);
+ workerItem.checkbox.checked = inspectorConnected;
workerItem.checkbox.addEventListener("click", this._workerItemClicked.bind(this, workerItem), true);
this._idToWorkerItem[workerId] = workerItem;
@@ -168,6 +185,11 @@
this._workerManager.openWorkerInspector(workerItem.workerId);
else
this._workerManager.closeWorkerInspector(workerItem.workerId);
+ },
+
+ _autoattachToWorkersClicked: function(event)
+ {
+ WorkerAgent.setAutoconnectToWorkers(event.target.checked);
}
}
Modified: trunk/Source/WebCore/inspector/front-end/inspector.js (87991 => 87992)
--- trunk/Source/WebCore/inspector/front-end/inspector.js 2011-06-03 05:17:28 UTC (rev 87991)
+++ trunk/Source/WebCore/inspector/front-end/inspector.js 2011-06-03 07:23:53 UTC (rev 87992)
@@ -984,6 +984,8 @@
this.console.clearMessages();
this.extensionServer.notifyInspectorReset();
+ if (this.workerManager)
+ this.workerManager.reset();
}
WebInspector.bringToFront = function()
Modified: trunk/Source/WebKit/chromium/ChangeLog (87991 => 87992)
--- trunk/Source/WebKit/chromium/ChangeLog 2011-06-03 05:17:28 UTC (rev 87991)
+++ trunk/Source/WebKit/chromium/ChangeLog 2011-06-03 07:23:53 UTC (rev 87992)
@@ -1,3 +1,17 @@
+2011-06-02 Yury Semikhatsky <[email protected]>
+
+ Reviewed by Pavel Feldman.
+
+ Web Inspector: add an option for automatically attaching to new workers
+ https://bugs.webkit.org/show_bug.cgi?id=61930
+
+ Notification about worker context termination are now sent to the inspector.
+
+ * src/WebWorkerClientImpl.cpp:
+ (WebKit::WebWorkerClientImpl::terminateWorkerContext):
+ (WebKit::WebWorkerClientImpl::disconnectFromInspector):
+ (WebKit::WebWorkerClientImpl::workerContextDestroyed):
+
2011-06-02 Aaron Colwell <[email protected]>
Reviewed by David Levin.
Modified: trunk/Source/WebKit/chromium/src/WebWorkerClientImpl.cpp (87991 => 87992)
--- trunk/Source/WebKit/chromium/src/WebWorkerClientImpl.cpp 2011-06-03 05:17:28 UTC (rev 87991)
+++ trunk/Source/WebKit/chromium/src/WebWorkerClientImpl.cpp 2011-06-03 07:23:53 UTC (rev 87992)
@@ -39,6 +39,7 @@
#include "ErrorEvent.h"
#include "Frame.h"
#include "FrameLoaderClient.h"
+#include "InspectorInstrumentation.h"
#include "MessageEvent.h"
#include "MessagePort.h"
#include "MessagePortChannel.h"
@@ -163,6 +164,7 @@
return;
}
m_webWorker->terminateWorkerContext();
+ InspectorInstrumentation::workerContextTerminated(m_scriptExecutionContext.get(), this);
}
void WebWorkerClientImpl::postMessageToWorkerContext(
@@ -217,7 +219,8 @@
void WebWorkerClientImpl::disconnectFromInspector()
{
- m_webWorker->detachDevTools();
+ if (!m_askedToTerminate)
+ m_webWorker->detachDevTools();
m_pageInspector = 0;
}
@@ -328,6 +331,7 @@
void WebWorkerClientImpl::workerContextDestroyed()
{
+ InspectorInstrumentation::workerContextTerminated(m_scriptExecutionContext.get(), this);
}
void WebWorkerClientImpl::workerContextClosed()