WebCore: Turn all callbacks into ActiveDOMObjects and create callbacks in the correct...
authordumi@chromium.org <dumi@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 3 Aug 2010 09:04:08 +0000 (09:04 +0000)
committerdumi@chromium.org <dumi@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 3 Aug 2010 09:04:08 +0000 (09:04 +0000)
commit8e2b02a1105784b0d0dbead6d0c6a33bcfce1274
treed6c8678a3cf1aca9a859bf246e68309bbab287db
parent993d34ee2188d5ba737ca9a22213250f5088537d
WebCore: Turn all callbacks into ActiveDOMObjects and create callbacks in the correct context.
https://bugs.webkit.org/show_bug.cgi?id=40112

Reviewed by Adam Barth.

Test: http/tests/storage/callbacks-are-called-in-correct-context.html

* CMakeLists.txt: Added new files.
* DerivedSources.make:
* GNUmakefile.am:
* WebCore.gypi:
* WebCore.pro:
* WebCore.vcproj/WebCore.vcproj:
* WebCore.xcodeproj/project.pbxproj:

* bindings/generic/ActiveDOMCallback.cpp: Added. The base class
for all callbacks, that behaves like an ActiveDOMObject.
(WebCore::DestroyOnContextThreadTask::create):
(WebCore::DestroyOnContextThreadTask::performTask):
(WebCore::DestroyOnContextThreadTask::DestroyOnContextThreadTask):
(WebCore::ActiveDOMObjectCallbackImpl::ActiveDOMObjectCallbackImpl):
(WebCore::ActiveDOMObjectCallbackImpl::contextDestroyed):
(WebCore::ActiveDOMObjectCallbackImpl::canSuspend):
(WebCore::ActiveDOMObjectCallbackImpl::suspend):
(WebCore::ActiveDOMObjectCallbackImpl::resume):
(WebCore::ActiveDOMObjectCallbackImpl::stop):
(WebCore::ActiveDOMObjectCallbackImpl::canInvokeCallback):
(WebCore::ActiveDOMObjectCallbackImpl::scriptExecutionContext):
(WebCore::ActiveDOMObjectCallbackImpl::mutex):
(WebCore::destroyOnContextThread):
(WebCore::ActiveDOMCallback::ActiveDOMCallback):
(WebCore::ActiveDOMCallback::~ActiveDOMCallback):
(WebCore::ActiveDOMCallback::canInvokeCallback):
(WebCore::ActiveDOMCallback::scriptExecutionContext):
* bindings/generic/ActiveDOMCallback.h: Added.

* bindings/js/JSCustomSQLStatementErrorCallback.cpp: Pass the
right ScriptExecutionContext to the JSC callbacks.
(WebCore::JSSQLStatementErrorCallback::handleEvent):
* bindings/js/JSSQLTransactionCustom.cpp:
(WebCore::JSSQLTransaction::executeSql):

* bindings/scripts/CodeGeneratorJS.pm: Make all callbacks inherit
from ActiveDOMCallback, and make them use the right
ScriptExecutionContext.
* bindings/scripts/CodeGeneratorV8.pm:

* bindings/scripts/test/JS/JSTestCallback.cpp: Update the
expectations for the code generated by CodeGenerator{JS|V8}.pm.
(WebCore::JSTestCallback::JSTestCallback):
(WebCore::JSTestCallback::~JSTestCallback):
(WebCore::JSTestCallback::callbackWithClass1Param):
(WebCore::JSTestCallback::callbackWithClass2Param):
* bindings/scripts/test/JS/JSTestCallback.h:
* bindings/scripts/test/V8/V8TestCallback.cpp:
(WebCore::V8TestCallback::V8TestCallback):
(WebCore::V8TestCallback::callbackWithClass1Param):
(WebCore::V8TestCallback::callbackWithClass2Param):
* bindings/scripts/test/V8/V8TestCallback.h:
(WebCore::V8TestCallback::create):
* bindings/scripts/test/V8/V8TestObj.cpp:
(WebCore::TestObjInternal::methodWithCallbackArgCallback):
(WebCore::TestObjInternal::methodWithNonCallbackArgAndCallbackArgCallback):
(WebCore::TestObjInternal::methodWithCallbackAndOptionalArgCallback):

* bindings/v8/custom/V8CustomSQLStatementErrorCallback.cpp: Pass
the right ScriptExecutionContext to the V8 callbacks.
(WebCore::V8SQLStatementErrorCallback::handleEvent):
* bindings/v8/custom/V8DOMWindowCustom.cpp:
(WebCore::V8DOMWindow::openDatabaseCallback):
* bindings/v8/custom/V8DatabaseCustom.cpp:
(WebCore::V8Database::changeVersionCallback):
(WebCore::createTransaction):
* bindings/v8/custom/V8DatabaseSyncCustom.cpp:
(WebCore::V8DatabaseSync::changeVersionCallback):
(WebCore::createTransaction):
* bindings/v8/custom/V8SQLTransactionCustom.cpp:
(WebCore::V8SQLTransaction::executeSqlCallback):
* bindings/v8/custom/V8WorkerContextCustom.cpp:
(WebCore::V8WorkerContext::openDatabaseCallback):
(WebCore::V8WorkerContext::openDatabaseSyncCallback):

* dom/ActiveDOMObject.cpp: Simplify the code.
(WebCore::ActiveDOMObject::ActiveDOMObject):
(WebCore::ActiveDOMObject::~ActiveDOMObject):

* storage/Database.cpp: CallbackClass::handleEvent() doesn't take
a ScriptExecutionContext anymore.
(WebCore::DatabaseCreationCallbackTask::performTask):
* storage/DatabaseCallback.h:
* storage/DatabaseSync.cpp:
(WebCore::DatabaseSync::openDatabaseSync):
* storage/EntryCallback.h:
* storage/ErrorCallback.h:
* storage/FileSystemCallback.h:
* storage/MetadataCallback.h:
* storage/SQLStatement.cpp:
(WebCore::SQLStatement::performCallback):
* storage/SQLStatementCallback.h:
* storage/SQLStatementErrorCallback.h:
* storage/SQLTransaction.cpp:
(WebCore::SQLTransaction::deliverTransactionCallback):
(WebCore::SQLTransaction::deliverTransactionErrorCallback):
* storage/SQLTransactionCallback.h:
* storage/SQLTransactionErrorCallback.h:
* storage/SQLTransactionSync.cpp:
(WebCore::SQLTransactionSync::execute):
* storage/SQLTransactionSyncCallback.h:

LayoutTests: Make sure all DB callbacks run in the correct context.
https://bugs.webkit.org/show_bug.cgi?id=40112

Reviewed by Adam Barth.

* http/tests/storage: Added.
* http/tests/storage/callbacks-are-called-in-correct-context-expected.txt: Added.
* http/tests/storage/callbacks-are-called-in-correct-context.html: Added.
* http/tests/storage/resources: Added.
* http/tests/storage/resources/callbacks-are-called-in-correct-context-first-frame.html: Added.
* http/tests/storage/resources/callbacks-are-called-in-correct-context-output-frame.html: Added.
* http/tests/storage/resources/callbacks-are-called-in-correct-context-second-frame.html: Added.
* http/tests/storage/resources/callbacks-are-called-in-correct-context-third-frame.html: Added.
* http/tests/storage/resources/callbacks-are-called-in-correct-context.cgi: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@64537 268f45cc-cd09-0410-ab3c-d52691b4dbfc
49 files changed:
LayoutTests/ChangeLog
LayoutTests/http/tests/storage/callbacks-are-called-in-correct-context-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/storage/callbacks-are-called-in-correct-context.html [new file with mode: 0644]
LayoutTests/http/tests/storage/resources/callbacks-are-called-in-correct-context-first-frame.html [new file with mode: 0644]
LayoutTests/http/tests/storage/resources/callbacks-are-called-in-correct-context-output-frame.html [new file with mode: 0644]
LayoutTests/http/tests/storage/resources/callbacks-are-called-in-correct-context-second-frame.html [new file with mode: 0644]
LayoutTests/http/tests/storage/resources/callbacks-are-called-in-correct-context-third-frame.html [new file with mode: 0644]
LayoutTests/http/tests/storage/resources/callbacks-are-called-in-correct-context.cgi [new file with mode: 0755]
WebCore/CMakeLists.txt
WebCore/ChangeLog
WebCore/DerivedSources.make
WebCore/GNUmakefile.am
WebCore/WebCore.gypi
WebCore/WebCore.pro
WebCore/WebCore.vcproj/WebCore.vcproj
WebCore/WebCore.xcodeproj/project.pbxproj
WebCore/bindings/generic/ActiveDOMCallback.cpp [new file with mode: 0644]
WebCore/bindings/generic/ActiveDOMCallback.h [new file with mode: 0644]
WebCore/bindings/js/JSCustomSQLStatementErrorCallback.cpp
WebCore/bindings/js/JSSQLTransactionCustom.cpp
WebCore/bindings/scripts/CodeGeneratorJS.pm
WebCore/bindings/scripts/CodeGeneratorV8.pm
WebCore/bindings/scripts/test/JS/JSTestCallback.cpp
WebCore/bindings/scripts/test/JS/JSTestCallback.h
WebCore/bindings/scripts/test/V8/V8TestCallback.cpp
WebCore/bindings/scripts/test/V8/V8TestCallback.h
WebCore/bindings/scripts/test/V8/V8TestObj.cpp
WebCore/bindings/v8/custom/V8CustomSQLStatementErrorCallback.cpp
WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp
WebCore/bindings/v8/custom/V8DatabaseCustom.cpp
WebCore/bindings/v8/custom/V8DatabaseSyncCustom.cpp
WebCore/bindings/v8/custom/V8SQLTransactionCustom.cpp
WebCore/bindings/v8/custom/V8WorkerContextCustom.cpp
WebCore/dom/ActiveDOMObject.cpp
WebCore/storage/Database.cpp
WebCore/storage/DatabaseCallback.h
WebCore/storage/DatabaseSync.cpp
WebCore/storage/EntryCallback.h
WebCore/storage/ErrorCallback.h
WebCore/storage/FileSystemCallback.h
WebCore/storage/MetadataCallback.h
WebCore/storage/SQLStatement.cpp
WebCore/storage/SQLStatementCallback.h
WebCore/storage/SQLStatementErrorCallback.h
WebCore/storage/SQLTransaction.cpp
WebCore/storage/SQLTransactionCallback.h
WebCore/storage/SQLTransactionErrorCallback.h
WebCore/storage/SQLTransactionSync.cpp
WebCore/storage/SQLTransactionSyncCallback.h