2011-04-27 Dmitry Lomov <dslomov@google.com>
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 28 Apr 2011 06:21:34 +0000 (06:21 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 28 Apr 2011 06:21:34 +0000 (06:21 +0000)
        Reviewed by David Levin.

        CrossThreadCopier should not have a default specialization for raw pointers
        https://bugs.webkit.org/show_bug.cgi?id=59234
        Removed the ablity to pass raw pointers cross-thread
        Added and applied annotations for doing that

        * fileapi/FileReader.cpp:
        (WebCore::FileReader::readInternal):
        (WebCore::FileReader::abort):
        * fileapi/FileStreamProxy.cpp:
        (WebCore::FileStreamProxy::startOnFileThread):
        (WebCore::FileStreamProxy::stopOnFileThread):
        (WebCore::FileStreamProxy::getSize):
        (WebCore::FileStreamProxy::getSizeOnFileThread):
        (WebCore::FileStreamProxy::openForRead):
        (WebCore::FileStreamProxy::openForReadOnFileThread):
        (WebCore::FileStreamProxy::openForWrite):
        (WebCore::FileStreamProxy::openForWriteOnFileThread):
        (WebCore::FileStreamProxy::close):
        (WebCore::FileStreamProxy::read):
        (WebCore::FileStreamProxy::readOnFileThread):
        (WebCore::FileStreamProxy::write):
        (WebCore::FileStreamProxy::writeOnFileThread):
        (WebCore::FileStreamProxy::truncate):
        (WebCore::FileStreamProxy::truncateOnFileThread):
        * loader/WorkerThreadableLoader.cpp:
        (WebCore::WorkerThreadableLoader::MainThreadBridge::MainThreadBridge):
        (WebCore::WorkerThreadableLoader::MainThreadBridge::destroy):
        (WebCore::WorkerThreadableLoader::MainThreadBridge::cancel):
        * page/GeolocationPositionCache.cpp:
        (WebCore::GeolocationPositionCache::triggerReadFromDatabase):
        (WebCore::GeolocationPositionCache::triggerWriteToDatabase):
        * platform/CrossThreadCopier.h:
        (WebCore::AllowCrossThreadAccessWrapper::AllowCrossThreadAccessWrapper):
        (WebCore::AllowCrossThreadAccessWrapper::value):
        (WebCore::AllowCrossThreadAccess):
        (WebCore::AllowExtendedLifetimeWrapper::AllowExtendedLifetimeWrapper):
        (WebCore::AllowExtendedLifetimeWrapper::value):
        (WebCore::AllowExtendedLifetime):
        * platform/graphics/chromium/cc/CCCompletionEvent.h:
        * storage/IDBObjectStoreBackendImpl.cpp:
        (WebCore::IDBObjectStoreBackendImpl::get):
        (WebCore::IDBObjectStoreBackendImpl::put):
        (WebCore::IDBObjectStoreBackendImpl::deleteFunction):
        (WebCore::IDBObjectStoreBackendImpl::clear):
        (WebCore::IDBObjectStoreBackendImpl::createIndex):
        (WebCore::IDBObjectStoreBackendImpl::deleteIndex):
        (WebCore::IDBObjectStoreBackendImpl::openCursor):
        * storage/SQLCallbackWrapper.h:
        (WebCore::SQLCallbackWrapper::clear):
        * websockets/WorkerThreadableWebSocketChannel.cpp:
        (WebCore::WorkerThreadableWebSocketChannel::Bridge::mainThreadCreateWebSocketChannel):
        (WebCore::WorkerThreadableWebSocketChannel::Bridge::Bridge):
        (WebCore::WorkerThreadableWebSocketChannel::Bridge::connect):
        (WebCore::WorkerThreadableWebSocketChannel::Bridge::send):
        (WebCore::WorkerThreadableWebSocketChannel::Bridge::bufferedAmount):
        (WebCore::WorkerThreadableWebSocketChannel::Bridge::close):
        (WebCore::WorkerThreadableWebSocketChannel::Bridge::disconnect):
        (WebCore::WorkerThreadableWebSocketChannel::Bridge::suspend):
        (WebCore::WorkerThreadableWebSocketChannel::Bridge::resume):
        * workers/WorkerMessagingProxy.cpp:
        (WebCore::WorkerMessagingProxy::postConsoleMessageToWorkerObject):
2011-04-27  Dmitry Lomov  <dslomov@google.com>

        Reviewed by David Levin.

        CrossThreadCopier should not have a default specialization for raw pointers
        https://bugs.webkit.org/show_bug.cgi?id=59234
        Removed the ablity to pass raw pointers cross-thread
        Added and applied annotations for doing that

        * src/WebSharedWorkerImpl.cpp:
        (WebKit::WebSharedWorkerImpl::connect):
        (WebKit::WebSharedWorkerImpl::connectTask):
        * src/WebSharedWorkerImpl.h:
        * src/WebWorkerBase.cpp:
        (WebKit::WebWorkerBase::postMessageToWorkerObject):
        (WebKit::WebWorkerBase::postExceptionToWorkerObject):
        (WebKit::WebWorkerBase::postConsoleMessageToWorkerObject):
        (WebKit::WebWorkerBase::confirmMessageFromWorkerObject):
        (WebKit::WebWorkerBase::reportPendingActivity):
        (WebKit::WebWorkerBase::workerContextClosed):
        (WebKit::WebWorkerBase::workerContextDestroyed):
        * src/WebWorkerClientImpl.cpp:
        (WebKit::WebWorkerClientImpl::startWorkerContext):
        (WebKit::WebWorkerClientImpl::terminateWorkerContext):
        (WebKit::WebWorkerClientImpl::postMessageToWorkerContext):
        (WebKit::WebWorkerClientImpl::workerObjectDestroyed):
        (WebKit::WebWorkerClientImpl::postMessageToWorkerObject):
        (WebKit::WebWorkerClientImpl::postExceptionToWorkerObject):
        (WebKit::WebWorkerClientImpl::postConsoleMessageToWorkerObject):
        (WebKit::WebWorkerClientImpl::confirmMessageFromWorkerObject):
        (WebKit::WebWorkerClientImpl::reportPendingActivity):
        * src/WebWorkerImpl.cpp:
        (WebKit::WebWorkerImpl::postMessageToWorkerContext):
        * src/WorkerFileSystemCallbacksBridge.cpp:
        (WebKit::WorkerFileSystemCallbacksBridge::postOpenFileSystemToMainThread):
        (WebKit::WorkerFileSystemCallbacksBridge::postMoveToMainThread):
        (WebKit::WorkerFileSystemCallbacksBridge::postCopyToMainThread):
        (WebKit::WorkerFileSystemCallbacksBridge::postRemoveToMainThread):
        (WebKit::WorkerFileSystemCallbacksBridge::postRemoveRecursivelyToMainThread):
        (WebKit::WorkerFileSystemCallbacksBridge::postReadMetadataToMainThread):
        (WebKit::WorkerFileSystemCallbacksBridge::postCreateFileToMainThread):
        (WebKit::WorkerFileSystemCallbacksBridge::postCreateDirectoryToMainThread):
        (WebKit::WorkerFileSystemCallbacksBridge::postFileExistsToMainThread):
        (WebKit::WorkerFileSystemCallbacksBridge::postDirectoryExistsToMainThread):
        (WebKit::WorkerFileSystemCallbacksBridge::postReadDirectoryToMainThread):
        (WebKit::WorkerFileSystemCallbacksBridge::didFailOnMainThread):
        (WebKit::WorkerFileSystemCallbacksBridge::didOpenFileSystemOnMainThread):
        (WebKit::WorkerFileSystemCallbacksBridge::didSucceedOnMainThread):
        (WebKit::WorkerFileSystemCallbacksBridge::didReadMetadataOnMainThread):
        (WebKit::WorkerFileSystemCallbacksBridge::didReadDirectoryOnMainThread):
        * src/WorkerFileWriterCallbacksBridge.cpp:
        (WebKit::WorkerFileWriterCallbacksBridge::postWriteToMainThread):
        (WebKit::WorkerFileWriterCallbacksBridge::postTruncateToMainThread):
        (WebKit::WorkerFileWriterCallbacksBridge::postAbortToMainThread):
        (WebKit::WorkerFileWriterCallbacksBridge::didWrite):
        (WebKit::WorkerFileWriterCallbacksBridge::didFail):
        (WebKit::WorkerFileWriterCallbacksBridge::didTruncate):
        (WebKit::WorkerFileWriterCallbacksBridge::postInitToMainThread):
        (WebKit::WorkerFileWriterCallbacksBridge::dispatchTaskToMainThread):
        (WebKit::WorkerFileWriterCallbacksBridge::dispatchTaskToWorkerThread):
        * tests/CCThreadTest.cpp:
        (WebCore::TEST):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@85165 268f45cc-cd09-0410-ab3c-d52691b4dbfc

20 files changed:
Source/WebCore/ChangeLog
Source/WebCore/fileapi/FileReader.cpp
Source/WebCore/fileapi/FileStreamProxy.cpp
Source/WebCore/loader/WorkerThreadableLoader.cpp
Source/WebCore/page/GeolocationPositionCache.cpp
Source/WebCore/platform/CrossThreadCopier.h
Source/WebCore/platform/graphics/chromium/cc/CCCompletionEvent.h
Source/WebCore/storage/IDBObjectStoreBackendImpl.cpp
Source/WebCore/storage/SQLCallbackWrapper.h
Source/WebCore/websockets/WorkerThreadableWebSocketChannel.cpp
Source/WebCore/workers/WorkerMessagingProxy.cpp
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/src/WebSharedWorkerImpl.cpp
Source/WebKit/chromium/src/WebSharedWorkerImpl.h
Source/WebKit/chromium/src/WebWorkerBase.cpp
Source/WebKit/chromium/src/WebWorkerClientImpl.cpp
Source/WebKit/chromium/src/WebWorkerImpl.cpp
Source/WebKit/chromium/src/WorkerFileSystemCallbacksBridge.cpp
Source/WebKit/chromium/src/WorkerFileWriterCallbacksBridge.cpp
Source/WebKit/chromium/tests/CCThreadTest.cpp

index db59088..9ae53f6 100644 (file)
@@ -1,3 +1,69 @@
+2011-04-27  Dmitry Lomov  <dslomov@google.com>
+
+        Reviewed by David Levin.
+
+        CrossThreadCopier should not have a default specialization for raw pointers
+        https://bugs.webkit.org/show_bug.cgi?id=59234
+        Removed the ablity to pass raw pointers cross-thread
+        Added and applied annotations for doing that
+
+        * fileapi/FileReader.cpp:
+        (WebCore::FileReader::readInternal):
+        (WebCore::FileReader::abort):
+        * fileapi/FileStreamProxy.cpp:
+        (WebCore::FileStreamProxy::startOnFileThread):
+        (WebCore::FileStreamProxy::stopOnFileThread):
+        (WebCore::FileStreamProxy::getSize):
+        (WebCore::FileStreamProxy::getSizeOnFileThread):
+        (WebCore::FileStreamProxy::openForRead):
+        (WebCore::FileStreamProxy::openForReadOnFileThread):
+        (WebCore::FileStreamProxy::openForWrite):
+        (WebCore::FileStreamProxy::openForWriteOnFileThread):
+        (WebCore::FileStreamProxy::close):
+        (WebCore::FileStreamProxy::read):
+        (WebCore::FileStreamProxy::readOnFileThread):
+        (WebCore::FileStreamProxy::write):
+        (WebCore::FileStreamProxy::writeOnFileThread):
+        (WebCore::FileStreamProxy::truncate):
+        (WebCore::FileStreamProxy::truncateOnFileThread):
+        * loader/WorkerThreadableLoader.cpp:
+        (WebCore::WorkerThreadableLoader::MainThreadBridge::MainThreadBridge):
+        (WebCore::WorkerThreadableLoader::MainThreadBridge::destroy):
+        (WebCore::WorkerThreadableLoader::MainThreadBridge::cancel):
+        * page/GeolocationPositionCache.cpp:
+        (WebCore::GeolocationPositionCache::triggerReadFromDatabase):
+        (WebCore::GeolocationPositionCache::triggerWriteToDatabase):
+        * platform/CrossThreadCopier.h:
+        (WebCore::AllowCrossThreadAccessWrapper::AllowCrossThreadAccessWrapper):
+        (WebCore::AllowCrossThreadAccessWrapper::value):
+        (WebCore::AllowCrossThreadAccess):
+        (WebCore::AllowExtendedLifetimeWrapper::AllowExtendedLifetimeWrapper):
+        (WebCore::AllowExtendedLifetimeWrapper::value):
+        (WebCore::AllowExtendedLifetime):
+        * platform/graphics/chromium/cc/CCCompletionEvent.h:
+        * storage/IDBObjectStoreBackendImpl.cpp:
+        (WebCore::IDBObjectStoreBackendImpl::get):
+        (WebCore::IDBObjectStoreBackendImpl::put):
+        (WebCore::IDBObjectStoreBackendImpl::deleteFunction):
+        (WebCore::IDBObjectStoreBackendImpl::clear):
+        (WebCore::IDBObjectStoreBackendImpl::createIndex):
+        (WebCore::IDBObjectStoreBackendImpl::deleteIndex):
+        (WebCore::IDBObjectStoreBackendImpl::openCursor):
+        * storage/SQLCallbackWrapper.h:
+        (WebCore::SQLCallbackWrapper::clear):
+        * websockets/WorkerThreadableWebSocketChannel.cpp:
+        (WebCore::WorkerThreadableWebSocketChannel::Bridge::mainThreadCreateWebSocketChannel):
+        (WebCore::WorkerThreadableWebSocketChannel::Bridge::Bridge):
+        (WebCore::WorkerThreadableWebSocketChannel::Bridge::connect):
+        (WebCore::WorkerThreadableWebSocketChannel::Bridge::send):
+        (WebCore::WorkerThreadableWebSocketChannel::Bridge::bufferedAmount):
+        (WebCore::WorkerThreadableWebSocketChannel::Bridge::close):
+        (WebCore::WorkerThreadableWebSocketChannel::Bridge::disconnect):
+        (WebCore::WorkerThreadableWebSocketChannel::Bridge::suspend):
+        (WebCore::WorkerThreadableWebSocketChannel::Bridge::resume):
+        * workers/WorkerMessagingProxy.cpp:
+        (WebCore::WorkerMessagingProxy::postConsoleMessageToWorkerObject):
+
 2011-04-27  Adam Barth  <abarth@webkit.org>
 
         Two build fixes from the future.  (Trivial strict OwnPtr fixes.)
index c23ab77..f251fc1 100644 (file)
@@ -129,7 +129,7 @@ void FileReader::readInternal(Blob* blob, FileReaderLoader::ReadType type)
         return;
 
     if (m_state == None)
-        scriptExecutionContext()->postTask(createCallbackTask(&delayedStart, this));
+        scriptExecutionContext()->postTask(createCallbackTask(&delayedStart, AllowAccessLater(this)));
 
     m_blob = blob;
     m_readType = type;
@@ -150,7 +150,8 @@ void FileReader::abort()
     m_state = Aborting;
 
     // Schedule to have the abort done later since abort() might be called from the event handler and we do not want the resource loading code to be in the stack.
-    scriptExecutionContext()->postTask(createCallbackTask(&delayedAbort, this));
+    scriptExecutionContext()->postTask(
+        createCallbackTask(&delayedAbort, AllowAccessLater(this)));
 }
 
 void FileReader::doAbort()
index 92b07cd..d435065 100644 (file)
@@ -86,7 +86,7 @@ void FileStreamProxy::startOnFileThread()
     if (!client())
         return;
     m_stream->start();
-    m_context->postTask(createCallbackTask(&didStart, this));
+    m_context->postTask(createCallbackTask(&didStart, AllowCrossThreadAccess(this)));
 }
 
 void FileStreamProxy::stop()
@@ -107,7 +107,7 @@ static void derefProxyOnContext(ScriptExecutionContext*, FileStreamProxy* proxy)
 void FileStreamProxy::stopOnFileThread()
 {
     m_stream->stop();
-    m_context->postTask(createCallbackTask(&derefProxyOnContext, this));
+    m_context->postTask(createCallbackTask(&derefProxyOnContext, AllowCrossThreadAccess(this)));
 }
 
 static void didGetSize(ScriptExecutionContext*, FileStreamProxy* proxy, long long size)
@@ -124,7 +124,7 @@ void FileStreamProxy::getSize(const String& path, double expectedModificationTim
 void FileStreamProxy::getSizeOnFileThread(const String& path, double expectedModificationTime)
 {
     long long size = m_stream->getSize(path, expectedModificationTime);
-    m_context->postTask(createCallbackTask(&didGetSize, this, size));
+    m_context->postTask(createCallbackTask(&didGetSize, AllowCrossThreadAccess(this), size));
 }
 
 static void didOpen(ScriptExecutionContext*, FileStreamProxy* proxy, bool success)
@@ -141,18 +141,20 @@ void FileStreamProxy::openForRead(const String& path, long long offset, long lon
 void FileStreamProxy::openForReadOnFileThread(const String& path, long long offset, long long length)
 {
     bool success = m_stream->openForRead(path, offset, length);
-    m_context->postTask(createCallbackTask(&didOpen, this, success));
+    m_context->postTask(createCallbackTask(&didOpen, AllowCrossThreadAccess(this), success));
 }
 
 void FileStreamProxy::openForWrite(const String& path)
 {
-    fileThread()->postTask(createFileThreadTask(this, &FileStreamProxy::openForWriteOnFileThread, path));
+    fileThread()->postTask(
+        createFileThreadTask(this,
+                             &FileStreamProxy::openForWriteOnFileThread, path));
 }
 
 void FileStreamProxy::openForWriteOnFileThread(const String& path)
 {
     bool success = m_stream->openForWrite(path);
-    m_context->postTask(createCallbackTask(&didOpen, this, success));
+    m_context->postTask(createCallbackTask(&didOpen, AllowCrossThreadAccess(this), success));
 }
 
 void FileStreamProxy::close()
@@ -173,13 +175,15 @@ static void didRead(ScriptExecutionContext*, FileStreamProxy* proxy, int bytesRe
 
 void FileStreamProxy::read(char* buffer, int length)
 {
-    fileThread()->postTask(createFileThreadTask(this, &FileStreamProxy::readOnFileThread, buffer, length));
+    fileThread()->postTask(
+        createFileThreadTask(this, &FileStreamProxy::readOnFileThread,
+                             AllowCrossThreadAccess(buffer), length));
 }
 
 void FileStreamProxy::readOnFileThread(char* buffer, int length)
 {
     int bytesRead = m_stream->read(buffer, length);
-    m_context->postTask(createCallbackTask(&didRead, this, bytesRead));
+    m_context->postTask(createCallbackTask(&didRead, AllowCrossThreadAccess(this), bytesRead));
 }
 
 static void didWrite(ScriptExecutionContext*, FileStreamProxy* proxy, int bytesWritten)
@@ -196,7 +200,7 @@ void FileStreamProxy::write(const KURL& blobURL, long long position, int length)
 void FileStreamProxy::writeOnFileThread(const KURL& blobURL, long long position, int length)
 {
     int bytesWritten = m_stream->write(blobURL, position, length);
-    m_context->postTask(createCallbackTask(&didWrite, this, bytesWritten));
+    m_context->postTask(createCallbackTask(&didWrite, AllowCrossThreadAccess(this), bytesWritten));
 }
 
 static void didTruncate(ScriptExecutionContext*, FileStreamProxy* proxy, bool success)
@@ -213,7 +217,7 @@ void FileStreamProxy::truncate(long long position)
 void FileStreamProxy::truncateOnFileThread(long long position)
 {
     bool success = m_stream->truncate(position);
-    m_context->postTask(createCallbackTask(&didTruncate, this, success));
+    m_context->postTask(createCallbackTask(&didTruncate, AllowCrossThreadAccess(this), success));
 }
 
 } // namespace WebCore
index 6672eee..097c625 100644 (file)
@@ -95,7 +95,9 @@ WorkerThreadableLoader::MainThreadBridge::MainThreadBridge(PassRefPtr<Threadable
     , m_taskMode(taskMode.crossThreadString())
 {
     ASSERT(m_workerClientWrapper.get());
-    m_loaderProxy.postTaskToLoader(createCallbackTask(&MainThreadBridge::mainThreadCreateLoader, this, request, options, outgoingReferrer));
+    m_loaderProxy.postTaskToLoader(
+        createCallbackTask(&MainThreadBridge::mainThreadCreateLoader, 
+                           AllowCrossThreadAccess(this), request, options, outgoingReferrer));
 }
 
 WorkerThreadableLoader::MainThreadBridge::~MainThreadBridge()
@@ -129,7 +131,8 @@ void WorkerThreadableLoader::MainThreadBridge::destroy()
     clearClientWrapper();
 
     // "delete this" and m_mainThreadLoader::deref() on the worker object's thread.
-    m_loaderProxy.postTaskToLoader(createCallbackTask(&MainThreadBridge::mainThreadDestroy, this));
+    m_loaderProxy.postTaskToLoader(
+        createCallbackTask(&MainThreadBridge::mainThreadDestroy, AllowCrossThreadAccess(this)));
 }
 
 void WorkerThreadableLoader::MainThreadBridge::mainThreadCancel(ScriptExecutionContext* context, MainThreadBridge* thisPtr)
@@ -145,7 +148,8 @@ void WorkerThreadableLoader::MainThreadBridge::mainThreadCancel(ScriptExecutionC
 
 void WorkerThreadableLoader::MainThreadBridge::cancel()
 {
-    m_loaderProxy.postTaskToLoader(createCallbackTask(&MainThreadBridge::mainThreadCancel, this));
+    m_loaderProxy.postTaskToLoader(
+        createCallbackTask(&MainThreadBridge::mainThreadCancel, AllowCrossThreadAccess(this)));
     ThreadableLoaderClientWrapper* clientWrapper = m_workerClientWrapper.get();
     if (!clientWrapper->done()) {
         // If the client hasn't reached a termination state, then transition it by sending a cancellation error.
index 5a0f42d..a42f2ec 100644 (file)
@@ -128,7 +128,7 @@ void GeolocationPositionCache::threadEntryPointImpl()
 
 void GeolocationPositionCache::triggerReadFromDatabase()
 {
-    m_queue.append(createCallbackTask(&GeolocationPositionCache::readFromDatabase, this));
+    m_queue.append(createCallbackTask(&GeolocationPositionCache::readFromDatabase, AllowCrossThreadAccess(this)));
 }
 
 void GeolocationPositionCache::readFromDatabase(ScriptExecutionContext*, GeolocationPositionCache* cache)
@@ -187,7 +187,7 @@ void GeolocationPositionCache::readFromDatabaseImpl()
 
 void GeolocationPositionCache::triggerWriteToDatabase()
 {
-    m_queue.append(createCallbackTask(writeToDatabase, this));
+    m_queue.append(createCallbackTask(writeToDatabase, AllowCrossThreadAccess(this)));
 }
 
 void GeolocationPositionCache::writeToDatabase(ScriptExecutionContext*, GeolocationPositionCache* cache)
index a25d6fa..b266d25 100644 (file)
@@ -62,10 +62,6 @@ namespace WebCore {
     template<typename T> struct CrossThreadCopierBase<true, false, T> : public CrossThreadCopierPassThrough<T> {
     };
 
-    // Pointers get passed through without any significant changes.
-    template<typename T> struct CrossThreadCopierBase<false, false, T*> : public CrossThreadCopierPassThrough<T*> {
-    };
-
     template<> struct CrossThreadCopierBase<false, false, ThreadableLoaderOptions> : public CrossThreadCopierPassThrough<ThreadableLoaderOptions> {
     };
 
@@ -119,6 +115,45 @@ namespace WebCore {
                                                                                  T> {
     };
 
+    template<typename T> struct AllowCrossThreadAccessWrapper {
+    public:
+        explicit AllowCrossThreadAccessWrapper(T* value) : m_value(value) { }
+        T* value() const { return m_value; }
+    private:
+        T* m_value;
+    };
+
+    template<typename T> struct CrossThreadCopierBase<false, false, AllowCrossThreadAccessWrapper<T> > {
+        typedef T* Type;
+        static Type copy(const AllowCrossThreadAccessWrapper<T>& wrapper) { return wrapper.value(); }
+    };
+
+    template<typename T> AllowCrossThreadAccessWrapper<T> AllowCrossThreadAccess(T* value) 
+    {
+        return AllowCrossThreadAccessWrapper<T>(value);
+    }
+
+    // FIXME: Move to a different header file. AllowAccessLater is for cross-thread access
+    // that is not cross-thread (tasks posted to a queue guaranteed to run on the same thread).
+    template<typename T> struct AllowAccessLaterWrapper {
+    public:
+        explicit AllowAccessLaterWrapper(T* value) : m_value(value) { }
+        T* value() const { return m_value; }
+    private:
+        T* m_value;
+    };
+
+    template<typename T> struct CrossThreadCopierBase<false, false, AllowAccessLaterWrapper<T> > {
+        typedef T* Type;
+        static Type copy(const AllowAccessLaterWrapper<T>& wrapper) { return wrapper.value(); }
+    };
+
+    template<typename T> AllowAccessLaterWrapper<T> AllowAccessLater(T* value)
+    {
+        return AllowAccessLaterWrapper<T>(value);
+    }
+
+
 } // namespace WebCore
 
 #endif // CrossThreadCopier_h
index cbfb340..565376f 100644 (file)
@@ -384,8 +384,11 @@ PassRefPtr<IDBIndexBackendInterface> IDBObjectStoreBackendImpl::createIndex(cons
 
     RefPtr<IDBObjectStoreBackendImpl> objectStore = this;
     RefPtr<IDBTransactionBackendInterface> transactionPtr = transaction;
-    if (!transaction->scheduleTask(createCallbackTask(&IDBObjectStoreBackendImpl::createIndexInternal, objectStore, index, transaction),
-                                   createCallbackTask(&IDBObjectStoreBackendImpl::removeIndexFromMap, objectStore, index))) {
+    if (!transaction->scheduleTask(
+              createCallbackTask(&IDBObjectStoreBackendImpl::createIndexInternal,
+                                 objectStore, index, transactionPtr),
+              createCallbackTask(&IDBObjectStoreBackendImpl::removeIndexFromMap,
+                                 objectStore, index))) {
         ec = IDBDatabaseException::NOT_ALLOWED_ERR;
         return 0;
     }
@@ -437,8 +440,11 @@ void IDBObjectStoreBackendImpl::deleteIndex(const String& name, IDBTransactionBa
 
     RefPtr<IDBObjectStoreBackendImpl> objectStore = this;
     RefPtr<IDBTransactionBackendInterface> transactionPtr = transaction;
-    if (!transaction->scheduleTask(createCallbackTask(&IDBObjectStoreBackendImpl::deleteIndexInternal, objectStore, index, transactionPtr),
-                                   createCallbackTask(&IDBObjectStoreBackendImpl::addIndexToMap, objectStore, index))) {
+    if (!transaction->scheduleTask(
+              createCallbackTask(&IDBObjectStoreBackendImpl::deleteIndexInternal,
+                                 objectStore, index, transactionPtr),
+              createCallbackTask(&IDBObjectStoreBackendImpl::addIndexToMap,
+                                 objectStore, index))) {
         ec = IDBDatabaseException::NOT_ALLOWED_ERR;
         return;
     }
@@ -451,14 +457,17 @@ void IDBObjectStoreBackendImpl::deleteIndexInternal(ScriptExecutionContext*, Pas
     transaction->didCompleteTaskEvents();
 }
 
-void IDBObjectStoreBackendImpl::openCursor(PassRefPtr<IDBKeyRange> prpRange, unsigned short direction, PassRefPtr<IDBCallbacks> prpCallbacks, IDBTransactionBackendInterface* transactionPtr, ExceptionCode& ec)
+void IDBObjectStoreBackendImpl::openCursor(PassRefPtr<IDBKeyRange> prpRange, unsigned short direction, PassRefPtr<IDBCallbacks> prpCallbacks, IDBTransactionBackendInterface* transaction, ExceptionCode& ec)
 {
     RefPtr<IDBObjectStoreBackendImpl> objectStore = this;
     RefPtr<IDBKeyRange> range = prpRange;
     RefPtr<IDBCallbacks> callbacks = prpCallbacks;
-    RefPtr<IDBTransactionBackendInterface> transaction = transactionPtr;
-    if (!transaction->scheduleTask(createCallbackTask(&IDBObjectStoreBackendImpl::openCursorInternal, objectStore, range, direction, callbacks, transaction)))
+    RefPtr<IDBTransactionBackendInterface> transactionPtr = transaction;
+    if (!transaction->scheduleTask(
+            createCallbackTask(&IDBObjectStoreBackendImpl::openCursorInternal,
+                               objectStore, range, direction, callbacks, transactionPtr))) {
         ec = IDBDatabaseException::NOT_ALLOWED_ERR;
+    }
 }
 
 void IDBObjectStoreBackendImpl::openCursorInternal(ScriptExecutionContext*, PassRefPtr<IDBObjectStoreBackendImpl> objectStore, PassRefPtr<IDBKeyRange> range, unsigned short tmpDirection, PassRefPtr<IDBCallbacks> callbacks, PassRefPtr<IDBTransactionBackendInterface> transaction)
index 38059fa..81e34fa 100644 (file)
@@ -74,7 +74,7 @@ public:
             context = m_scriptExecutionContext.release().leakRef();
             callback = m_callback.release().leakRef();
         }
-        context->postTask(createCallbackTask(&safeRelease, callback));
+        context->postTask(createCallbackTask(&safeRelease, AllowAccessLater(callback)));
     }
 
     PassRefPtr<T> unwrap()
index fd82591..5d84495 100644 (file)
@@ -246,7 +246,10 @@ void WorkerThreadableWebSocketChannel::Bridge::mainThreadCreateWebSocketChannel(
     ASSERT_UNUSED(context, context->isDocument());
 
     Peer* peer = Peer::create(clientWrapper, thisPtr->m_loaderProxy, context, taskMode, url, protocol);
-    thisPtr->m_loaderProxy.postTaskForModeToWorkerContext(createCallbackTask(&Bridge::setWebSocketChannel, thisPtr, peer, clientWrapper), taskMode);
+    thisPtr->m_loaderProxy.postTaskForModeToWorkerContext(
+        createCallbackTask(&Bridge::setWebSocketChannel,
+                           AllowCrossThreadAccess(thisPtr),
+                           AllowCrossThreadAccess(peer), clientWrapper), taskMode);
 }
 
 WorkerThreadableWebSocketChannel::Bridge::Bridge(PassRefPtr<ThreadableWebSocketChannelClientWrapper> workerClientWrapper, PassRefPtr<WorkerContext> workerContext, const String& taskMode, const KURL& url, const String& protocol)
@@ -258,7 +261,9 @@ WorkerThreadableWebSocketChannel::Bridge::Bridge(PassRefPtr<ThreadableWebSocketC
 {
     ASSERT(m_workerClientWrapper.get());
     setMethodNotCompleted();
-    m_loaderProxy.postTaskToLoader(createCallbackTask(&Bridge::mainThreadCreateWebSocketChannel, this, m_workerClientWrapper, m_taskMode, url, protocol));
+    m_loaderProxy.postTaskToLoader(
+        createCallbackTask(&Bridge::mainThreadCreateWebSocketChannel,
+                           AllowCrossThreadAccess(this), m_workerClientWrapper, m_taskMode, url, protocol));
     waitForMethodCompletion();
     ASSERT(m_peer);
 }
@@ -281,7 +286,8 @@ void WorkerThreadableWebSocketChannel::Bridge::connect()
 {
     ASSERT(m_workerClientWrapper);
     ASSERT(m_peer);
-    m_loaderProxy.postTaskToLoader(createCallbackTask(&WorkerThreadableWebSocketChannel::mainThreadConnect, m_peer));
+    m_loaderProxy.postTaskToLoader(
+        createCallbackTask(&WorkerThreadableWebSocketChannel::mainThreadConnect, AllowCrossThreadAccess(m_peer)));
 }
 
 void WorkerThreadableWebSocketChannel::mainThreadSend(ScriptExecutionContext* context, Peer* peer, const String& message)
@@ -299,7 +305,9 @@ bool WorkerThreadableWebSocketChannel::Bridge::send(const String& message)
         return false;
     ASSERT(m_peer);
     setMethodNotCompleted();
-    m_loaderProxy.postTaskToLoader(createCallbackTask(&WorkerThreadableWebSocketChannel::mainThreadSend, m_peer, message));
+    m_loaderProxy.postTaskToLoader(
+        createCallbackTask(&WorkerThreadableWebSocketChannel::mainThreadSend,
+                           AllowCrossThreadAccess(m_peer), message));
     RefPtr<Bridge> protect(this);
     waitForMethodCompletion();
     ThreadableWebSocketChannelClientWrapper* clientWrapper = m_workerClientWrapper.get();
@@ -321,7 +329,8 @@ unsigned long WorkerThreadableWebSocketChannel::Bridge::bufferedAmount()
         return 0;
     ASSERT(m_peer);
     setMethodNotCompleted();
-    m_loaderProxy.postTaskToLoader(createCallbackTask(&WorkerThreadableWebSocketChannel::mainThreadBufferedAmount, m_peer));
+    m_loaderProxy.postTaskToLoader(
+        createCallbackTask(&WorkerThreadableWebSocketChannel::mainThreadBufferedAmount, AllowCrossThreadAccess(m_peer)));
     RefPtr<Bridge> protect(this);
     waitForMethodCompletion();
     ThreadableWebSocketChannelClientWrapper* clientWrapper = m_workerClientWrapper.get();
@@ -342,7 +351,8 @@ void WorkerThreadableWebSocketChannel::mainThreadClose(ScriptExecutionContext* c
 void WorkerThreadableWebSocketChannel::Bridge::close()
 {
     ASSERT(m_peer);
-    m_loaderProxy.postTaskToLoader(createCallbackTask(&WorkerThreadableWebSocketChannel::mainThreadClose, m_peer));
+    m_loaderProxy.postTaskToLoader(
+        createCallbackTask(&WorkerThreadableWebSocketChannel::mainThreadClose, AllowCrossThreadAccess(m_peer)));
 }
 
 void WorkerThreadableWebSocketChannel::mainThreadDestroy(ScriptExecutionContext* context, Peer* peer)
@@ -360,7 +370,8 @@ void WorkerThreadableWebSocketChannel::Bridge::disconnect()
     if (m_peer) {
         Peer* peer = m_peer;
         m_peer = 0;
-        m_loaderProxy.postTaskToLoader(createCallbackTask(&mainThreadDestroy, peer));
+        m_loaderProxy.postTaskToLoader(
+            createCallbackTask(&mainThreadDestroy, AllowCrossThreadAccess(peer)));
     }
     m_workerContext = 0;
 }
@@ -377,7 +388,8 @@ void WorkerThreadableWebSocketChannel::mainThreadSuspend(ScriptExecutionContext*
 void WorkerThreadableWebSocketChannel::Bridge::suspend()
 {
     ASSERT(m_peer);
-    m_loaderProxy.postTaskToLoader(createCallbackTask(&WorkerThreadableWebSocketChannel::mainThreadSuspend, m_peer));
+    m_loaderProxy.postTaskToLoader(
+        createCallbackTask(&WorkerThreadableWebSocketChannel::mainThreadSuspend, AllowCrossThreadAccess(m_peer)));
 }
 
 void WorkerThreadableWebSocketChannel::mainThreadResume(ScriptExecutionContext* context, Peer* peer)
@@ -392,7 +404,8 @@ void WorkerThreadableWebSocketChannel::mainThreadResume(ScriptExecutionContext*
 void WorkerThreadableWebSocketChannel::Bridge::resume()
 {
     ASSERT(m_peer);
-    m_loaderProxy.postTaskToLoader(createCallbackTask(&WorkerThreadableWebSocketChannel::mainThreadResume, m_peer));
+    m_loaderProxy.postTaskToLoader(
+        createCallbackTask(&WorkerThreadableWebSocketChannel::mainThreadResume, AllowCrossThreadAccess(m_peer)));
 }
 
 void WorkerThreadableWebSocketChannel::Bridge::clearClientWrapper()
index 9e76dbe..ad69e16 100644 (file)
@@ -288,7 +288,9 @@ static void postConsoleMessageTask(ScriptExecutionContext* context, WorkerMessag
 
 void WorkerMessagingProxy::postConsoleMessageToWorkerObject(MessageSource source, MessageType type, MessageLevel level, const String& message, int lineNumber, const String& sourceURL)
 {
-    m_scriptExecutionContext->postTask(createCallbackTask(&postConsoleMessageTask, this, source, type, level, message, lineNumber, sourceURL));
+    m_scriptExecutionContext->postTask(
+        createCallbackTask(&postConsoleMessageTask, AllowCrossThreadAccess(this),
+                           source, type, level, message, lineNumber, sourceURL));
 }
 
 void WorkerMessagingProxy::workerThreadCreated(PassRefPtr<DedicatedWorkerThread> workerThread)
index c7a9241..332c167 100644 (file)
@@ -1,3 +1,66 @@
+2011-04-27  Dmitry Lomov  <dslomov@google.com>
+
+        Reviewed by David Levin.
+        
+        CrossThreadCopier should not have a default specialization for raw pointers
+        https://bugs.webkit.org/show_bug.cgi?id=59234
+        Removed the ablity to pass raw pointers cross-thread
+        Added and applied annotations for doing that
+
+        * src/WebSharedWorkerImpl.cpp:
+        (WebKit::WebSharedWorkerImpl::connect):
+        (WebKit::WebSharedWorkerImpl::connectTask):
+        * src/WebSharedWorkerImpl.h:
+        * src/WebWorkerBase.cpp:
+        (WebKit::WebWorkerBase::postMessageToWorkerObject):
+        (WebKit::WebWorkerBase::postExceptionToWorkerObject):
+        (WebKit::WebWorkerBase::postConsoleMessageToWorkerObject):
+        (WebKit::WebWorkerBase::confirmMessageFromWorkerObject):
+        (WebKit::WebWorkerBase::reportPendingActivity):
+        (WebKit::WebWorkerBase::workerContextClosed):
+        (WebKit::WebWorkerBase::workerContextDestroyed):
+        * src/WebWorkerClientImpl.cpp:
+        (WebKit::WebWorkerClientImpl::startWorkerContext):
+        (WebKit::WebWorkerClientImpl::terminateWorkerContext):
+        (WebKit::WebWorkerClientImpl::postMessageToWorkerContext):
+        (WebKit::WebWorkerClientImpl::workerObjectDestroyed):
+        (WebKit::WebWorkerClientImpl::postMessageToWorkerObject):
+        (WebKit::WebWorkerClientImpl::postExceptionToWorkerObject):
+        (WebKit::WebWorkerClientImpl::postConsoleMessageToWorkerObject):
+        (WebKit::WebWorkerClientImpl::confirmMessageFromWorkerObject):
+        (WebKit::WebWorkerClientImpl::reportPendingActivity):
+        * src/WebWorkerImpl.cpp:
+        (WebKit::WebWorkerImpl::postMessageToWorkerContext):
+        * src/WorkerFileSystemCallbacksBridge.cpp:
+        (WebKit::WorkerFileSystemCallbacksBridge::postOpenFileSystemToMainThread):
+        (WebKit::WorkerFileSystemCallbacksBridge::postMoveToMainThread):
+        (WebKit::WorkerFileSystemCallbacksBridge::postCopyToMainThread):
+        (WebKit::WorkerFileSystemCallbacksBridge::postRemoveToMainThread):
+        (WebKit::WorkerFileSystemCallbacksBridge::postRemoveRecursivelyToMainThread):
+        (WebKit::WorkerFileSystemCallbacksBridge::postReadMetadataToMainThread):
+        (WebKit::WorkerFileSystemCallbacksBridge::postCreateFileToMainThread):
+        (WebKit::WorkerFileSystemCallbacksBridge::postCreateDirectoryToMainThread):
+        (WebKit::WorkerFileSystemCallbacksBridge::postFileExistsToMainThread):
+        (WebKit::WorkerFileSystemCallbacksBridge::postDirectoryExistsToMainThread):
+        (WebKit::WorkerFileSystemCallbacksBridge::postReadDirectoryToMainThread):
+        (WebKit::WorkerFileSystemCallbacksBridge::didFailOnMainThread):
+        (WebKit::WorkerFileSystemCallbacksBridge::didOpenFileSystemOnMainThread):
+        (WebKit::WorkerFileSystemCallbacksBridge::didSucceedOnMainThread):
+        (WebKit::WorkerFileSystemCallbacksBridge::didReadMetadataOnMainThread):
+        (WebKit::WorkerFileSystemCallbacksBridge::didReadDirectoryOnMainThread):
+        * src/WorkerFileWriterCallbacksBridge.cpp:
+        (WebKit::WorkerFileWriterCallbacksBridge::postWriteToMainThread):
+        (WebKit::WorkerFileWriterCallbacksBridge::postTruncateToMainThread):
+        (WebKit::WorkerFileWriterCallbacksBridge::postAbortToMainThread):
+        (WebKit::WorkerFileWriterCallbacksBridge::didWrite):
+        (WebKit::WorkerFileWriterCallbacksBridge::didFail):
+        (WebKit::WorkerFileWriterCallbacksBridge::didTruncate):
+        (WebKit::WorkerFileWriterCallbacksBridge::postInitToMainThread):
+        (WebKit::WorkerFileWriterCallbacksBridge::dispatchTaskToMainThread):
+        (WebKit::WorkerFileWriterCallbacksBridge::dispatchTaskToWorkerThread):
+        * tests/CCThreadTest.cpp:
+        (WebCore::TEST):
+
 2011-04-27  James Robinson  <jamesr@chromium.org>
 
         Reviewed by Kenneth Russell.
index e73c0f4..9f14409 100644 (file)
@@ -76,12 +76,12 @@ void WebSharedWorkerImpl::connect(WebMessagePortChannel* webChannel, ConnectList
         MessagePortChannel::create(platform_channel);
 
     workerThread()->runLoop().postTask(
-        createCallbackTask(&connectTask, this, channel.release()));
+        createCallbackTask(&connectTask, channel.release()));
     if (listener)
         listener->connected();
 }
 
-void WebSharedWorkerImpl::connectTask(ScriptExecutionContext* context, WebSharedWorkerImpl* worker, PassOwnPtr<MessagePortChannel> channel)
+void WebSharedWorkerImpl::connectTask(ScriptExecutionContext* context, PassOwnPtr<MessagePortChannel> channel)
 {
     // Wrap the passed-in channel in a MessagePort, and send it off via a connect event.
     RefPtr<MessagePort> port = MessagePort::create(*context);
index b591c7b..3147533 100644 (file)
@@ -63,7 +63,7 @@ public:
 private:
     virtual ~WebSharedWorkerImpl();
 
-    static void connectTask(WebCore::ScriptExecutionContext*, WebSharedWorkerImpl*, PassOwnPtr<WebCore::MessagePortChannel>);
+    static void connectTask(WebCore::ScriptExecutionContext*, PassOwnPtr<WebCore::MessagePortChannel>);
 
     WebCommonWorkerClient* m_client;
 };
index 3f9cf0c..f48078e 100644 (file)
@@ -90,7 +90,8 @@ public:
     {
         MutexLocker locker(m_mutex);
         if (m_worker)
-            m_worker->postTaskForModeToWorkerContext(createCallbackTask(&didComplete, this, result), m_mode);
+            m_worker->postTaskForModeToWorkerContext(
+                createCallbackTask(&didComplete, AllowCrossThreadAccess(this), result), m_mode);
     }
 
 private:
@@ -98,7 +99,11 @@ private:
         : m_worker(worker)
         , m_mode(mode)
     {
-        worker->dispatchTaskToMainThread(createCallbackTask(&allowDatabaseTask, commonClient, frame, String(name), String(displayName), estimatedSize, this));
+        worker->dispatchTaskToMainThread(
+            createCallbackTask(&allowDatabaseTask, AllowCrossThreadAccess(commonClient),
+                               AllowCrossThreadAccess(frame),
+                               String(name), String(displayName), estimatedSize,
+                               AllowCrossThreadAccess(this)));
     }
 
     static void allowDatabaseTask(WebCore::ScriptExecutionContext* context, WebCommonWorkerClient* commonClient, WebFrame* frame, const WTF::String name, const WTF::String displayName, unsigned long estimatedSize, PassRefPtr<AllowDatabaseMainThreadBridge> bridge)
@@ -263,7 +268,7 @@ void WebWorkerBase::openFileSystemForWorker(WebFileSystem::Type type, long long
 void WebWorkerBase::postMessageToWorkerObject(PassRefPtr<SerializedScriptValue> message,
                                               PassOwnPtr<MessagePortChannelArray> channels)
 {
-    dispatchTaskToMainThread(createCallbackTask(&postMessageTask, this,
+    dispatchTaskToMainThread(createCallbackTask(&postMessageTask, AllowCrossThreadAccess(this),
                                                 message->toWireString(), channels));
 }
 
@@ -288,9 +293,10 @@ void WebWorkerBase::postExceptionToWorkerObject(const String& errorMessage,
                                                 int lineNumber,
                                                 const String& sourceURL)
 {
-    dispatchTaskToMainThread(createCallbackTask(&postExceptionTask, this,
-                                                errorMessage, lineNumber,
-                                                sourceURL));
+    dispatchTaskToMainThread(
+        createCallbackTask(&postExceptionTask, AllowCrossThreadAccess(this),
+                           errorMessage, lineNumber,
+                           sourceURL));
 }
 
 void WebWorkerBase::postExceptionTask(ScriptExecutionContext* context,
@@ -313,7 +319,7 @@ void WebWorkerBase::postConsoleMessageToWorkerObject(MessageSource source,
                                                      int lineNumber,
                                                      const String& sourceURL)
 {
-    dispatchTaskToMainThread(createCallbackTask(&postConsoleMessageTask, this,
+    dispatchTaskToMainThread(createCallbackTask(&postConsoleMessageTask, AllowCrossThreadAccess(this),
                                                 source, type, level,
                                                 message, lineNumber, sourceURL));
 }
@@ -335,7 +341,7 @@ void WebWorkerBase::postConsoleMessageTask(ScriptExecutionContext* context,
 
 void WebWorkerBase::confirmMessageFromWorkerObject(bool hasPendingActivity)
 {
-    dispatchTaskToMainThread(createCallbackTask(&confirmMessageTask, this,
+    dispatchTaskToMainThread(createCallbackTask(&confirmMessageTask, AllowCrossThreadAccess(this),
                                                 hasPendingActivity));
 }
 
@@ -351,7 +357,8 @@ void WebWorkerBase::confirmMessageTask(ScriptExecutionContext* context,
 void WebWorkerBase::reportPendingActivity(bool hasPendingActivity)
 {
     dispatchTaskToMainThread(createCallbackTask(&reportPendingActivityTask,
-                                                this, hasPendingActivity));
+                                                AllowCrossThreadAccess(this),
+                                                hasPendingActivity));
 }
 
 void WebWorkerBase::reportPendingActivityTask(ScriptExecutionContext* context,
@@ -366,7 +373,7 @@ void WebWorkerBase::reportPendingActivityTask(ScriptExecutionContext* context,
 void WebWorkerBase::workerContextClosed()
 {
     dispatchTaskToMainThread(createCallbackTask(&workerContextClosedTask,
-                                                this));
+                                                AllowCrossThreadAccess(this)));
 }
 
 void WebWorkerBase::workerContextClosedTask(ScriptExecutionContext* context,
@@ -381,7 +388,7 @@ void WebWorkerBase::workerContextClosedTask(ScriptExecutionContext* context,
 void WebWorkerBase::workerContextDestroyed()
 {
     dispatchTaskToMainThread(createCallbackTask(&workerContextDestroyedTask,
-                                                this));
+                                                AllowCrossThreadAccess(this)));
 }
 
 void WebWorkerBase::workerContextDestroyedTask(ScriptExecutionContext* context,
index f90e7e8..1010b1c 100644 (file)
@@ -141,7 +141,7 @@ void WebWorkerClientImpl::startWorkerContext(const KURL& scriptURL,
     if (!isMainThread()) {
         WebWorkerBase::dispatchTaskToMainThread(createCallbackTask(
             &startWorkerContextTask,
-            this,
+            AllowCrossThreadAccess(this),
             scriptURL.string(),
             userAgent,
             sourceCode));
@@ -156,7 +156,8 @@ void WebWorkerClientImpl::terminateWorkerContext()
         return;
     m_askedToTerminate = true;
     if (!isMainThread()) {
-        WebWorkerBase::dispatchTaskToMainThread(createCallbackTask(&terminateWorkerContextTask, this));
+        WebWorkerBase::dispatchTaskToMainThread(
+            createCallbackTask(&terminateWorkerContextTask, AllowCrossThreadAccess(this)));
         return;
     }
     m_webWorker->terminateWorkerContext();
@@ -172,7 +173,7 @@ void WebWorkerClientImpl::postMessageToWorkerContext(
     ++m_unconfirmedMessageCount;
     if (!isMainThread()) {
         WebWorkerBase::dispatchTaskToMainThread(createCallbackTask(&postMessageToWorkerContextTask,
-                                                                   this,
+                                                                   AllowCrossThreadAccess(this),
                                                                    message->toWireString(),
                                                                    channels));
         return;
@@ -202,7 +203,7 @@ void WebWorkerClientImpl::workerObjectDestroyed()
     // Even if this is called on the main thread, there could be a queued task for
     // this object, so don't delete it right away.
     WebWorkerBase::dispatchTaskToMainThread(createCallbackTask(&workerObjectDestroyedTask,
-                                                               this));
+                                                               AllowCrossThreadAccess(this)));
 }
 
 void WebWorkerClientImpl::postMessageToWorkerObject(const WebString& message,
@@ -221,7 +222,7 @@ void WebWorkerClientImpl::postMessageToWorkerObject(const WebString& message,
 
     if (currentThread() != m_workerThreadId) {
         m_scriptExecutionContext->postTask(createCallbackTask(&postMessageToWorkerObjectTask,
-                                                              this,
+                                                              AllowCrossThreadAccess(this),
                                                               String(message),
                                                               channels2.release()));
         return;
@@ -237,7 +238,7 @@ void WebWorkerClientImpl::postExceptionToWorkerObject(const WebString& errorMess
 {
     if (currentThread() != m_workerThreadId) {
         m_scriptExecutionContext->postTask(createCallbackTask(&postExceptionToWorkerObjectTask,
-                                                              this,
+                                                              AllowCrossThreadAccess(this),
                                                               String(errorMessage),
                                                               lineNumber,
                                                               String(sourceURL)));
@@ -261,7 +262,7 @@ void WebWorkerClientImpl::postConsoleMessageToWorkerObject(int destination,
 {
     if (currentThread() != m_workerThreadId) {
         m_scriptExecutionContext->postTask(createCallbackTask(&postConsoleMessageToWorkerObjectTask,
-                                                              this,
+                                                              AllowCrossThreadAccess(this),
                                                               sourceId,
                                                               messageType,
                                                               messageLevel,
@@ -294,14 +295,14 @@ void WebWorkerClientImpl::confirmMessageFromWorkerObject(bool hasPendingActivity
     // accessed.  Otherwise there are race conditions with v8's garbage
     // collection.
     m_scriptExecutionContext->postTask(createCallbackTask(&confirmMessageFromWorkerObjectTask,
-                                                          this));
+                                                          AllowCrossThreadAccess(this)));
 }
 
 void WebWorkerClientImpl::reportPendingActivity(bool hasPendingActivity)
 {
     // See above comment in confirmMessageFromWorkerObject.
     m_scriptExecutionContext->postTask(createCallbackTask(&reportPendingActivityTask,
-                                                          this,
+                                                          AllowCrossThreadAccess(this),
                                                           hasPendingActivity));
 }
 
index 165af68..b2d4915 100644 (file)
@@ -129,7 +129,7 @@ void WebWorkerImpl::postMessageToWorkerContext(const WebString& message,
 
     workerThread()->runLoop().postTask(
         createCallbackTask(&postMessageToWorkerContextTask,
-                           this, String(message), channels.release()));
+                           AllowCrossThreadAccess(this), String(message), channels.release()));
 }
 
 void WebWorkerImpl::workerObjectDestroyed()
index 5147e15..fb5dd68 100644 (file)
@@ -155,64 +155,97 @@ void WorkerFileSystemCallbacksBridge::stop()
 
 void WorkerFileSystemCallbacksBridge::postOpenFileSystemToMainThread(WebCommonWorkerClient* commonClient, WebFileSystem::Type type, long long size, bool create, const String& mode)
 {
-    dispatchTaskToMainThread(createCallbackTask(&openFileSystemOnMainThread, commonClient, type, size, create, this, mode));
+    dispatchTaskToMainThread(
+        createCallbackTask(&openFileSystemOnMainThread,
+                           AllowCrossThreadAccess(commonClient), type, size, create,
+                           AllowCrossThreadAccess(this), mode));
 }
 
 void WorkerFileSystemCallbacksBridge::postMoveToMainThread(WebFileSystem* fileSystem, const String& sourcePath, const String& destinationPath, const String& mode)
 {
-    dispatchTaskToMainThread(createCallbackTask(&moveOnMainThread, fileSystem, sourcePath, destinationPath, this, mode));
+    dispatchTaskToMainThread(
+        createCallbackTask(&moveOnMainThread,
+                           AllowCrossThreadAccess(fileSystem), sourcePath, destinationPath,
+                           AllowCrossThreadAccess(this), mode));
 }
 
 void WorkerFileSystemCallbacksBridge::postCopyToMainThread(WebFileSystem* fileSystem, const String& sourcePath, const String& destinationPath, const String& mode)
 {
-    dispatchTaskToMainThread(createCallbackTask(&copyOnMainThread, fileSystem, sourcePath, destinationPath, this, mode));
+    dispatchTaskToMainThread(
+        createCallbackTask(&copyOnMainThread,
+                           AllowCrossThreadAccess(fileSystem), sourcePath, destinationPath,
+                           AllowCrossThreadAccess(this), mode));
 }
 
 void WorkerFileSystemCallbacksBridge::postRemoveToMainThread(WebFileSystem* fileSystem, const String& path, const String& mode)
 {
     ASSERT(fileSystem);
-    dispatchTaskToMainThread(createCallbackTask(&removeOnMainThread, fileSystem, path, this, mode));
+    dispatchTaskToMainThread(
+        createCallbackTask(&removeOnMainThread,
+                           AllowCrossThreadAccess(fileSystem), path,
+                           AllowCrossThreadAccess(this), mode));
 }
 
 void WorkerFileSystemCallbacksBridge::postRemoveRecursivelyToMainThread(WebFileSystem* fileSystem, const String& path, const String& mode)
 {
     ASSERT(fileSystem);
-    dispatchTaskToMainThread(createCallbackTask(&removeRecursivelyOnMainThread, fileSystem, path, this, mode));
+    dispatchTaskToMainThread(
+        createCallbackTask(&removeRecursivelyOnMainThread,
+                           AllowCrossThreadAccess(fileSystem), path,
+                           AllowCrossThreadAccess(this), mode));
 }
 
 void WorkerFileSystemCallbacksBridge::postReadMetadataToMainThread(WebFileSystem* fileSystem, const String& path, const String& mode)
 {
     ASSERT(fileSystem);
-    dispatchTaskToMainThread(createCallbackTask(&readMetadataOnMainThread, fileSystem, path, this, mode));
+    dispatchTaskToMainThread(
+        createCallbackTask(&readMetadataOnMainThread,
+                           AllowCrossThreadAccess(fileSystem), path,
+                           AllowCrossThreadAccess(this), mode));
 }
 
 void WorkerFileSystemCallbacksBridge::postCreateFileToMainThread(WebFileSystem* fileSystem, const String& path, bool exclusive, const String& mode)
 {
-    dispatchTaskToMainThread(createCallbackTask(&createFileOnMainThread, fileSystem, path, exclusive, this, mode));
+    dispatchTaskToMainThread(
+        createCallbackTask(&createFileOnMainThread,
+                           AllowCrossThreadAccess(fileSystem), path, exclusive,
+                           AllowCrossThreadAccess(this), mode));
 }
 
 void WorkerFileSystemCallbacksBridge::postCreateDirectoryToMainThread(WebFileSystem* fileSystem, const String& path, bool exclusive, const String& mode)
 {
     ASSERT(fileSystem);
-    dispatchTaskToMainThread(createCallbackTask(&createDirectoryOnMainThread, fileSystem, path, exclusive, this, mode));
+    dispatchTaskToMainThread(
+        createCallbackTask(&createDirectoryOnMainThread,
+                           AllowCrossThreadAccess(fileSystem), path, exclusive,
+                           AllowCrossThreadAccess(this), mode));
 }
 
 void WorkerFileSystemCallbacksBridge::postFileExistsToMainThread(WebFileSystem* fileSystem, const String& path, const String& mode)
 {
     ASSERT(fileSystem);
-    dispatchTaskToMainThread(createCallbackTask(&fileExistsOnMainThread, fileSystem, path, this, mode));
+    dispatchTaskToMainThread(
+        createCallbackTask(&fileExistsOnMainThread,
+                           AllowCrossThreadAccess(fileSystem), path,
+                           AllowCrossThreadAccess(this), mode));
 }
 
 void WorkerFileSystemCallbacksBridge::postDirectoryExistsToMainThread(WebFileSystem* fileSystem, const String& path, const String& mode)
 {
     ASSERT(fileSystem);
-    dispatchTaskToMainThread(createCallbackTask(&directoryExistsOnMainThread, fileSystem, path, this, mode));
+    dispatchTaskToMainThread(
+        createCallbackTask(&directoryExistsOnMainThread,
+                           AllowCrossThreadAccess(fileSystem), path,
+                           AllowCrossThreadAccess(this), mode));
 }
 
 void WorkerFileSystemCallbacksBridge::postReadDirectoryToMainThread(WebFileSystem* fileSystem, const String& path, const String& mode)
 {
     ASSERT(fileSystem);
-    dispatchTaskToMainThread(createCallbackTask(&readDirectoryOnMainThread, fileSystem, path, this, mode));
+    dispatchTaskToMainThread(
+        createCallbackTask(&readDirectoryOnMainThread,
+                           AllowCrossThreadAccess(fileSystem), path,
+                           AllowCrossThreadAccess(this), mode));
 }
 
 void WorkerFileSystemCallbacksBridge::openFileSystemOnMainThread(ScriptExecutionContext*, WebCommonWorkerClient* commonClient, WebFileSystem::Type type, long long size, bool create, WorkerFileSystemCallbacksBridge* bridge, const String& mode)
@@ -276,27 +309,30 @@ void WorkerFileSystemCallbacksBridge::readDirectoryOnMainThread(WebCore::ScriptE
 
 void WorkerFileSystemCallbacksBridge::didFailOnMainThread(WebFileError error, const String& mode)
 {
-    mayPostTaskToWorker(createCallbackTask(&didFailOnWorkerThread, this, error), mode);
+    mayPostTaskToWorker(createCallbackTask(&didFailOnWorkerThread, AllowCrossThreadAccess(this), error), mode);
 }
 
 void WorkerFileSystemCallbacksBridge::didOpenFileSystemOnMainThread(const String& name, const String& rootPath, const String& mode)
 {
-    mayPostTaskToWorker(createCallbackTask(&didOpenFileSystemOnWorkerThread, this, name, rootPath), mode);
+    mayPostTaskToWorker(createCallbackTask(&didOpenFileSystemOnWorkerThread,
+                                           AllowCrossThreadAccess(this), name, rootPath), mode);
 }
 
 void WorkerFileSystemCallbacksBridge::didSucceedOnMainThread(const String& mode)
 {
-    mayPostTaskToWorker(createCallbackTask(&didSucceedOnWorkerThread, this), mode);
+    mayPostTaskToWorker(createCallbackTask(&didSucceedOnWorkerThread, AllowCrossThreadAccess(this)), mode);
 }
 
 void WorkerFileSystemCallbacksBridge::didReadMetadataOnMainThread(const WebFileInfo& info, const String& mode)
 {
-    mayPostTaskToWorker(createCallbackTask(&didReadMetadataOnWorkerThread, this, info), mode);
+    mayPostTaskToWorker(createCallbackTask(&didReadMetadataOnWorkerThread, AllowCrossThreadAccess(this), info), mode);
 }
 
 void WorkerFileSystemCallbacksBridge::didReadDirectoryOnMainThread(const WebVector<WebFileSystemEntry>& entries, bool hasMore, const String& mode)
 {
-    mayPostTaskToWorker(createCallbackTask(&didReadDirectoryOnWorkerThread, this, entries, hasMore), mode);
+    mayPostTaskToWorker(
+        createCallbackTask(&didReadDirectoryOnWorkerThread,
+                           AllowCrossThreadAccess(this), entries, hasMore), mode);
 }
 
 WorkerFileSystemCallbacksBridge::WorkerFileSystemCallbacksBridge(WebWorkerBase* worker, ScriptExecutionContext* scriptExecutionContext, WebFileSystemCallbacks* callbacks)
index 179aea5..b718bcd 100644 (file)
@@ -61,20 +61,22 @@ void WorkerFileWriterCallbacksBridge::postWriteToMainThread(long long position,
 {
     ASSERT(!m_operationInProgress);
     m_operationInProgress = true;
-    dispatchTaskToMainThread(createCallbackTask(&writeOnMainThread, this, position, data));
+    dispatchTaskToMainThread(createCallbackTask(&writeOnMainThread, 
+                                                AllowCrossThreadAccess(this), position, data));
 }
 
 void WorkerFileWriterCallbacksBridge::postTruncateToMainThread(long long length)
 {
     ASSERT(!m_operationInProgress);
     m_operationInProgress = true;
-    dispatchTaskToMainThread(createCallbackTask(&truncateOnMainThread, this, length));
+    dispatchTaskToMainThread(createCallbackTask(&truncateOnMainThread, 
+                                                AllowCrossThreadAccess(this), length));
 }
 
 void WorkerFileWriterCallbacksBridge::postAbortToMainThread()
 {
     ASSERT(m_operationInProgress);
-    dispatchTaskToMainThread(createCallbackTask(&abortOnMainThread, this));
+    dispatchTaskToMainThread(createCallbackTask(&abortOnMainThread, AllowCrossThreadAccess(this)));
 }
 
 void WorkerFileWriterCallbacksBridge::postShutdownToMainThread(PassRefPtr<WorkerFileWriterCallbacksBridge> bridge)
@@ -113,17 +115,20 @@ void WorkerFileWriterCallbacksBridge::shutdownOnMainThread(ScriptExecutionContex
 
 void WorkerFileWriterCallbacksBridge::didWrite(long long bytes, bool complete)
 {
-    dispatchTaskToWorkerThread(createCallbackTask(&didWriteOnWorkerThread, this, bytes, complete));
+    dispatchTaskToWorkerThread(
+        createCallbackTask(&didWriteOnWorkerThread, AllowCrossThreadAccess(this), bytes, complete));
 }
 
 void WorkerFileWriterCallbacksBridge::didFail(WebFileError error)
 {
-    dispatchTaskToWorkerThread(createCallbackTask(&didFailOnWorkerThread, this, error));
+    dispatchTaskToWorkerThread(
+        createCallbackTask(&didFailOnWorkerThread, AllowCrossThreadAccess(this), error));
 }
 
 void WorkerFileWriterCallbacksBridge::didTruncate()
 {
-    dispatchTaskToWorkerThread(createCallbackTask(&didTruncateOnWorkerThread, this));
+    dispatchTaskToWorkerThread(
+        createCallbackTask(&didTruncateOnWorkerThread, AllowCrossThreadAccess(this)));
 }
 
 static const char fileWriterOperationsMode[] = "fileWriterOperationsMode";
@@ -144,7 +149,8 @@ WorkerFileWriterCallbacksBridge::WorkerFileWriterCallbacksBridge(const String& p
 
 void WorkerFileWriterCallbacksBridge::postInitToMainThread(const String& path)
 {
-    dispatchTaskToMainThread(createCallbackTask(&initOnMainThread, this, path));
+    dispatchTaskToMainThread(
+        createCallbackTask(&initOnMainThread, AllowCrossThreadAccess(this), path));
 }
 
 WorkerFileWriterCallbacksBridge::~WorkerFileWriterCallbacksBridge()
@@ -196,13 +202,15 @@ void WorkerFileWriterCallbacksBridge::runTaskOnWorkerThread(ScriptExecutionConte
 void WorkerFileWriterCallbacksBridge::dispatchTaskToMainThread(PassOwnPtr<ScriptExecutionContext::Task> task)
 {
     ASSERT(m_workerContext->isContextThread());
-    WebWorkerBase::dispatchTaskToMainThread(createCallbackTask(&runTaskOnMainThread, this, task));
+    WebWorkerBase::dispatchTaskToMainThread(
+        createCallbackTask(&runTaskOnMainThread, AllowCrossThreadAccess(this), task));
 }
 
 void WorkerFileWriterCallbacksBridge::dispatchTaskToWorkerThread(PassOwnPtr<ScriptExecutionContext::Task> task)
 {
     ASSERT(isMainThread());
-    m_proxy->postTaskForModeToWorkerContext(createCallbackTask(&runTaskOnWorkerThread, this, task), m_mode);
+    m_proxy->postTaskForModeToWorkerContext(
+        createCallbackTask(&runTaskOnWorkerThread, AllowCrossThreadAccess(this), task), m_mode);
 }
 
 bool WorkerFileWriterCallbacksBridge::waitForOperationToComplete()
index 04fba46..69ae10b 100644 (file)
@@ -53,7 +53,8 @@ TEST(CCThreadTest, pingPongUsingCondition)
     OwnPtr<CCThread> thread = CCThread::create();
     PingPongUsingCondition target;
     CCCompletionEvent completion;
-    thread->postTask(createCCThreadTask(&target, &PingPongUsingCondition::ping, &completion));
+    thread->postTask(createCCThreadTask(&target, &PingPongUsingCondition::ping, 
+                                        AllowCrossThreadAccess(&completion)));
     completion.wait();
 
     EXPECT_EQ(thread->threadID(), target.hitThreadID);