Changeset 56404 in webkit
- Timestamp:
- Mar 23, 2010 11:49:46 AM (14 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r56402 r56404 1 2010-03-23 Andrey Kosyakov <caseq@chromium.org> 2 3 Reviewed by Dmitry Titov. 4 5 Change notification sent to inspector frontend on workers creation / destruction 6 to be posted asynchronously to avoid JS reenterability problems. Also, renamed 7 willDestroyWorker to didDestroyWorker to reflect that it gets called later and got 8 rid of explicit IDs for workers (use addresses instead). 9 https://bugs.webkit.org/show_bug.cgi?id=36213 10 11 * inspector/InjectedScriptHost.cpp: 12 (WebCore::InjectedScriptHost::didDestroyWorker): 13 * inspector/InjectedScriptHost.h: 14 * inspector/InjectedScriptHost.idl: 15 * inspector/InspectorController.cpp: 16 (WebCore::PostWorkerNotificationToFrontendTask::create): 17 (WebCore::PostWorkerNotificationToFrontendTask::PostWorkerNotificationToFrontendTask): 18 (WebCore::PostWorkerNotificationToFrontendTask::performTask): 19 (WebCore::InspectorController::postWorkerNotificationToFrontend): 20 (WebCore::InspectorController::didCreateWorker): 21 (WebCore::InspectorController::didDestroyWorker): 22 * inspector/InspectorController.h: 23 (WebCore::InspectorController::): 24 * inspector/InspectorFrontend.cpp: 25 (WebCore::InspectorFrontend::didDestroyWorker): 26 * inspector/InspectorFrontend.h: 27 * inspector/InspectorWorkerResource.h: 28 (WebCore::InspectorWorkerResource::create): 29 (WebCore::InspectorWorkerResource::id): 30 (WebCore::InspectorWorkerResource::InspectorWorkerResource): 31 * inspector/front-end/InjectedFakeWorker.js: 32 (InjectedFakeWorker.FakeWorker.prototype.terminate): 33 * inspector/front-end/WorkersSidebarPane.js: 34 (WebInspector.didDestroyWorker): 35 * workers/AbstractWorker.cpp: 36 (WebCore::AbstractWorker::AbstractWorker): 37 (WebCore::AbstractWorker::onDestroyWorker): 38 * workers/AbstractWorker.h: 39 (WebCore::AbstractWorker::asID): 40 * workers/SharedWorker.cpp: 41 (WebCore::SharedWorker::SharedWorker): 42 * workers/Worker.cpp: 43 (WebCore::Worker::Worker): 44 1 45 2010-03-22 David Hyatt <hyatt@apple.com> 2 46 -
trunk/WebCore/inspector/InjectedScriptHost.cpp
r55771 r56404 214 214 } 215 215 216 void InjectedScriptHost:: willDestroyWorker(long id)217 { 218 if (m_inspectorController) 219 m_inspectorController-> willDestroyWorker(id);216 void InjectedScriptHost::didDestroyWorker(long id) 217 { 218 if (m_inspectorController) 219 m_inspectorController->didDestroyWorker(id); 220 220 } 221 221 #endif // ENABLE(WORKERS) -
trunk/WebCore/inspector/InjectedScriptHost.h
r55771 r56404 84 84 long nextWorkerId(); 85 85 void didCreateWorker(long id, const String& url, bool isSharedWorker); 86 void willDestroyWorker(long id);86 void didDestroyWorker(long id); 87 87 #endif 88 88 void reportDidDispatchOnInjectedScript(long callId, SerializedScriptValue* result, bool isException); -
trunk/WebCore/inspector/InjectedScriptHost.idl
r55771 r56404 58 58 #if defined(ENABLE_WORKERS) && ENABLE_WORKERS 59 59 void didCreateWorker(in long id, in DOMString url, in boolean isFakeWorker); 60 void willDestroyWorker(in long id);60 void didDestroyWorker(in long id); 61 61 long nextWorkerId(); 62 62 #endif -
trunk/WebCore/inspector/InspectorController.cpp
r56108 r56404 1058 1058 1059 1059 #if ENABLE(WORKERS) 1060 void InspectorController::didCreateWorker(long id, const String& url, bool isSharedWorker) 1060 class PostWorkerNotificationToFrontendTask : public ScriptExecutionContext::Task { 1061 public: 1062 static PassOwnPtr<PostWorkerNotificationToFrontendTask> create(PassRefPtr<InspectorWorkerResource> worker, InspectorController::WorkerAction action) 1063 { 1064 return new PostWorkerNotificationToFrontendTask(worker, action); 1065 } 1066 1067 private: 1068 PostWorkerNotificationToFrontendTask(PassRefPtr<InspectorWorkerResource> worker, InspectorController::WorkerAction action) 1069 : m_worker(worker) 1070 , m_action(action) 1071 { 1072 } 1073 1074 virtual void performTask(ScriptExecutionContext* scriptContext) 1075 { 1076 if (InspectorController* inspector = scriptContext->inspectorController()) 1077 inspector->postWorkerNotificationToFrontend(*m_worker, m_action); 1078 } 1079 1080 private: 1081 RefPtr<InspectorWorkerResource> m_worker; 1082 InspectorController::WorkerAction m_action; 1083 }; 1084 1085 void InspectorController::postWorkerNotificationToFrontend(const InspectorWorkerResource& worker, InspectorController::WorkerAction action) 1086 { 1087 if (!m_frontend) 1088 return; 1089 switch (action) { 1090 case InspectorController::WorkerCreated: 1091 m_frontend->didCreateWorker(worker); 1092 break; 1093 case InspectorController::WorkerDestroyed: 1094 m_frontend->didDestroyWorker(worker); 1095 break; 1096 } 1097 } 1098 1099 void InspectorController::didCreateWorker(intptr_t id, const String& url, bool isSharedWorker) 1061 1100 { 1062 1101 if (!enabled()) … … 1065 1104 RefPtr<InspectorWorkerResource> workerResource(InspectorWorkerResource::create(id, url, isSharedWorker)); 1066 1105 m_workers.set(id, workerResource); 1067 if (m_ frontend)1068 m_ frontend->didCreateWorker(*workerResource);1069 } 1070 1071 void InspectorController:: willDestroyWorker(longid)1106 if (m_inspectedPage && m_frontend) 1107 m_inspectedPage->mainFrame()->document()->postTask(PostWorkerNotificationToFrontendTask::create(workerResource, InspectorController::WorkerCreated)); 1108 } 1109 1110 void InspectorController::didDestroyWorker(intptr_t id) 1072 1111 { 1073 1112 if (!enabled()) … … 1077 1116 if (workerResource == m_workers.end()) 1078 1117 return; 1079 if (m_ frontend)1080 m_ frontend->willDestroyWorker(*workerResource->second);1118 if (m_inspectedPage && m_frontend) 1119 m_inspectedPage->mainFrame()->document()->postTask(PostWorkerNotificationToFrontendTask::create(workerResource->second, InspectorController::WorkerDestroyed)); 1081 1120 m_workers.remove(workerResource); 1082 1121 } -
trunk/WebCore/inspector/InspectorController.h
r56104 r56404 184 184 void didModifyDOMAttr(Element*); 185 185 #if ENABLE(WORKERS) 186 void didCreateWorker(long id, const String& url, bool isSharedWorker); 187 void willDestroyWorker(long id); 186 enum WorkerAction { WorkerCreated, WorkerDestroyed }; 187 188 void postWorkerNotificationToFrontend(const InspectorWorkerResource&, WorkerAction); 189 void didCreateWorker(intptr_t, const String& url, bool isSharedWorker); 190 void didDestroyWorker(intptr_t); 188 191 #endif 189 192 void getCookies(long callId); … … 362 365 #endif 363 366 #if ENABLE(WORKERS) 364 typedef HashMap< long, RefPtr<InspectorWorkerResource> > WorkersMap;367 typedef HashMap<intptr_t, RefPtr<InspectorWorkerResource> > WorkersMap; 365 368 366 369 WorkersMap m_workers; -
trunk/WebCore/inspector/InspectorFrontend.cpp
r56107 r56404 603 603 } 604 604 605 void InspectorFrontend:: willDestroyWorker(const InspectorWorkerResource& worker)606 { 607 ScriptFunctionCall function(m_webInspector, "dispatch"); 608 function.appendArgument(" willDestroyWorker");605 void InspectorFrontend::didDestroyWorker(const InspectorWorkerResource& worker) 606 { 607 ScriptFunctionCall function(m_webInspector, "dispatch"); 608 function.appendArgument("didDestroyWorker"); 609 609 function.appendArgument(worker.id()); 610 610 function.call(); -
trunk/WebCore/inspector/InspectorFrontend.h
r56109 r56404 151 151 #if ENABLE(WORKERS) 152 152 void didCreateWorker(const InspectorWorkerResource&); 153 void willDestroyWorker(const InspectorWorkerResource&);153 void didDestroyWorker(const InspectorWorkerResource&); 154 154 #endif // ENABLE(WORKER) 155 155 -
trunk/WebCore/inspector/InspectorWorkerResource.h
r55771 r56404 43 43 class InspectorWorkerResource : public RefCounted<InspectorWorkerResource> { 44 44 public: 45 static PassRefPtr<InspectorWorkerResource> create( longid, const String& url, bool isSharedWorker)45 static PassRefPtr<InspectorWorkerResource> create(intptr_t id, const String& url, bool isSharedWorker) 46 46 { 47 47 return adoptRef(new InspectorWorkerResource(id, url, isSharedWorker)); 48 48 } 49 49 50 longid() const { return m_id; }50 intptr_t id() const { return m_id; } 51 51 const String& url() const { return m_url; } 52 52 bool isSharedWorker() const { return m_isSharedWorker; } 53 53 private: 54 InspectorWorkerResource( longid, const String& url, bool isSharedWorker)54 InspectorWorkerResource(intptr_t id, const String& url, bool isSharedWorker) 55 55 : m_id(id) 56 56 , m_url(url) … … 59 59 } 60 60 61 int m_id;61 intptr_t m_id; 62 62 String m_url; 63 63 bool m_isSharedWorker; -
trunk/WebCore/inspector/front-end/InjectedFakeWorker.js
r56374 r56404 68 68 terminate: function() 69 69 { 70 InjectedScriptHost. willDestroyWorker(this._id);70 InjectedScriptHost.didDestroyWorker(this._id); 71 71 72 72 if (this._frame != null) { -
trunk/WebCore/inspector/front-end/WorkersSidebarPane.js
r55771 r56404 108 108 } 109 109 110 WebInspector. willDestroyWorker = function()110 WebInspector.didDestroyWorker = function() 111 111 { 112 112 var workersPane = WebInspector.panels.scripts.sidebarPanes.workers; -
trunk/WebCore/workers/AbstractWorker.cpp
r55771 r56404 45 45 namespace WebCore { 46 46 47 long AbstractWorker::s_lastId;48 49 47 AbstractWorker::AbstractWorker(ScriptExecutionContext* context) 50 48 : ActiveDOMObject(context, this) 51 , m_id(++s_lastId)52 49 { 53 50 } … … 62 59 #if ENABLE(INSPECTOR) 63 60 if (InspectorController* inspector = scriptExecutionContext() ? scriptExecutionContext()->inspectorController() : 0) 64 inspector-> willDestroyWorker(id());61 inspector->didDestroyWorker(asID()); 65 62 #endif 66 63 } -
trunk/WebCore/workers/AbstractWorker.h
r55771 r56404 58 58 using RefCounted<AbstractWorker>::deref; 59 59 60 long id() const { return m_id; }61 60 virtual void contextDestroyed(); 62 61 AbstractWorker(ScriptExecutionContext*); … … 66 65 // Helper function that converts a URL to an absolute URL and checks the result for validity. 67 66 KURL resolveURL(const String& url, ExceptionCode& ec); 67 intptr_t asID() const { return reinterpret_cast<intptr_t>(this); } 68 68 69 69 private: … … 75 75 76 76 EventTargetData m_eventTargetData; 77 long m_id;78 79 static long s_lastId;80 77 }; 81 78 -
trunk/WebCore/workers/SharedWorker.cpp
r55771 r56404 57 57 #if ENABLE(INSPECTOR) 58 58 if (InspectorController* inspector = scriptExecutionContext()->inspectorController()) 59 inspector->didCreateWorker( id(), scriptUrl.string(), true);59 inspector->didCreateWorker(asID(), scriptUrl.string(), true); 60 60 #endif 61 61 } -
trunk/WebCore/workers/Worker.cpp
r55771 r56404 64 64 #if ENABLE(INSPECTOR) 65 65 if (InspectorController* inspector = scriptExecutionContext()->inspectorController()) 66 inspector->didCreateWorker( id(), scriptURL.string(), false);66 inspector->didCreateWorker(asID(), scriptURL.string(), false); 67 67 #endif 68 68 }
Note: See TracChangeset
for help on using the changeset viewer.