Changeset 47036 in webkit
- Timestamp:
- Aug 11, 2009 9:33:18 AM (15 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 18 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r47030 r47036 1 2009-08-11 Drew Wilson <atwilson@google.com> 2 3 Reviewed by David Levin. 4 5 Need to refactor WorkerObjectProxy. 6 https://bugs.webkit.org/show_bug.cgi?id=28136 7 8 Added WorkerReportingProxy for reporting worker state (exceptions, console messages, thread exited) to the parent. 9 10 Existing tests are sufficient, as this is only a refactoring. 11 12 * GNUmakefile.am: 13 Added WorkerReportingProxy.h to build. 14 * WebCore.gypi: 15 Added WorkerReportingProxy.h to build. 16 * WebCore.vcproj/WebCore.vcproj: 17 Added WorkerReportingProxy.h to build. 18 * WebCore.xcodeproj/project.pbxproj: 19 Added WorkerReportingProxy.h to build. 20 * workers/DedicatedWorkerContext.cpp: 21 * workers/DedicatedWorkerContext.h: 22 Removed addMessage/forwardException() APIs - now handled by WorkerReportingProxy. 23 * workers/DedicatedWorkerThread.cpp: 24 (WebCore::DedicatedWorkerThread::DedicatedWorkerThread): 25 Changed constructor to pass WorkerReportingProxy to base class. 26 * workers/DefaultSharedWorkerRepository.cpp: 27 Updated SharedWorkerProxy to implement WorkerReportingProxy interface. 28 (WebCore::SharedWorkerProxy::postExceptionToWorkerObject): 29 (WebCore::SharedWorkerProxy::postConsoleMessageToWorkerObject): 30 (WebCore::SharedWorkerProxy::workerContextClosed): 31 (WebCore::SharedWorkerProxy::workerContextDestroyed): 32 (WebCore::DefaultSharedWorkerRepository::workerScriptLoaded): 33 Now passes in WorkerReportingProxy when creating SharedWorkerThread. 34 * workers/SharedWorkerContext.cpp: 35 * workers/SharedWorkerContext.h: 36 Removed addMessage/forwardException() APIs - now handled by WorkerReportingProxy. 37 * workers/SharedWorkerThread.cpp: 38 (WebCore::SharedWorkerThread::create): 39 (WebCore::SharedWorkerThread::SharedWorkerThread): 40 Passes WorkerReportingProxy to base class constructor. 41 * workers/SharedWorkerThread.h: 42 Constructor now takes a WorkerReportingProxy. 43 * workers/WorkerContext.cpp: 44 (WebCore::WorkerContext::~WorkerContext): 45 Moved code that calls workerContextDestroyed() into base class so shared workers share this functionality. 46 (WebCore::WorkerContext::close): 47 Now notifies WorkerReportingProxy when the thread is closing. 48 (WebCore::WorkerContext::reportException): 49 Reports exceptions via WorkerReportingProxy. 50 (WebCore::WorkerContext::addMessage): 51 Reports console messages via WorkerReportingProxy. 52 * workers/WorkerContext.h: 53 * workers/WorkerObjectProxy.h: 54 (WebCore::WorkerObjectProxy::workerContextClosed): 55 Default empty implementation for dedicated workers. 56 * workers/WorkerReportingProxy.h: Added. 57 Base interface that contains APIs moved from WorkerObjectProxy. 58 (WebCore::WorkerReportingProxy::~WorkerReportingProxy): 59 * workers/WorkerThread.cpp: 60 (WebCore::WorkerThread::WorkerThread): 61 Updated constructor to accept a WorkerReportingProxy. 62 * workers/WorkerThread.h: 63 (WebCore::WorkerThread::workerReportingProxy): 64 1 65 2009-08-11 Simon Hausmann <simon.hausmann@nokia.com> 2 66 -
trunk/WebCore/GNUmakefile.am
r46956 r47036 2371 2371 WebCore/workers/WorkerMessagingProxy.h \ 2372 2372 WebCore/workers/WorkerObjectProxy.h \ 2373 WebCore/workers/WorkerReportingProxy.h \ 2373 2374 WebCore/workers/WorkerRunLoop.cpp \ 2374 2375 WebCore/workers/WorkerRunLoop.h \ -
trunk/WebCore/WebCore.gypi
r46979 r47036 3354 3354 'workers/WorkerMessagingProxy.h', 3355 3355 'workers/WorkerObjectProxy.h', 3356 'workers/WorkerReportingProxy.h', 3356 3357 'workers/WorkerRunLoop.cpp', 3357 3358 'workers/WorkerRunLoop.h', -
trunk/WebCore/WebCore.vcproj/WebCore.vcproj
r46995 r47036 24293 24293 </File> 24294 24294 <File 24295 RelativePath="..\workers\WorkerReportingProxy.h" 24296 > 24297 </File> 24298 <File 24295 24299 RelativePath="..\workers\WorkerRunLoop.cpp" 24296 24300 > -
trunk/WebCore/WebCore.xcodeproj/project.pbxproj
r46937 r47036 676 676 4167EBF5102962BA003D252A /* DefaultSharedWorkerRepository.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4167EBF3102962BA003D252A /* DefaultSharedWorkerRepository.cpp */; }; 677 677 4167EBF6102962BA003D252A /* DefaultSharedWorkerRepository.h in Headers */ = {isa = PBXBuildFile; fileRef = 4167EBF4102962BA003D252A /* DefaultSharedWorkerRepository.h */; }; 678 416E29A6102FA962007FC14E /* WorkerReportingProxy.h in Headers */ = {isa = PBXBuildFile; fileRef = 416E29A5102FA962007FC14E /* WorkerReportingProxy.h */; }; 678 679 416E75BE0EDF8FD700360E1D /* ScriptCallStack.h in Headers */ = {isa = PBXBuildFile; fileRef = 416E75BC0EDF8FD700360E1D /* ScriptCallStack.h */; }; 679 680 416E75BF0EDF8FD700360E1D /* ScriptCallStack.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 416E75BD0EDF8FD700360E1D /* ScriptCallStack.cpp */; }; … … 5674 5675 4167EBF3102962BA003D252A /* DefaultSharedWorkerRepository.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DefaultSharedWorkerRepository.cpp; path = workers/DefaultSharedWorkerRepository.cpp; sourceTree = "<group>"; }; 5675 5676 4167EBF4102962BA003D252A /* DefaultSharedWorkerRepository.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DefaultSharedWorkerRepository.h; path = workers/DefaultSharedWorkerRepository.h; sourceTree = "<group>"; }; 5677 416E29A5102FA962007FC14E /* WorkerReportingProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WorkerReportingProxy.h; path = workers/WorkerReportingProxy.h; sourceTree = "<group>"; }; 5676 5678 416E75BC0EDF8FD700360E1D /* ScriptCallStack.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScriptCallStack.h; sourceTree = "<group>"; }; 5677 5679 416E75BD0EDF8FD700360E1D /* ScriptCallStack.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScriptCallStack.cpp; sourceTree = "<group>"; }; … … 10027 10029 2E43463E0F546A8200B0F1BA /* WorkerMessagingProxy.h */, 10028 10030 2E43463F0F546A8200B0F1BA /* WorkerObjectProxy.h */, 10031 416E29A5102FA962007FC14E /* WorkerReportingProxy.h */, 10029 10032 2E4346400F546A8200B0F1BA /* WorkerRunLoop.cpp */, 10030 10033 2E4346410F546A8200B0F1BA /* WorkerRunLoop.h */, … … 17186 17189 49484FCB102CF23C00187DD3 /* CanvasRenderingContext2D.h in Headers */, 17187 17190 49484FCE102CF23C00187DD3 /* CanvasStyle.h in Headers */, 17191 416E29A6102FA962007FC14E /* WorkerReportingProxy.h in Headers */, 17188 17192 ); 17189 17193 runOnlyForDeploymentPostprocessing = 0; -
trunk/WebCore/workers/DedicatedWorkerContext.cpp
r46845 r47036 45 45 : WorkerContext(url, userAgent, thread) 46 46 { 47 }48 49 DedicatedWorkerContext::~DedicatedWorkerContext()50 {51 ASSERT(currentThread() == thread()->threadID());52 // Notify parent worker we are going away. This can free the WorkerThread object, so do not access it after this.53 thread()->workerObjectProxy().workerContextDestroyed();54 }55 56 void DedicatedWorkerContext::forwardException(const String& errorMessage, int lineNumber, const String& sourceURL)57 {58 thread()->workerObjectProxy().postExceptionToWorkerObject(errorMessage, lineNumber, sourceURL);59 }60 61 void DedicatedWorkerContext::addMessage(MessageDestination destination, MessageSource source, MessageType type, MessageLevel level, const String& message, unsigned lineNumber, const String& sourceURL)62 {63 thread()->workerObjectProxy().postConsoleMessageToWorkerObject(destination, source, type, level, message, lineNumber, sourceURL);64 47 } 65 48 -
trunk/WebCore/workers/DedicatedWorkerContext.h
r46845 r47036 47 47 return adoptRef(new DedicatedWorkerContext(url, userAgent, thread)); 48 48 } 49 virtual ~DedicatedWorkerContext();50 49 51 50 virtual bool isDedicatedWorkerContext() const { return true; } … … 53 52 // Overridden to allow us to check our pending activity after executing imported script. 54 53 virtual void importScripts(const Vector<String>& urls, const String& callerURL, int callerLine, ExceptionCode&); 55 56 // ScriptExecutionContext57 virtual void addMessage(MessageDestination, MessageSource, MessageType, MessageLevel, const String& message, unsigned lineNumber, const String& sourceURL);58 59 virtual void forwardException(const String& errorMessage, int lineNumber, const String& sourceURL);60 54 61 55 // EventTarget -
trunk/WebCore/workers/DedicatedWorkerThread.cpp
r46507 r47036 46 46 47 47 DedicatedWorkerThread::DedicatedWorkerThread(const KURL& url, const String& userAgent, const String& sourceCode, WorkerLoaderProxy& workerLoaderProxy, WorkerObjectProxy& workerObjectProxy) 48 : WorkerThread(url, userAgent, sourceCode, workerLoaderProxy )48 : WorkerThread(url, userAgent, sourceCode, workerLoaderProxy, workerObjectProxy) 49 49 , m_workerObjectProxy(workerObjectProxy) 50 50 { -
trunk/WebCore/workers/DefaultSharedWorkerRepository.cpp
r46925 r47036 45 45 #include "SharedWorkerThread.h" 46 46 #include "WorkerLoaderProxy.h" 47 #include "WorkerReportingProxy.h" 47 48 #include "WorkerScriptLoader.h" 48 49 #include "WorkerScriptLoaderClient.h" … … 52 53 namespace WebCore { 53 54 54 class SharedWorkerProxy : public ThreadSafeShared<SharedWorkerProxy>, public WorkerLoaderProxy {55 class SharedWorkerProxy : public ThreadSafeShared<SharedWorkerProxy>, public WorkerLoaderProxy, public WorkerReportingProxy { 55 56 public: 56 57 static PassRefPtr<SharedWorkerProxy> create(const String& name, const KURL& url) { return adoptRef(new SharedWorkerProxy(name, url)); } … … 67 68 virtual void postTaskForModeToWorkerContext(PassRefPtr<ScriptExecutionContext::Task>, const String&) { notImplemented(); } 68 69 70 // WorkerReportingProxy 71 virtual void postExceptionToWorkerObject(const String& errorMessage, int lineNumber, const String& sourceURL); 72 virtual void postConsoleMessageToWorkerObject(MessageDestination, MessageSource, MessageType, MessageLevel, const String& message, int lineNumber, const String& sourceURL); 73 virtual void workerContextClosed(); 74 virtual void workerContextDestroyed(); 75 69 76 // Updates the list of the worker's documents, per section 4.5 of the WebWorkers spec. 70 77 void addToWorkerDocuments(ScriptExecutionContext*); 78 71 79 private: 72 80 SharedWorkerProxy(const String& name, const KURL&); … … 82 90 , m_url(url.copy()) 83 91 { 92 } 93 94 void SharedWorkerProxy::postExceptionToWorkerObject(const String&, int, const String&) 95 { 96 // FIXME: Log exceptions to all parent documents. 97 notImplemented(); 98 } 99 100 void SharedWorkerProxy::postConsoleMessageToWorkerObject(MessageDestination, MessageSource, MessageType, MessageLevel, const String&, int, const String&) 101 { 102 // FIXME: Log console messages to all parent documents. 103 notImplemented(); 104 } 105 106 void SharedWorkerProxy::workerContextClosed() 107 { 108 m_closing = true; 109 } 110 111 void SharedWorkerProxy::workerContextDestroyed() 112 { 113 // FIXME: Remove the proxy from the repository once the worker context is destroyed. 114 notImplemented(); 84 115 } 85 116 … … 178 209 // Another loader may have already started up a thread for this proxy - if so, just send a connect to the pre-existing thread. 179 210 if (!proxy.thread()) { 180 RefPtr<SharedWorkerThread> thread = SharedWorkerThread::create(proxy.name(), proxy.url(), userAgent, workerScript, proxy );211 RefPtr<SharedWorkerThread> thread = SharedWorkerThread::create(proxy.name(), proxy.url(), userAgent, workerScript, proxy, proxy); 181 212 proxy.setThread(thread); 182 213 thread->start(); -
trunk/WebCore/workers/SharedWorkerContext.cpp
r46845 r47036 40 40 #include "NotImplemented.h" 41 41 #include "SharedWorkerThread.h" 42 #include "WorkerObjectProxy.h"43 42 44 43 namespace WebCore { … … 52 51 SharedWorkerContext::~SharedWorkerContext() 53 52 { 54 }55 56 void SharedWorkerContext::forwardException(const String&, int, const String&)57 {58 // FIXME: forward to console (do not need to report to parent context).59 }60 61 void SharedWorkerContext::addMessage(MessageDestination, MessageSource, MessageType, MessageLevel, const String&, unsigned, const String&)62 {63 // FIXME: forward to console.64 notImplemented();65 53 } 66 54 -
trunk/WebCore/workers/SharedWorkerContext.h
r46845 r47036 51 51 virtual bool isSharedWorkerContext() const { return true; } 52 52 53 // ScriptExecutionContext54 virtual void addMessage(MessageDestination, MessageSource, MessageType, MessageLevel, const String& message, unsigned lineNumber, const String& sourceURL);55 56 virtual void forwardException(const String& errorMessage, int lineNumber, const String& sourceURL);57 58 53 // EventTarget 59 54 virtual SharedWorkerContext* toSharedWorkerContext() { return this; } -
trunk/WebCore/workers/SharedWorkerThread.cpp
r46845 r47036 39 39 namespace WebCore { 40 40 41 PassRefPtr<SharedWorkerThread> SharedWorkerThread::create(const String& name, const KURL& scriptURL, const String& userAgent, const String& sourceCode, WorkerLoaderProxy& workerLoaderProxy )41 PassRefPtr<SharedWorkerThread> SharedWorkerThread::create(const String& name, const KURL& scriptURL, const String& userAgent, const String& sourceCode, WorkerLoaderProxy& workerLoaderProxy, WorkerReportingProxy& workerReportingProxy) 42 42 { 43 return adoptRef(new SharedWorkerThread(name, scriptURL, userAgent, sourceCode, workerLoaderProxy ));43 return adoptRef(new SharedWorkerThread(name, scriptURL, userAgent, sourceCode, workerLoaderProxy, workerReportingProxy)); 44 44 } 45 45 46 SharedWorkerThread::SharedWorkerThread(const String& name, const KURL& url, const String& userAgent, const String& sourceCode, WorkerLoaderProxy& workerLoaderProxy )47 : WorkerThread(url, userAgent, sourceCode, workerLoaderProxy )46 SharedWorkerThread::SharedWorkerThread(const String& name, const KURL& url, const String& userAgent, const String& sourceCode, WorkerLoaderProxy& workerLoaderProxy, WorkerReportingProxy& workerReportingProxy) 47 : WorkerThread(url, userAgent, sourceCode, workerLoaderProxy, workerReportingProxy) 48 48 , m_name(name.copy()) 49 49 { -
trunk/WebCore/workers/SharedWorkerThread.h
r46845 r47036 39 39 class SharedWorkerThread : public WorkerThread { 40 40 public: 41 static PassRefPtr<SharedWorkerThread> create(const String& name, const KURL&, const String& userAgent, const String& sourceCode, WorkerLoaderProxy& );41 static PassRefPtr<SharedWorkerThread> create(const String& name, const KURL&, const String& userAgent, const String& sourceCode, WorkerLoaderProxy&, WorkerReportingProxy&); 42 42 ~SharedWorkerThread(); 43 43 … … 46 46 47 47 private: 48 SharedWorkerThread(const String& name, const KURL&, const String& userAgent, const String& sourceCode, WorkerLoaderProxy& );48 SharedWorkerThread(const String& name, const KURL&, const String& userAgent, const String& sourceCode, WorkerLoaderProxy&, WorkerReportingProxy&); 49 49 50 50 String m_name; -
trunk/WebCore/workers/WorkerContext.cpp
r46845 r47036 65 65 WorkerContext::~WorkerContext() 66 66 { 67 ASSERT(currentThread() == thread()->threadID()); 68 // Notify proxy that we are going away. This can free the WorkerThread object, so do not access it after this. 69 thread()->workerReportingProxy().workerContextDestroyed(); 67 70 } 68 71 … … 110 113 111 114 m_closing = true; 115 // Notify parent that this context is closed. 116 thread()->workerReportingProxy().workerContextClosed(); 112 117 m_thread->stop(); 113 118 } … … 272 277 273 278 if (!errorHandled) 274 forwardException(errorMessage, lineNumber, sourceURL); 279 thread()->workerReportingProxy().postExceptionToWorkerObject(errorMessage, lineNumber, sourceURL); 280 } 281 282 void WorkerContext::addMessage(MessageDestination destination, MessageSource source, MessageType type, MessageLevel level, const String& message, unsigned lineNumber, const String& sourceURL) 283 { 284 thread()->workerReportingProxy().postConsoleMessageToWorkerObject(destination, source, type, level, message, lineNumber, sourceURL); 275 285 } 276 286 -
trunk/WebCore/workers/WorkerContext.h
r47022 r47036 49 49 class WorkerContext : public RefCounted<WorkerContext>, public ScriptExecutionContext, public EventTarget { 50 50 public: 51 52 51 virtual ~WorkerContext(); 53 52 … … 104 103 // ScriptExecutionContext 105 104 virtual void reportException(const String& errorMessage, int lineNumber, const String& sourceURL); 106 107 virtual void forwardException(const String& errorMessage, int lineNumber, const String& sourceURL) = 0; 105 virtual void addMessage(MessageDestination, MessageSource, MessageType, MessageLevel, const String& message, unsigned lineNumber, const String& sourceURL); 108 106 109 107 // These methods are used for GC marking. See JSWorkerContext::markChildren(MarkStack&) in -
trunk/WebCore/workers/WorkerObjectProxy.h
r45786 r47036 34 34 #if ENABLE(WORKERS) 35 35 36 #include " Console.h"36 #include "WorkerReportingProxy.h" 37 37 38 38 #include <wtf/PassOwnPtr.h> … … 41 41 42 42 class MessagePortChannel; 43 class String;44 43 45 44 // A proxy to talk to the worker object. 46 class WorkerObjectProxy {45 class WorkerObjectProxy : public WorkerReportingProxy { 47 46 public: 48 virtual ~WorkerObjectProxy() {}49 50 47 virtual void postMessageToWorkerObject(const String&, PassOwnPtr<MessagePortChannel>) = 0; 51 48 52 virtual void postExceptionToWorkerObject(const String& errorMessage, int lineNumber, const String& sourceURL) = 0;53 54 virtual void postConsoleMessageToWorkerObject(MessageDestination, MessageSource, MessageType, MessageLevel, const String& message, int lineNumber, const String& sourceURL) = 0;55 56 49 virtual void confirmMessageFromWorkerObject(bool hasPendingActivity) = 0; 57 58 50 virtual void reportPendingActivity(bool hasPendingActivity) = 0; 59 51 60 virtual void workerContextDestroyed() = 0; 52 // No need to notify the parent page context when dedicated workers are closing. 53 virtual void workerContextClosed() { } 61 54 }; 62 55 -
trunk/WebCore/workers/WorkerReportingProxy.h
r47035 r47036 29 29 */ 30 30 31 #ifndef Worker ObjectProxy_h32 #define Worker ObjectProxy_h31 #ifndef WorkerReportingProxy_h 32 #define WorkerReportingProxy_h 33 33 34 34 #if ENABLE(WORKERS) … … 36 36 #include "Console.h" 37 37 38 #include <wtf/PassOwnPtr.h>39 40 38 namespace WebCore { 41 39 42 class MessagePortChannel;43 40 class String; 44 41 45 // A proxy to talk to the worker object.46 class Worker ObjectProxy {42 // APIs used by workers to report console activity. 43 class WorkerReportingProxy { 47 44 public: 48 virtual ~WorkerObjectProxy() {} 49 50 virtual void postMessageToWorkerObject(const String&, PassOwnPtr<MessagePortChannel>) = 0; 45 virtual ~WorkerReportingProxy() {} 51 46 52 47 virtual void postExceptionToWorkerObject(const String& errorMessage, int lineNumber, const String& sourceURL) = 0; … … 54 49 virtual void postConsoleMessageToWorkerObject(MessageDestination, MessageSource, MessageType, MessageLevel, const String& message, int lineNumber, const String& sourceURL) = 0; 55 50 56 virtual void confirmMessageFromWorkerObject(bool hasPendingActivity) = 0; 51 // Invoked when close() is invoked on the worker context. 52 virtual void workerContextClosed() = 0; 57 53 58 virtual void reportPendingActivity(bool hasPendingActivity) = 0; 59 54 // Invoked when the thread has stopped. 60 55 virtual void workerContextDestroyed() = 0; 61 56 }; 62 63 57 } // namespace WebCore 64 58 65 59 #endif // ENABLE(WORKERS) 66 60 67 #endif // Worker ObjectProxy_h61 #endif // WorkerReportingProxy_h -
trunk/WebCore/workers/WorkerThread.cpp
r46507 r47036 62 62 } 63 63 64 WorkerThread::WorkerThread(const KURL& scriptURL, const String& userAgent, const String& sourceCode, WorkerLoaderProxy& workerLoaderProxy )64 WorkerThread::WorkerThread(const KURL& scriptURL, const String& userAgent, const String& sourceCode, WorkerLoaderProxy& workerLoaderProxy, WorkerReportingProxy& workerReportingProxy) 65 65 : m_threadID(0) 66 66 , m_workerLoaderProxy(workerLoaderProxy) 67 , m_workerReportingProxy(workerReportingProxy) 67 68 , m_startupData(WorkerThreadStartupData::create(scriptURL, userAgent, sourceCode)) 68 69 { -
trunk/WebCore/workers/WorkerThread.h
r46507 r47036 41 41 class WorkerContext; 42 42 class WorkerLoaderProxy; 43 class WorkerReportingProxy; 43 44 struct WorkerThreadStartupData; 44 45 … … 53 54 WorkerRunLoop& runLoop() { return m_runLoop; } 54 55 WorkerLoaderProxy& workerLoaderProxy() const { return m_workerLoaderProxy; } 56 WorkerReportingProxy& workerReportingProxy() const { return m_workerReportingProxy; } 55 57 56 58 protected: 57 WorkerThread(const KURL&, const String& userAgent, const String& sourceCode, WorkerLoaderProxy& );59 WorkerThread(const KURL&, const String& userAgent, const String& sourceCode, WorkerLoaderProxy&, WorkerReportingProxy&); 58 60 59 61 // Factory method for creating a new worker context for the thread. … … 73 75 WorkerRunLoop m_runLoop; 74 76 WorkerLoaderProxy& m_workerLoaderProxy; 77 WorkerReportingProxy& m_workerReportingProxy; 75 78 76 79 RefPtr<WorkerContext> m_workerContext;
Note: See TracChangeset
for help on using the changeset viewer.