Changeset 87992 in webkit
- Timestamp:
- Jun 3, 2011 12:23:53 AM (13 years ago)
- Location:
- trunk/Source
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r87991 r87992 1 2011-06-02 Yury Semikhatsky <yurys@chromium.org> 2 3 Reviewed by Pavel Feldman. 4 5 Web Inspector: add an option for automatically attaching to new workers 6 https://bugs.webkit.org/show_bug.cgi?id=61930 7 8 Worker list is extended with a checkbox that makes inspector attach to each 9 new worker. Whenever a new worker context starts a new inspector window will 10 be opened for it. 11 12 Also worker agent and worker list will be updated when worker context is terminated. 13 14 * inspector/Inspector.json: 15 * inspector/InspectorController.cpp: 16 (WebCore::InspectorController::InspectorController): 17 * inspector/InspectorInstrumentation.cpp: 18 (WebCore::InspectorInstrumentation::workerContextTerminatedImpl): 19 * inspector/InspectorInstrumentation.h: 20 (WebCore::InspectorInstrumentation::workerContextTerminated): 21 * inspector/InspectorWorkerAgent.cpp: 22 (WebCore::InspectorWorkerAgent::WorkerFrontendChannel::~WorkerFrontendChannel): 23 (WebCore::InspectorWorkerAgent::create): 24 (WebCore::InspectorWorkerAgent::InspectorWorkerAgent): 25 (WebCore::InspectorWorkerAgent::clearFrontend): 26 (WebCore::InspectorWorkerAgent::setAutoconnectToWorkers): 27 (WebCore::InspectorWorkerAgent::didStartWorkerContext): 28 (WebCore::InspectorWorkerAgent::workerContextTerminated): 29 * inspector/InspectorWorkerAgent.h: 30 * inspector/front-end/WorkerManager.js: 31 (WebInspector.WorkerManager.prototype._workerCreated): 32 (WebInspector.WorkerManager.prototype._workerTerminated): 33 (WebInspector.WorkerManager.prototype.openWorkerInspector): 34 (WebInspector.WorkerManager.prototype._openInspectorWindow): 35 (WebInspector.WorkerManager.prototype.reset): 36 (WebInspector.WorkerMessageForwarder.prototype.workerCreated): 37 (WebInspector.WorkerMessageForwarder.prototype.workerTerminated): 38 * inspector/front-end/WorkersSidebarPane.js: 39 (WebInspector.WorkerListSidebarPane): 40 (WebInspector.WorkerListSidebarPane.prototype._workerAdded): 41 (WebInspector.WorkerListSidebarPane.prototype._workerRemoved): 42 (WebInspector.WorkerListSidebarPane.prototype._workersCleared): 43 (WebInspector.WorkerListSidebarPane.prototype._addWorker): 44 (WebInspector.WorkerListSidebarPane.prototype._workerItemClicked): 45 (WebInspector.WorkerListSidebarPane.prototype._autoattachToWorkersClicked): 46 * inspector/front-end/inspector.js: 47 (WebInspector.reset): 48 1 49 2011-06-02 Hayato Ito <hayato@chromium.org> 2 50 -
trunk/Source/WebCore/inspector/Inspector.json
r87803 r87992 1739 1739 { "name": "workerId", "type": "integer" } 1740 1740 ] 1741 } 1741 }, 1742 { 1743 "name": "setAutoconnectToWorkers", 1744 "parameters": [ 1745 { "name": "value", "type": "boolean" } 1746 ] 1747 } 1748 1742 1749 ], 1743 1750 "events": [ … … 1746 1753 "parameters": [ 1747 1754 { "name": "workerId", "type": "integer" }, 1748 { "name": "url", "type": "string" } 1755 { "name": "url", "type": "string" }, 1756 { "name": "inspectorConnected", "type": "boolean" } 1757 ] 1758 }, 1759 { 1760 "name": "workerTerminated", 1761 "parameters": [ 1762 { "name": "workerId", "type": "integer" } 1749 1763 ] 1750 1764 }, -
trunk/Source/WebCore/inspector/InspectorController.cpp
r86581 r87992 111 111 #endif 112 112 #if ENABLE(WORKERS) 113 , m_workerAgent(InspectorWorkerAgent::create(m_instrumentingAgents.get() ))113 , m_workerAgent(InspectorWorkerAgent::create(m_instrumentingAgents.get(), m_state.get())) 114 114 #endif 115 115 , m_page(page) -
trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp
r87803 r87992 734 734 inspectorAgent->didDestroyWorker(id); 735 735 } 736 737 void InspectorInstrumentation::workerContextTerminatedImpl(InstrumentingAgents* instrumentingAgents, WorkerContextProxy* proxy) 738 { 739 if (InspectorWorkerAgent* workerAgent = instrumentingAgents->inspectorWorkerAgent()) 740 workerAgent->workerContextTerminated(proxy); 741 } 736 742 #endif 737 743 -
trunk/Source/WebCore/inspector/InspectorInstrumentation.h
r87803 r87992 165 165 static void didCreateWorker(ScriptExecutionContext*, intptr_t id, const String& url, bool isSharedWorker); 166 166 static void didDestroyWorker(ScriptExecutionContext*, intptr_t id); 167 static void workerContextTerminated(ScriptExecutionContext*, WorkerContextProxy*); 167 168 #endif 168 169 … … 287 288 static void didCreateWorkerImpl(InstrumentingAgents*, intptr_t id, const String& url, bool isSharedWorker); 288 289 static void didDestroyWorkerImpl(InstrumentingAgents*, intptr_t id); 290 static void workerContextTerminatedImpl(InstrumentingAgents*, WorkerContextProxy*); 289 291 #endif 290 292 … … 885 887 #endif 886 888 } 889 890 inline void InspectorInstrumentation::workerContextTerminated(ScriptExecutionContext* context, WorkerContextProxy* proxy) 891 { 892 #if ENABLE(INSPECTOR) 893 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context)) 894 workerContextTerminatedImpl(instrumentingAgents, proxy); 895 #endif 896 } 897 887 898 #endif 888 899 -
trunk/Source/WebCore/inspector/InspectorWorkerAgent.cpp
r87803 r87992 37 37 #include "InspectorFrontend.h" 38 38 #include "InspectorFrontendChannel.h" 39 #include "InspectorState.h" 39 40 #include "InspectorValues.h" 40 41 #include "InstrumentingAgents.h" … … 45 46 46 47 namespace WebCore { 48 49 namespace WorkerAgentState { 50 static const char autoconnectToWorkers[] = "autoconnectToWorkers"; 51 }; 47 52 48 53 class InspectorWorkerAgent::WorkerFrontendChannel : public WorkerContextProxy::PageInspector { … … 57 62 virtual ~WorkerFrontendChannel() 58 63 { 59 disconnectFromWorkerContext();60 64 } 61 65 … … 101 105 int InspectorWorkerAgent::WorkerFrontendChannel::s_nextId = 1; 102 106 103 PassOwnPtr<InspectorWorkerAgent> InspectorWorkerAgent::create(InstrumentingAgents* instrumentingAgents )104 { 105 return adoptPtr(new InspectorWorkerAgent(instrumentingAgents ));106 } 107 108 InspectorWorkerAgent::InspectorWorkerAgent(InstrumentingAgents* instrumentingAgents )107 PassOwnPtr<InspectorWorkerAgent> InspectorWorkerAgent::create(InstrumentingAgents* instrumentingAgents, InspectorState* inspectorState) 108 { 109 return adoptPtr(new InspectorWorkerAgent(instrumentingAgents, inspectorState)); 110 } 111 112 InspectorWorkerAgent::InspectorWorkerAgent(InstrumentingAgents* instrumentingAgents, InspectorState* inspectorState) 109 113 : m_instrumentingAgents(instrumentingAgents) 110 114 , m_inspectorFrontend(0) 115 , m_inspectorState(inspectorState) 111 116 { 112 117 } … … 127 132 m_inspectorFrontend = 0; 128 133 m_instrumentingAgents->setInspectorWorkerAgent(0); 129 deleteAllValues(m_idToChannel); 134 m_inspectorState->setBoolean(WorkerAgentState::autoconnectToWorkers, false); 135 for (WorkerChannels::iterator it = m_idToChannel.begin(); it != m_idToChannel.end(); ++it) { 136 it->second->disconnectFromWorkerContext(); 137 delete it->second; 138 } 130 139 m_idToChannel.clear(); 131 140 } … … 158 167 } 159 168 169 void InspectorWorkerAgent::setAutoconnectToWorkers(ErrorString*, bool value) 170 { 171 m_inspectorState->setBoolean(WorkerAgentState::autoconnectToWorkers, value); 172 } 173 160 174 void InspectorWorkerAgent::didStartWorkerContext(WorkerContextProxy* workerContextProxy, const KURL& url) 161 175 { … … 164 178 165 179 ASSERT(m_inspectorFrontend); 166 m_inspectorFrontend->worker()->workerCreated(channel->id(), url.string()); 180 bool autoconnectToWorkers = m_inspectorState->getBoolean(WorkerAgentState::autoconnectToWorkers); 181 if (autoconnectToWorkers) 182 channel->connectToWorkerContext(); 183 m_inspectorFrontend->worker()->workerCreated(channel->id(), url.string(), autoconnectToWorkers); 184 } 185 186 void InspectorWorkerAgent::workerContextTerminated(WorkerContextProxy* proxy) 187 { 188 for (WorkerChannels::iterator it = m_idToChannel.begin(); it != m_idToChannel.end(); ++it) { 189 if (proxy == it->second->proxy()) { 190 m_inspectorFrontend->worker()->workerTerminated(it->first); 191 delete it->second; 192 m_idToChannel.remove(it); 193 return; 194 } 195 } 167 196 } 168 197 -
trunk/Source/WebCore/inspector/InspectorWorkerAgent.h
r87803 r87992 40 40 class InspectorFrontend; 41 41 class InspectorObject; 42 class InspectorState; 42 43 class InstrumentingAgents; 43 44 class KURL; … … 48 49 class InspectorWorkerAgent { 49 50 public: 50 static PassOwnPtr<InspectorWorkerAgent> create(InstrumentingAgents* );51 static PassOwnPtr<InspectorWorkerAgent> create(InstrumentingAgents*, InspectorState*); 51 52 ~InspectorWorkerAgent(); 52 53 … … 56 57 // Called from InspectorInstrumentation 57 58 void didStartWorkerContext(WorkerContextProxy*, const KURL&); 59 void workerContextTerminated(WorkerContextProxy*); 58 60 59 61 // Called from InspectorBackendDispatcher … … 61 63 void disconnectFromWorker(ErrorString*, int workerId); 62 64 void sendMessageToWorker(ErrorString*, int workerId, PassRefPtr<InspectorObject> message); 65 void setAutoconnectToWorkers(ErrorString*, bool value); 63 66 64 67 private: 65 explicit InspectorWorkerAgent(InstrumentingAgents*);68 InspectorWorkerAgent(InstrumentingAgents*, InspectorState*); 66 69 67 70 InstrumentingAgents* m_instrumentingAgents; 68 71 InspectorFrontend* m_inspectorFrontend; 72 InspectorState* m_inspectorState; 69 73 70 74 class WorkerFrontendChannel; 71 HashMap<int, WorkerFrontendChannel*> m_idToChannel; 75 typedef HashMap<int, WorkerFrontendChannel*> WorkerChannels; 76 WorkerChannels m_idToChannel; 72 77 }; 73 78 -
trunk/Source/WebCore/inspector/front-end/WorkerManager.js
r87803 r87992 70 70 WorkerAdded: "worker-added", 71 71 WorkerRemoved: "worker-removed", 72 WorkersCleared: "workers-cleared", 72 73 WorkerInspectorClosed: "worker-inspector-closed" 73 74 } 74 75 75 76 WebInspector.WorkerManager.prototype = { 76 _workerCreated: function(workerId, url) 77 { 78 this.dispatchEventToListeners(WebInspector.WorkerManager.Events.WorkerAdded, {workerId: workerId, url: url}); 79 }, 77 _workerCreated: function(workerId, url, inspectorConnected) 78 { 79 if (inspectorConnected) 80 this._openInspectorWindow(workerId); 81 this.dispatchEventToListeners(WebInspector.WorkerManager.Events.WorkerAdded, {workerId: workerId, url: url, inspectorConnected: inspectorConnected}); 82 }, 83 84 _workerTerminated: function(workerId) 85 { 86 this.closeWorkerInspector(workerId); 87 this.dispatchEventToListeners(WebInspector.WorkerManager.Events.WorkerRemoved, workerId); 88 }, 80 89 81 90 _sendMessageToWorkerInspector: function(workerId, message) … … 88 97 openWorkerInspector: function(workerId) 89 98 { 99 this._openInspectorWindow(workerId); 100 WorkerAgent.connectToWorker(workerId); 101 }, 102 103 _openInspectorWindow: function(workerId) 104 { 90 105 var url = location.href + "&workerId=" + workerId; 91 106 url = url.replace("docked=true&", ""); … … 93 108 this._workerIdToWindow[workerId] = workerInspectorWindow; 94 109 workerInspectorWindow.addEventListener("beforeunload", this._workerInspectorClosing.bind(this, workerId), true); 95 WorkerAgent.connectToWorker(workerId);96 110 }, 97 111 … … 101 115 if (workerInspectorWindow) 102 116 workerInspectorWindow.close(); 117 }, 118 119 reset: function() 120 { 121 for (var workerId in this._workerIdToWindow) 122 this.closeWorkerInspector(workerId); 123 this.dispatchEventToListeners(WebInspector.WorkerManager.Events.WorkersCleared); 103 124 }, 104 125 … … 131 152 }, 132 153 133 workerCreated: function(workerId, url )154 workerCreated: function(workerId, url, inspectorConnected) 134 155 { 135 this._workerManager._workerCreated(workerId, url); 156 this._workerManager._workerCreated(workerId, url, inspectorConnected); 157 }, 158 159 workerTerminated: function(workerId) 160 { 161 this._workerManager._workerTerminated(workerId); 136 162 }, 137 163 -
trunk/Source/WebCore/inspector/front-end/WorkersSidebarPane.js
r87803 r87992 108 108 WebInspector.SidebarPane.call(this, WebInspector.UIString("Worker inspectors")); 109 109 110 this._enableWorkersCheckbox = new WebInspector.Checkbox( 111 WebInspector.UIString("Debug"), 112 "sidebar-pane-subtitle", 113 WebInspector.UIString("Automatically attach to new workers. Enabling this option will force opening inspector for all new workers.")); 114 this.titleElement.insertBefore(this._enableWorkersCheckbox.element, this.titleElement.firstChild); 115 this._enableWorkersCheckbox.addEventListener(this._autoattachToWorkersClicked.bind(this)); 116 this._enableWorkersCheckbox.checked = false; 117 110 118 this._workerListElement = document.createElement("ol"); 111 119 this._workerListElement.tabIndex = 0; … … 119 127 workerManager.addEventListener(WebInspector.WorkerManager.Events.WorkerAdded, this._workerAdded, this); 120 128 workerManager.addEventListener(WebInspector.WorkerManager.Events.WorkerRemoved, this._workerRemoved, this); 129 workerManager.addEventListener(WebInspector.WorkerManager.Events.WorkersCleared, this._workersCleared, this); 121 130 workerManager.addEventListener(WebInspector.WorkerManager.Events.WorkerInspectorClosed, this._workerInspectorClosed, this); 122 131 } … … 125 134 _workerAdded: function(event) 126 135 { 127 this._addWorker(event.data.workerId, event.data.url );136 this._addWorker(event.data.workerId, event.data.url, event.data.inspectorConnected); 128 137 }, 129 138 … … 131 140 { 132 141 var workerItem = this._idToWorkerItem[event.data]; 133 workerItem.element.parentElement.removeChild(workerItem.element); 142 delete this._idToWorkerItem[event.data]; 143 workerItem.element.parent.removeChild(workerItem.element); 134 144 }, 135 145 … … 140 150 }, 141 151 142 _addWorker: function(workerId, url) 152 _workersCleared: function(event) 153 { 154 this._idToWorkerItem = {}; 155 this._workerListTreeOutline.removeChildren(); 156 }, 157 158 _addWorker: function(workerId, url, inspectorConnected) 143 159 { 144 160 var workerItem = {}; … … 149 165 150 166 workerItem.checkbox = this._createCheckbox(workerItem.element); 167 workerItem.checkbox.checked = inspectorConnected; 151 168 workerItem.checkbox.addEventListener("click", this._workerItemClicked.bind(this, workerItem), true); 152 169 … … 169 186 else 170 187 this._workerManager.closeWorkerInspector(workerItem.workerId); 188 }, 189 190 _autoattachToWorkersClicked: function(event) 191 { 192 WorkerAgent.setAutoconnectToWorkers(event.target.checked); 171 193 } 172 194 } -
trunk/Source/WebCore/inspector/front-end/inspector.js
r87681 r87992 985 985 this.console.clearMessages(); 986 986 this.extensionServer.notifyInspectorReset(); 987 if (this.workerManager) 988 this.workerManager.reset(); 987 989 } 988 990 -
trunk/Source/WebKit/chromium/ChangeLog
r87965 r87992 1 2011-06-02 Yury Semikhatsky <yurys@chromium.org> 2 3 Reviewed by Pavel Feldman. 4 5 Web Inspector: add an option for automatically attaching to new workers 6 https://bugs.webkit.org/show_bug.cgi?id=61930 7 8 Notification about worker context termination are now sent to the inspector. 9 10 * src/WebWorkerClientImpl.cpp: 11 (WebKit::WebWorkerClientImpl::terminateWorkerContext): 12 (WebKit::WebWorkerClientImpl::disconnectFromInspector): 13 (WebKit::WebWorkerClientImpl::workerContextDestroyed): 14 1 15 2011-06-02 Aaron Colwell <acolwell@chromium.org> 2 16 -
trunk/Source/WebKit/chromium/src/WebWorkerClientImpl.cpp
r87074 r87992 40 40 #include "Frame.h" 41 41 #include "FrameLoaderClient.h" 42 #include "InspectorInstrumentation.h" 42 43 #include "MessageEvent.h" 43 44 #include "MessagePort.h" … … 164 165 } 165 166 m_webWorker->terminateWorkerContext(); 167 InspectorInstrumentation::workerContextTerminated(m_scriptExecutionContext.get(), this); 166 168 } 167 169 … … 218 220 void WebWorkerClientImpl::disconnectFromInspector() 219 221 { 220 m_webWorker->detachDevTools(); 222 if (!m_askedToTerminate) 223 m_webWorker->detachDevTools(); 221 224 m_pageInspector = 0; 222 225 } … … 329 332 void WebWorkerClientImpl::workerContextDestroyed() 330 333 { 334 InspectorInstrumentation::workerContextTerminated(m_scriptExecutionContext.get(), this); 331 335 } 332 336
Note: See TracChangeset
for help on using the changeset viewer.