| Differences between
and this patch
- WebCore/ChangeLog +82 lines
Lines 1-3 WebCore/ChangeLog_sec1
1
2010-06-21  Dumitru Daniliuc  <dumi@chromium.org>
2
3
        Reviewed by NOBODY (OOPS!).
4
5
        Turn all callbacks into ActiveDOMObjects.
6
        https://bugs.webkit.org/show_bug.cgi?id=40112
7
8
        Test: storage/callbacks-are-called-in-correct-context.html
9
10
        * CMakeLists.txt:
11
        * DerivedSources.make:
12
        * GNUmakefile.am:
13
        * WebCore.gypi:
14
        * WebCore.pro:
15
        * WebCore.vcproj/WebCore.vcproj:
16
        * WebCore.vcproj/WebCoreCommon.vsprops:
17
        * WebCore.xcodeproj/project.pbxproj:
18
        * bindings/generic/ActiveDOMCallback.cpp: Added.
19
        (WebCore::DestroyOnContextThreadTask::create):
20
        (WebCore::DestroyOnContextThreadTask::performTask):
21
        (WebCore::DestroyOnContextThreadTask::DestroyOnContextThreadTask):
22
        (WebCore::ActiveDOMObjectCallbackImpl::ActiveDOMObjectCallbackImpl):
23
        (WebCore::ActiveDOMObjectCallbackImpl::contextDestroyed):
24
        (WebCore::ActiveDOMObjectCallbackImpl::canSuspend):
25
        (WebCore::ActiveDOMObjectCallbackImpl::suspend):
26
        (WebCore::ActiveDOMObjectCallbackImpl::resume):
27
        (WebCore::ActiveDOMObjectCallbackImpl::stop):
28
        (WebCore::ActiveDOMObjectCallbackImpl::canInvokeCallback):
29
        (WebCore::destroyOnContextThread):
30
        (WebCore::ActiveDOMCallback::ActiveDOMCallback):
31
        (WebCore::ActiveDOMCallback::~ActiveDOMCallback):
32
        (WebCore::ActiveDOMCallback::canInvokeCallback):
33
        * bindings/generic/ActiveDOMCallback.h: Added.
34
        * bindings/js/JSCustomSQLStatementErrorCallback.cpp:
35
        (WebCore::JSSQLStatementErrorCallback::handleEvent):
36
        * bindings/js/JSSQLTransactionCustom.cpp:
37
        (WebCore::JSSQLTransaction::executeSql):
38
        * bindings/scripts/CodeGeneratorJS.pm:
39
        * bindings/scripts/CodeGeneratorV8.pm:
40
        * bindings/scripts/test/JS/JSTestCallback.cpp:
41
        (WebCore::JSTestCallback::JSTestCallback):
42
        (WebCore::JSTestCallback::callbackWithClass1Param):
43
        (WebCore::JSTestCallback::callbackWithClass2Param):
44
        * bindings/scripts/test/JS/JSTestCallback.h:
45
        * bindings/scripts/test/V8/V8TestCallback.cpp:
46
        (WebCore::V8TestCallback::V8TestCallback):
47
        (WebCore::V8TestCallback::callbackWithClass1Param):
48
        (WebCore::V8TestCallback::callbackWithClass2Param):
49
        * bindings/scripts/test/V8/V8TestCallback.h:
50
        (WebCore::V8TestCallback::create):
51
        * bindings/v8/custom/V8CustomSQLStatementErrorCallback.cpp:
52
        (WebCore::V8SQLStatementErrorCallback::handleEvent):
53
        * bindings/v8/custom/V8DOMWindowCustom.cpp:
54
        (WebCore::V8DOMWindow::openDatabaseCallback):
55
        * bindings/v8/custom/V8DatabaseCustom.cpp:
56
        (WebCore::V8Database::changeVersionCallback):
57
        (WebCore::createTransaction):
58
        * bindings/v8/custom/V8DatabaseSyncCustom.cpp:
59
        (WebCore::V8DatabaseSync::changeVersionCallback):
60
        (WebCore::createTransaction):
61
        * bindings/v8/custom/V8SQLTransactionCustom.cpp:
62
        (WebCore::V8SQLTransaction::executeSqlCallback):
63
        * bindings/v8/custom/V8WorkerContextCustom.cpp:
64
        (WebCore::V8WorkerContext::openDatabaseCallback):
65
        (WebCore::V8WorkerContext::openDatabaseSyncCallback):
66
        * dom/ActiveDOMObject.cpp:
67
        (WebCore::ActiveDOMObject::ActiveDOMObject):
68
        (WebCore::ActiveDOMObject::~ActiveDOMObject):
69
        * storage/Database.cpp:
70
        (WebCore::Database::performCreationCallback):
71
        * storage/DatabaseCallback.h:
72
        * storage/SQLStatement.cpp:
73
        (WebCore::SQLStatement::performCallback):
74
        * storage/SQLStatementCallback.h:
75
        * storage/SQLStatementErrorCallback.h:
76
        * storage/SQLTransaction.cpp:
77
        (WebCore::SQLTransaction::deliverTransactionCallback):
78
        (WebCore::SQLTransaction::deliverTransactionErrorCallback):
79
        * storage/SQLTransactionCallback.h:
80
        * storage/SQLTransactionErrorCallback.h:
81
        * storage/SQLTransactionSyncCallback.h:
82
1
2010-06-21  Benjamin Poulain  <benjamin.poulain@nokia.com>
83
2010-06-21  Benjamin Poulain  <benjamin.poulain@nokia.com>
2
84
3
        Reviewed by Kenneth Rohde Christiansen.
85
        Reviewed by Kenneth Rohde Christiansen.
- WebCore/CMakeLists.txt +4 lines
Lines 1-6 WebCore/CMakeLists.txt_sec1
1
SET(WebCore_INCLUDE_DIRECTORIES
1
SET(WebCore_INCLUDE_DIRECTORIES
2
    "${WEBCORE_DIR}"
2
    "${WEBCORE_DIR}"
3
    "${WEBCORE_DIR}/accessibility"
3
    "${WEBCORE_DIR}/accessibility"
4
    "${WEBCORE_DIR}/bindings/generic"
4
    "${WEBCORE_DIR}/bindings/js"
5
    "${WEBCORE_DIR}/bindings/js"
5
    "${WEBCORE_DIR}/bridge"
6
    "${WEBCORE_DIR}/bridge"
6
    "${WEBCORE_DIR}/bridge/c"
7
    "${WEBCORE_DIR}/bridge/c"
Lines 68-73 SET(WebCore_INCLUDE_DIRECTORIES WebCore/CMakeLists.txt_sec2
68
)
69
)
69
70
70
SET(WebCore_IDL_INCLUDES
71
SET(WebCore_IDL_INCLUDES
72
    bindings/generic
71
    bindings/js
73
    bindings/js
72
    css
74
    css
73
    dom
75
    dom
Lines 546-551 SET(WebCore_SOURCES WebCore/CMakeLists.txt_sec3
546
548
547
    bindings/ScriptControllerBase.cpp
549
    bindings/ScriptControllerBase.cpp
548
550
551
    bindings/generic/ActiveDOMCallback.cpp
552
549
    bindings/js/DOMObjectHashTableMap.cpp
553
    bindings/js/DOMObjectHashTableMap.cpp
550
    bindings/js/DOMWrapperWorld.cpp
554
    bindings/js/DOMWrapperWorld.cpp
551
    bindings/js/GCController.cpp
555
    bindings/js/GCController.cpp
- WebCore/DerivedSources.make +1 lines
Lines 28-33 WebCore/DerivedSources.make_sec1
28
28
29
VPATH = \
29
VPATH = \
30
    $(WebCore) \
30
    $(WebCore) \
31
    $(WebCore)/bindings/generic \
31
    $(WebCore)/bindings/js \
32
    $(WebCore)/bindings/js \
32
    $(WebCore)/bindings/objc \
33
    $(WebCore)/bindings/objc \
33
    $(WebCore)/css \
34
    $(WebCore)/css \
- WebCore/GNUmakefile.am +3 lines
Lines 14-19 webcore_cppflags += \ WebCore/GNUmakefile.am_sec1
14
	-I$(srcdir)/WebKit/gtk/webkit \
14
	-I$(srcdir)/WebKit/gtk/webkit \
15
	-I$(srcdir)/WebCore \
15
	-I$(srcdir)/WebCore \
16
	-I$(srcdir)/WebCore/accessibility \
16
	-I$(srcdir)/WebCore/accessibility \
17
	-I$(srcdir)/WebCore/bindings/generic \
17
	-I$(srcdir)/WebCore/bindings/js \
18
	-I$(srcdir)/WebCore/bindings/js \
18
	-I$(srcdir)/WebCore/bindings/gobject \
19
	-I$(srcdir)/WebCore/bindings/gobject \
19
	-I$(srcdir)/WebCore/bridge \
20
	-I$(srcdir)/WebCore/bridge \
Lines 383-388 webcore_sources += \ WebCore/GNUmakefile.am_sec2
383
	WebCore/accessibility/AccessibilityTableHeaderContainer.h \
384
	WebCore/accessibility/AccessibilityTableHeaderContainer.h \
384
	WebCore/accessibility/AccessibilityTableRow.cpp \
385
	WebCore/accessibility/AccessibilityTableRow.cpp \
385
	WebCore/accessibility/AccessibilityTableRow.h \
386
	WebCore/accessibility/AccessibilityTableRow.h \
387
	WebCore/bindings/generic/ActiveDOMCallback.cpp \
388
	WebCore/bindings/generic/ActiveDOMCallback.h \
386
	WebCore/bindings/js/CachedScriptSourceProvider.h \
389
	WebCore/bindings/js/CachedScriptSourceProvider.h \
387
	WebCore/bindings/js/DOMObjectHashTableMap.cpp \
390
	WebCore/bindings/js/DOMObjectHashTableMap.cpp \
388
	WebCore/bindings/js/DOMObjectHashTableMap.h \
391
	WebCore/bindings/js/DOMObjectHashTableMap.h \
- WebCore/WebCore.gypi +2 lines
Lines 483-488 WebCore/WebCore.gypi_sec1
483
            'accessibility/win/AccessibilityObjectWin.cpp',
483
            'accessibility/win/AccessibilityObjectWin.cpp',
484
            'accessibility/win/AccessibilityObjectWrapperWin.h',
484
            'accessibility/win/AccessibilityObjectWrapperWin.h',
485
            'accessibility/wx/AccessibilityObjectWx.cpp',
485
            'accessibility/wx/AccessibilityObjectWx.cpp',
486
            'bindings/generic/ActiveDOMCallback.cpp',
487
            'bindings/generic/ActiveDOMCallback.h',
486
            'bindings/generic/BindingDOMWindow.h',
488
            'bindings/generic/BindingDOMWindow.h',
487
            'bindings/generic/BindingElement.h',
489
            'bindings/generic/BindingElement.h',
488
            'bindings/generic/BindingSecurity.h',
490
            'bindings/generic/BindingSecurity.h',
- WebCore/WebCore.pro +3 lines
Lines 171-176 include(WebCore.pri) WebCore/WebCore.pro_sec1
171
INCLUDEPATH = \
171
INCLUDEPATH = \
172
    $$PWD \
172
    $$PWD \
173
    $$PWD/accessibility \
173
    $$PWD/accessibility \
174
    $$PWD/bindings/generic \
174
    $$PWD/bindings/js \
175
    $$PWD/bindings/js \
175
    $$PWD/bridge \
176
    $$PWD/bridge \
176
    $$PWD/bridge/c \
177
    $$PWD/bridge/c \
Lines 266-271 SOURCES += \ WebCore/WebCore.pro_sec2
266
    accessibility/AccessibilityTableHeaderContainer.cpp \    
267
    accessibility/AccessibilityTableHeaderContainer.cpp \    
267
    accessibility/AccessibilityTableRow.cpp \    
268
    accessibility/AccessibilityTableRow.cpp \    
268
    accessibility/AXObjectCache.cpp \
269
    accessibility/AXObjectCache.cpp \
270
    bindings/generic/ActiveDOMCallback.cpp \
269
    bindings/js/GCController.cpp \
271
    bindings/js/GCController.cpp \
270
    bindings/js/DOMObjectHashTableMap.cpp \
272
    bindings/js/DOMObjectHashTableMap.cpp \
271
    bindings/js/DOMWrapperWorld.cpp \
273
    bindings/js/DOMWrapperWorld.cpp \
Lines 1043-1048 HEADERS += \ WebCore/WebCore.pro_sec3
1043
    accessibility/AccessibilityTableHeaderContainer.h \
1045
    accessibility/AccessibilityTableHeaderContainer.h \
1044
    accessibility/AccessibilityTableRow.h \
1046
    accessibility/AccessibilityTableRow.h \
1045
    accessibility/AXObjectCache.h \
1047
    accessibility/AXObjectCache.h \
1048
    bindings/generic/ActiveDOMCallback.h \
1046
    bindings/js/CachedScriptSourceProvider.h \
1049
    bindings/js/CachedScriptSourceProvider.h \
1047
    bindings/js/GCController.h \
1050
    bindings/js/GCController.h \
1048
    bindings/js/DOMObjectHashTableMap.h \
1051
    bindings/js/DOMObjectHashTableMap.h \
- WebCore/WebCore.vcproj/WebCore.vcproj +12 lines
Lines 37732-37737 WebCore/WebCore.vcproj/WebCore.vcproj_sec1
37732
				RelativePath="..\bindings\ScriptControllerBase.cpp"
37732
				RelativePath="..\bindings\ScriptControllerBase.cpp"
37733
				>
37733
				>
37734
			</File>
37734
			</File>
37735
 			<Filter
37736
				Name="generic"
37737
				>
37738
				<File
37739
					RelativePath="..\bindings\generic\ActiveDOMCallback.h"
37740
					>
37741
				</File>
37742
				<File
37743
					RelativePath="..\bindings\generic\ActiveDOMCallback.cpp"
37744
					>
37745
				</File>
37746
			</Filter>
37735
			<Filter
37747
			<Filter
37736
				Name="js"
37748
				Name="js"
37737
				>
37749
				>
- WebCore/WebCore.vcproj/WebCoreCommon.vsprops -1 / +1 lines
Lines 7-13 WebCore/WebCore.vcproj/WebCoreCommon.vsprops_sec1
7
	>
7
	>
8
	<Tool
8
	<Tool
9
		Name="VCCLCompilerTool"
9
		Name="VCCLCompilerTool"
10
		AdditionalIncludeDirectories="&quot;$(ProjectDir)..&quot;;&quot;$(ProjectDir)..\accessibility&quot;;&quot;$(ProjectDir)..\accessibility\win&quot;;&quot;$(ProjectDir)..\bridge&quot;;&quot;$(ProjectDir)..\bridge\c&quot;;&quot;$(ProjectDir)..\bridge\jsc&quot;;&quot;$(ProjectDir)..\css&quot;;&quot;$(ProjectDir)..\editing&quot;;&quot;$(ProjectDir)..\rendering&quot;;&quot;$(ProjectDir)..\rendering\style&quot;;&quot;$(ProjectDir)..\bindings\js&quot;;&quot;$(ProjectDir)..\dom&quot;;&quot;$(ProjectDir)..\dom\default&quot;;&quot;$(ProjectDir)..\history&quot;;&quot;$(ProjectDir)..\html&quot;;&quot;$(ProjectDir)..\html\canvas&quot;;&quot;$(ProjectDir)..\inspector&quot;;&quot;$(ProjectDir)..\loader&quot;;&quot;$(ProjectDir)..\loader\appcache&quot;;&quot;$(ProjectDir)..\loader\archive&quot;;&quot;$(ProjectDir)..\loader\archive\cf&quot;;&quot;$(ProjectDir)..\loader\icon&quot;;&quot;$(ProjectDir)..\notifications&quot;;&quot;$(ProjectDir)..\page&quot;;&quot;$(ProjectDir)..\page\animation&quot;;&quot;$(ProjectDir)..\page\win&quot;;&quot;$(ProjectDir)..\platform&quot;;&quot;$(ProjectDir)..\platform\animation&quot;;&quot;$(ProjectDir)..\platform\mock&quot;;&quot;$(ProjectDir)..\platform\sql&quot;;&quot;$(ProjectDir)..\platform\win&quot;;&quot;$(ProjectDir)..\platform\network&quot;;&quot;$(ProjectDir)..\platform\network\win&quot;;&quot;$(ProjectDir)..\platform\cf&quot;;&quot;$(ProjectDir)..\platform\graphics&quot;;&quot;$(ProjectDir)..\platform\graphics\filters&quot;;&quot;$(ProjectDir)..\platform\graphics\opentype&quot;;&quot;$(ProjectDir)..\platform\graphics\transforms&quot;;&quot;$(ProjectDir)..\platform\text&quot;;&quot;$(ProjectDir)..\platform\text\transcoder&quot;;&quot;$(ProjectDir)..\platform\graphics\win&quot;;&quot;$(ProjectDir)..\xml&quot;;&quot;$(WebKitOutputDir)\obj\WebCore\DerivedSources&quot;;&quot;$(ProjectDir)..\plugins&quot;;&quot;$(ProjectDir)..\plugins\win&quot;;&quot;$(ProjectDir)..\svg\animation&quot;;&quot;$(ProjectDir)..\svg\graphics&quot;;&quot;$(ProjectDir)..\svg\graphics\filters&quot;;&quot;$(ProjectDir)..\svg&quot;;&quot;$(ProjectDir)..\wml&quot;;&quot;$(ProjectDir)..\storage&quot;;&quot;$(ProjectDir)..\websockets&quot;;&quot;$(ProjectDir)..\workers&quot;;&quot;$(WebKitOutputDir)\include&quot;;&quot;$(WebKitOutputDir)\include\private&quot;;&quot;$(WebKitOutputDir)\include\JavaScriptCore&quot;;&quot;$(WebKitOutputDir)\include\private\JavaScriptCore&quot;;&quot;$(ProjectDir)..\ForwardingHeaders&quot;;&quot;$(WebKitLibrariesDir)\include&quot;;&quot;$(WebKitLibrariesDir)\include\private&quot;;&quot;$(WebKitLibrariesDir)\include\private\JavaScriptCore&quot;;&quot;$(WebKitLibrariesDir)\include\pthreads&quot;;&quot;$(WebKitLibrariesDir)\include\sqlite&quot;;&quot;$(WebKitLibrariesDir)\include\JavaScriptCore&quot;"
10
		AdditionalIncludeDirectories="&quot;$(ProjectDir)..&quot;;&quot;$(ProjectDir)..\accessibility&quot;;&quot;$(ProjectDir)..\accessibility\win&quot;;&quot;$(ProjectDir)..\bridge&quot;;&quot;$(ProjectDir)..\bridge\c&quot;;&quot;$(ProjectDir)..\bridge\jsc&quot;;&quot;$(ProjectDir)..\css&quot;;&quot;$(ProjectDir)..\editing&quot;;&quot;$(ProjectDir)..\rendering&quot;;&quot;$(ProjectDir)..\rendering\style&quot;;&quot;$(ProjectDir)..\bindings\generic&quot;;&quot;$(ProjectDir)..\bindings\js&quot;;&quot;$(ProjectDir)..\dom&quot;;&quot;$(ProjectDir)..\dom\default&quot;;&quot;$(ProjectDir)..\history&quot;;&quot;$(ProjectDir)..\html&quot;;&quot;$(ProjectDir)..\html\canvas&quot;;&quot;$(ProjectDir)..\inspector&quot;;&quot;$(ProjectDir)..\loader&quot;;&quot;$(ProjectDir)..\loader\appcache&quot;;&quot;$(ProjectDir)..\loader\archive&quot;;&quot;$(ProjectDir)..\loader\archive\cf&quot;;&quot;$(ProjectDir)..\loader\icon&quot;;&quot;$(ProjectDir)..\notifications&quot;;&quot;$(ProjectDir)..\page&quot;;&quot;$(ProjectDir)..\page\animation&quot;;&quot;$(ProjectDir)..\page\win&quot;;&quot;$(ProjectDir)..\platform&quot;;&quot;$(ProjectDir)..\platform\animation&quot;;&quot;$(ProjectDir)..\platform\mock&quot;;&quot;$(ProjectDir)..\platform\sql&quot;;&quot;$(ProjectDir)..\platform\win&quot;;&quot;$(ProjectDir)..\platform\network&quot;;&quot;$(ProjectDir)..\platform\network\win&quot;;&quot;$(ProjectDir)..\platform\cf&quot;;&quot;$(ProjectDir)..\platform\graphics&quot;;&quot;$(ProjectDir)..\platform\graphics\filters&quot;;&quot;$(ProjectDir)..\platform\graphics\opentype&quot;;&quot;$(ProjectDir)..\platform\graphics\transforms&quot;;&quot;$(ProjectDir)..\platform\text&quot;;&quot;$(ProjectDir)..\platform\text\transcoder&quot;;&quot;$(ProjectDir)..\platform\graphics\win&quot;;&quot;$(ProjectDir)..\xml&quot;;&quot;$(WebKitOutputDir)\obj\WebCore\DerivedSources&quot;;&quot;$(ProjectDir)..\plugins&quot;;&quot;$(ProjectDir)..\plugins\win&quot;;&quot;$(ProjectDir)..\svg\animation&quot;;&quot;$(ProjectDir)..\svg\graphics&quot;;&quot;$(ProjectDir)..\svg\graphics\filters&quot;;&quot;$(ProjectDir)..\svg&quot;;&quot;$(ProjectDir)..\wml&quot;;&quot;$(ProjectDir)..\storage&quot;;&quot;$(ProjectDir)..\websockets&quot;;&quot;$(ProjectDir)..\workers&quot;;&quot;$(WebKitOutputDir)\include&quot;;&quot;$(WebKitOutputDir)\include\private&quot;;&quot;$(WebKitOutputDir)\include\JavaScriptCore&quot;;&quot;$(WebKitOutputDir)\include\private\JavaScriptCore&quot;;&quot;$(ProjectDir)..\ForwardingHeaders&quot;;&quot;$(WebKitLibrariesDir)\include&quot;;&quot;$(WebKitLibrariesDir)\include\private&quot;;&quot;$(WebKitLibrariesDir)\include\private\JavaScriptCore&quot;;&quot;$(WebKitLibrariesDir)\include\pthreads&quot;;&quot;$(WebKitLibrariesDir)\include\sqlite&quot;;&quot;$(WebKitLibrariesDir)\include\JavaScriptCore&quot;"
11
		PreprocessorDefinitions="__WIN32__;DISABLE_3D_RENDERING;WEBCORE_CONTEXT_MENUS"
11
		PreprocessorDefinitions="__WIN32__;DISABLE_3D_RENDERING;WEBCORE_CONTEXT_MENUS"
12
		UsePrecompiledHeader="2"
12
		UsePrecompiledHeader="2"
13
		PrecompiledHeaderThrough="WebCorePrefix.h"
13
		PrecompiledHeaderThrough="WebCorePrefix.h"
- WebCore/WebCore.xcodeproj/project.pbxproj +16 lines
Lines 4253-4258 WebCore/WebCore.xcodeproj/project.pbxproj_sec1
4253
		B5B5DC6A119BB3D5002A8790 /* AbstractDatabase.h in Headers */ = {isa = PBXBuildFile; fileRef = B5B5DC68119BB3D5002A8790 /* AbstractDatabase.h */; settings = {ATTRIBUTES = (Private, ); }; };
4253
		B5B5DC6A119BB3D5002A8790 /* AbstractDatabase.h in Headers */ = {isa = PBXBuildFile; fileRef = B5B5DC68119BB3D5002A8790 /* AbstractDatabase.h */; settings = {ATTRIBUTES = (Private, ); }; };
4254
		B5C1123B102B6C4600096578 /* SQLTransactionCoordinator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B5C11239102B6C4600096578 /* SQLTransactionCoordinator.cpp */; };
4254
		B5C1123B102B6C4600096578 /* SQLTransactionCoordinator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B5C11239102B6C4600096578 /* SQLTransactionCoordinator.cpp */; };
4255
		B5C1123C102B6C4600096578 /* SQLTransactionCoordinator.h in Headers */ = {isa = PBXBuildFile; fileRef = B5C1123A102B6C4600096578 /* SQLTransactionCoordinator.h */; };
4255
		B5C1123C102B6C4600096578 /* SQLTransactionCoordinator.h in Headers */ = {isa = PBXBuildFile; fileRef = B5C1123A102B6C4600096578 /* SQLTransactionCoordinator.h */; };
4256
		B5D31DFA11CF610B009F22B4 /* ActiveDOMCallback.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B5D31DF811CF610B009F22B4 /* ActiveDOMCallback.cpp */; };
4257
		B5D31DFB11CF610B009F22B4 /* ActiveDOMCallback.h in Headers */ = {isa = PBXBuildFile; fileRef = B5D31DF911CF610B009F22B4 /* ActiveDOMCallback.h */; };
4256
		B5D3601A112F8B560048DEA8 /* DatabaseCallback.h in Headers */ = {isa = PBXBuildFile; fileRef = B5D36019112F8B560048DEA8 /* DatabaseCallback.h */; };
4258
		B5D3601A112F8B560048DEA8 /* DatabaseCallback.h in Headers */ = {isa = PBXBuildFile; fileRef = B5D36019112F8B560048DEA8 /* DatabaseCallback.h */; };
4257
		B627FB2D11AD743500E97B72 /* IDBDatabaseImpl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C50AD2A911AC1631008CF2FB /* IDBDatabaseImpl.cpp */; };
4259
		B627FB2D11AD743500E97B72 /* IDBDatabaseImpl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C50AD2A911AC1631008CF2FB /* IDBDatabaseImpl.cpp */; };
4258
		B6693EEC11AD63E6003F2770 /* IDBObjectStore.h in Headers */ = {isa = PBXBuildFile; fileRef = B6693EE811AD63E6003F2770 /* IDBObjectStore.h */; };
4260
		B6693EEC11AD63E6003F2770 /* IDBObjectStore.h in Headers */ = {isa = PBXBuildFile; fileRef = B6693EE811AD63E6003F2770 /* IDBObjectStore.h */; };
Lines 9753-9758 WebCore/WebCore.xcodeproj/project.pbxproj_sec2
9753
		B5B5DC68119BB3D5002A8790 /* AbstractDatabase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AbstractDatabase.h; sourceTree = "<group>"; };
9755
		B5B5DC68119BB3D5002A8790 /* AbstractDatabase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AbstractDatabase.h; sourceTree = "<group>"; };
9754
		B5C11239102B6C4600096578 /* SQLTransactionCoordinator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SQLTransactionCoordinator.cpp; sourceTree = "<group>"; };
9756
		B5C11239102B6C4600096578 /* SQLTransactionCoordinator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SQLTransactionCoordinator.cpp; sourceTree = "<group>"; };
9755
		B5C1123A102B6C4600096578 /* SQLTransactionCoordinator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SQLTransactionCoordinator.h; sourceTree = "<group>"; };
9757
		B5C1123A102B6C4600096578 /* SQLTransactionCoordinator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SQLTransactionCoordinator.h; sourceTree = "<group>"; };
9758
		B5D31DF811CF610B009F22B4 /* ActiveDOMCallback.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ActiveDOMCallback.cpp; path = generic/ActiveDOMCallback.cpp; sourceTree = "<group>"; };
9759
		B5D31DF911CF610B009F22B4 /* ActiveDOMCallback.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ActiveDOMCallback.h; path = generic/ActiveDOMCallback.h; sourceTree = "<group>"; };
9756
		B5D36019112F8B560048DEA8 /* DatabaseCallback.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DatabaseCallback.h; sourceTree = "<group>"; };
9760
		B5D36019112F8B560048DEA8 /* DatabaseCallback.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DatabaseCallback.h; sourceTree = "<group>"; };
9757
		B6693EE811AD63E6003F2770 /* IDBObjectStore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IDBObjectStore.h; sourceTree = "<group>"; };
9761
		B6693EE811AD63E6003F2770 /* IDBObjectStore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IDBObjectStore.h; sourceTree = "<group>"; };
9758
		B6693EE911AD63E6003F2770 /* IDBObjectStoreRequest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = IDBObjectStoreRequest.cpp; sourceTree = "<group>"; };
9762
		B6693EE911AD63E6003F2770 /* IDBObjectStoreRequest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = IDBObjectStoreRequest.cpp; sourceTree = "<group>"; };
Lines 15327-15332 WebCore/WebCore.xcodeproj/project.pbxproj_sec3
15327
			name = cf;
15331
			name = cf;
15328
			sourceTree = "<group>";
15332
			sourceTree = "<group>";
15329
		};
15333
		};
15334
		B5D31DF711CF60E5009F22B4 /* generic */ = {
15335
			isa = PBXGroup;
15336
			children = (
15337
				B5D31DF811CF610B009F22B4 /* ActiveDOMCallback.cpp */,
15338
				B5D31DF911CF610B009F22B4 /* ActiveDOMCallback.h */,
15339
			);
15340
			name = generic;
15341
			sourceTree = "<group>";
15342
		};
15330
		B734B17F119B98DB006587BD /* transcoder */ = {
15343
		B734B17F119B98DB006587BD /* transcoder */ = {
15331
			isa = PBXGroup;
15344
			isa = PBXGroup;
15332
			children = (
15345
			children = (
Lines 15339-15344 WebCore/WebCore.xcodeproj/project.pbxproj_sec4
15339
		BC1A3790097C6F970019F3D8 /* bindings */ = {
15352
		BC1A3790097C6F970019F3D8 /* bindings */ = {
15340
			isa = PBXGroup;
15353
			isa = PBXGroup;
15341
			children = (
15354
			children = (
15355
				B5D31DF711CF60E5009F22B4 /* generic */,
15342
				BC1A3793097C6FB10019F3D8 /* js */,
15356
				BC1A3793097C6FB10019F3D8 /* js */,
15343
				BC1A3794097C6FC40019F3D8 /* objc */,
15357
				BC1A3794097C6FC40019F3D8 /* objc */,
15344
				93F8B3050A300FE100F61AB8 /* CodeGenerator.pm */,
15358
				93F8B3050A300FE100F61AB8 /* CodeGenerator.pm */,
Lines 19470-19475 WebCore/WebCore.xcodeproj/project.pbxproj_sec5
19470
				1AA8799011CBE846003C664F /* PluginStrategy.h in Headers */,
19484
				1AA8799011CBE846003C664F /* PluginStrategy.h in Headers */,
19471
				B56EBA8511C9FF8100B04477 /* SQLException.h in Headers */,
19485
				B56EBA8511C9FF8100B04477 /* SQLException.h in Headers */,
19472
				B525A96511CA2340003A23A8 /* JSSQLException.h in Headers */,
19486
				B525A96511CA2340003A23A8 /* JSSQLException.h in Headers */,
19487
				B5D31DFB11CF610B009F22B4 /* ActiveDOMCallback.h in Headers */,
19473
			);
19488
			);
19474
			runOnlyForDeploymentPostprocessing = 0;
19489
			runOnlyForDeploymentPostprocessing = 0;
19475
		};
19490
		};
Lines 21782-21787 WebCore/WebCore.xcodeproj/project.pbxproj_sec6
21782
				200B190911C277D900DCCD3A /* ScriptBreakpoint.cpp in Sources */,
21797
				200B190911C277D900DCCD3A /* ScriptBreakpoint.cpp in Sources */,
21783
				1AD8F81C11CAB9E900E93E54 /* PlatformStrategies.cpp in Sources */,
21798
				1AD8F81C11CAB9E900E93E54 /* PlatformStrategies.cpp in Sources */,
21784
				B525A96611CA2340003A23A8 /* JSSQLException.cpp in Sources */,
21799
				B525A96611CA2340003A23A8 /* JSSQLException.cpp in Sources */,
21800
				B5D31DFA11CF610B009F22B4 /* ActiveDOMCallback.cpp in Sources */,
21785
			);
21801
			);
21786
			runOnlyForDeploymentPostprocessing = 0;
21802
			runOnlyForDeploymentPostprocessing = 0;
21787
		};
21803
		};
- WebCore/bindings/generic/ActiveDOMCallback.cpp +140 lines
Line 0 WebCore/bindings/generic/ActiveDOMCallback.cpp_sec1
1
/*
2
 * Copyright (C) 2010 Google Inc. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions are
6
 * met:
7
 *
8
 *     * Redistributions of source code must retain the above copyright
9
 * notice, this list of conditions and the following disclaimer.
10
 *     * Redistributions in binary form must reproduce the above
11
 * copyright notice, this list of conditions and the following disclaimer
12
 * in the documentation and/or other materials provided with the
13
 * distribution.
14
 *     * Neither the name of Google Inc. nor the names of its
15
 * contributors may be used to endorse or promote products derived from
16
 * this software without specific prior written permission.
17
 *
18
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
 */
30
31
#include "config.h"
32
#include "ActiveDOMCallback.h"
33
34
#include "ActiveDOMObject.h"
35
#include "ScriptExecutionContext.h"
36
#include <wtf/ThreadingPrimitives.h>
37
38
namespace WebCore {
39
40
static void destroyOnContextThread(ActiveDOMObjectCallbackImpl*, Mutex*, bool);
41
42
class DestroyOnContextThreadTask : public ScriptExecutionContext::Task {
43
public:
44
    static PassOwnPtr<DestroyOnContextThreadTask> create(ActiveDOMObjectCallbackImpl* impl, Mutex* implMutex, bool deleteMutex)
45
    {
46
        return new DestroyOnContextThreadTask(impl, implMutex, deleteMutex);
47
    }
48
49
    virtual void performTask(ScriptExecutionContext*)
50
    {
51
        destroyOnContextThread(m_impl, m_implMutex, m_deleteMutex);
52
    }
53
54
private:
55
    DestroyOnContextThreadTask(ActiveDOMObjectCallbackImpl* impl, Mutex* implMutex, bool deleteMutex)
56
        : m_impl(impl)
57
        , m_implMutex(implMutex)
58
        , m_deleteMutex(deleteMutex)
59
    {
60
    }
61
62
    ActiveDOMObjectCallbackImpl* m_impl;
63
    Mutex* m_implMutex;
64
    bool m_deleteMutex;
65
};
66
67
// Instances of this class are accessed only on the context thread, so we don't need to use locks.
68
class ActiveDOMObjectCallbackImpl : public ActiveDOMObject {
69
public:
70
    ActiveDOMObjectCallbackImpl(ScriptExecutionContext* context, Mutex* mutex)
71
        : ActiveDOMObject(context, this)
72
        , m_mutex(mutex)
73
        , m_suspended(false)
74
        , m_stopped(false)
75
    {
76
    }
77
78
    virtual void contextDestroyed() { destroyOnContextThread(this, m_mutex, false); }
79
    virtual bool canSuspend() const { return false; }
80
    virtual void suspend() { m_suspended = true; }
81
    virtual void resume() { m_suspended = false; }
82
    virtual void stop() { m_stopped = true; }
83
    bool canInvokeCallback() const { return (!m_suspended && !m_stopped); }
84
85
private:
86
    Mutex* m_mutex;
87
    bool m_suspended;
88
    bool m_stopped;
89
};
90
91
static void destroyOnContextThread(ActiveDOMObjectCallbackImpl* impl, Mutex* implMutex, bool deleteMutex)
92
{
93
    {
94
        // implMutex is NULL if and only if ActiveDOMCallback's destructor was already called and impl
95
        // was already deleted. Once these two things happen though, destroyOnContextThread() is not
96
        // called from anywhere. So if we got here, then we can be sure that implMutex != NULL.
97
        MutexLocker locker(*implMutex);
98
        if (impl) {
99
            ScriptExecutionContext* context = impl->scriptExecutionContext();
100
            if (!context->isContextThread()) {
101
                context->postTask(DestroyOnContextThreadTask::create(impl, implMutex, deleteMutex));
102
                return;
103
            }
104
105
            delete impl;
106
        }
107
    }
108
109
    if (deleteMutex)
110
        delete implMutex;
111
}
112
113
ActiveDOMCallback::ActiveDOMCallback(ScriptExecutionContext* context)
114
    : m_implMutex(new Mutex())
115
    , m_impl(new ActiveDOMObjectCallbackImpl(context, m_implMutex))
116
{
117
    ASSERT(context->isContextThread());
118
}
119
120
ActiveDOMCallback::~ActiveDOMCallback()
121
{
122
    destroyOnContextThread(m_impl, m_implMutex, true);
123
}
124
125
bool ActiveDOMCallback::canInvokeCallback()
126
{
127
    MutexLocker locker(*m_implMutex);
128
    return (m_impl && m_impl->canInvokeCallback());
129
}
130
131
ScriptExecutionContext* ActiveDOMCallback::scriptExecutionContext() const
132
{
133
    MutexLocker locker(*m_implMutex);
134
    if (m_impl)
135
        return m_impl->scriptExecutionContext();
136
137
    return 0;
138
}
139
140
} // namespace WebCore
- WebCore/bindings/generic/ActiveDOMCallback.h +68 lines
Line 0 WebCore/bindings/generic/ActiveDOMCallback.h_sec1
1
/*
2
 * Copyright (C) 2010 Google Inc. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions are
6
 * met:
7
 *
8
 *     * Redistributions of source code must retain the above copyright
9
 * notice, this list of conditions and the following disclaimer.
10
 *     * Redistributions in binary form must reproduce the above
11
 * copyright notice, this list of conditions and the following disclaimer
12
 * in the documentation and/or other materials provided with the
13
 * distribution.
14
 *     * Neither the name of Google Inc. nor the names of its
15
 * contributors may be used to endorse or promote products derived from
16
 * this software without specific prior written permission.
17
 *
18
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
 */
30
31
#ifndef ActiveDOMCallback_h
32
#define ActiveDOMCallback_h
33
34
namespace WTF {
35
class Mutex;
36
}
37
38
namespace WebCore {
39
40
class ActiveDOMObjectCallbackImpl;
41
class ScriptExecutionContext;
42
43
// A class that allows callbacks to behave like ActiveDOMObjects, and also
44
// be destroyed on the context thread or any other thread.
45
class ActiveDOMCallback {
46
public:
47
    ActiveDOMCallback(ScriptExecutionContext* context);
48
    ~ActiveDOMCallback();
49
50
    bool canInvokeCallback();
51
    ScriptExecutionContext* scriptExecutionContext() const;
52
53
private:
54
    // A mutex used to coordinate access to m_impl. This mutex is destroyed only when/after the
55
    // ActiveDOMCallback instance is destroyed. So the methods of this class can assume that it
56
    // is not NULL, and can use it to acquire locks; unless somebody calls a method of this
57
    // class on an instance that has been destroyed, in which case that code needs to be fixed.
58
    WTF::Mutex* m_implMutex;
59
60
    // The ActiveDOMObject part of the callback. We use a raw pointer here,
61
    // because the destructor can be called on any thread, and we need to
62
    // make sure that this object gets destroyed only on the context thread.
63
    ActiveDOMObjectCallbackImpl* m_impl;
64
};
65
66
} // namespace WebCore
67
68
#endif // ActiveDOMCallback_h
- WebCore/bindings/js/JSCustomSQLStatementErrorCallback.cpp -7 / +8 lines
Lines 41-62 namespace WebCore { WebCore/bindings/js/JSCustomSQLStatementErrorCallback.cpp_sec1
41
41
42
using namespace JSC;
42
using namespace JSC;
43
43
44
bool JSSQLStatementErrorCallback::handleEvent(ScriptExecutionContext* context, SQLTransaction* transaction, SQLError* error)
44
bool JSSQLStatementErrorCallback::handleEvent(SQLTransaction* transaction, SQLError* error)
45
{
45
{
46
    ASSERT(m_data);
46
    if (!m_data || !canInvokeCallback())
47
    ASSERT(context);
47
        return true;
48
48
49
    RefPtr<JSSQLStatementErrorCallback> protect(this);
49
    RefPtr<JSSQLStatementErrorCallback> protect(this);
50
50
51
    JSC::JSLock lock(SilenceAssertionsOnly);
51
    JSC::JSLock lock(SilenceAssertionsOnly);
52
    JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(context, m_isolatedWorld.get());
52
53
    JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(scriptExecutionContext(), m_isolatedWorld.get());
53
    if (!globalObject)
54
    if (!globalObject)
54
        return true; // if we cannot invoke the callback, roll back the transaction
55
        return true;
55
56
56
    ExecState* exec = globalObject->globalExec();
57
    ExecState* exec = globalObject->globalExec();
57
    MarkedArgumentBuffer args;
58
    MarkedArgumentBuffer args;
58
    args.append(toJS(exec, deprecatedGlobalObjectForPrototype(exec), transaction));
59
    args.append(toJS(exec, transaction));
59
    args.append(toJS(exec, deprecatedGlobalObjectForPrototype(exec), error));
60
    args.append(toJS(exec, error));
60
61
61
    bool raisedException = false;
62
    bool raisedException = false;
62
    JSValue result = m_data->invokeCallback(args, &raisedException);
63
    JSValue result = m_data->invokeCallback(args, &raisedException);
- WebCore/bindings/js/JSSQLTransactionCustom.cpp -2 / +2 lines
Lines 95-101 JSValue JSSQLTransaction::executeSql(Exe WebCore/bindings/js/JSSQLTransactionCustom.cpp_sec1
95
            return jsUndefined();
95
            return jsUndefined();
96
        }
96
        }
97
97
98
        callback = JSSQLStatementCallback::create(object, static_cast<JSDOMGlobalObject*>(exec->dynamicGlobalObject()));
98
        callback = JSSQLStatementCallback::create(object, static_cast<JSDOMGlobalObject*>(globalObject()));
99
    }
99
    }
100
100
101
    RefPtr<SQLStatementErrorCallback> errorCallback;
101
    RefPtr<SQLStatementErrorCallback> errorCallback;
Lines 106-112 JSValue JSSQLTransaction::executeSql(Exe WebCore/bindings/js/JSSQLTransactionCustom.cpp_sec2
106
            return jsUndefined();
106
            return jsUndefined();
107
        }
107
        }
108
108
109
        errorCallback = JSSQLStatementErrorCallback::create(object, static_cast<JSDOMGlobalObject*>(exec->dynamicGlobalObject()));
109
        errorCallback = JSSQLStatementErrorCallback::create(object, static_cast<JSDOMGlobalObject*>(globalObject()));
110
    }
110
    }
111
111
112
    ExceptionCode ec = 0;
112
    ExceptionCode ec = 0;
- WebCore/bindings/scripts/CodeGeneratorJS.pm -13 / +17 lines
Lines 2055-2066 sub GenerateCallbackHeader WebCore/bindings/scripts/CodeGeneratorJS.pm_sec1
2055
    # - Add default header template and header protection
2055
    # - Add default header template and header protection
2056
    push(@headerContentHeader, GenerateHeaderContentHeader($dataNode));
2056
    push(@headerContentHeader, GenerateHeaderContentHeader($dataNode));
2057
2057
2058
    $headerIncludes{"ActiveDOMCallback.h"} = 1;
2058
    $headerIncludes{"$interfaceName.h"} = 1;
2059
    $headerIncludes{"$interfaceName.h"} = 1;
2059
    $headerIncludes{"JSCallbackData.h"} = 1;
2060
    $headerIncludes{"JSCallbackData.h"} = 1;
2060
    $headerIncludes{"<wtf/Forward.h>"} = 1;
2061
    $headerIncludes{"<wtf/Forward.h>"} = 1;
2061
2062
2062
    push(@headerContent, "\nnamespace WebCore {\n\n");
2063
    push(@headerContent, "\nnamespace WebCore {\n\n");
2063
    push(@headerContent, "class $className : public $interfaceName {\n");
2064
    push(@headerContent, "class $className : public $interfaceName, public ActiveDOMCallback {\n");
2064
    push(@headerContent, "public:\n");
2065
    push(@headerContent, "public:\n");
2065
2066
2066
    # The static create() method.
2067
    # The static create() method.
Lines 2083-2092 sub GenerateCallbackHeader WebCore/bindings/scripts/CodeGeneratorJS.pm_sec2
2083
                push(@headerContent, "    COMPILE_ASSERT(false)");
2084
                push(@headerContent, "    COMPILE_ASSERT(false)");
2084
            }
2085
            }
2085
2086
2086
            push(@headerContent, "    virtual " . GetNativeType($function->signature->type) . " " . $function->signature->name . "(ScriptExecutionContext*");
2087
            push(@headerContent, "    virtual " . GetNativeType($function->signature->type) . " " . $function->signature->name . "(");
2088
2089
            my @args = ();
2087
            foreach my $param (@params) {
2090
            foreach my $param (@params) {
2088
                push(@headerContent, ", " . GetNativeType($param->type) . " " . $param->name);
2091
                push(@args, GetNativeType($param->type) . " " . $param->name);
2089
            }
2092
            }
2093
            push(@headerContent, join(", ", @args));
2090
2094
2091
            push(@headerContent, ");\n");
2095
            push(@headerContent, ");\n");
2092
        }
2096
        }
Lines 2100-2106 sub GenerateCallbackHeader WebCore/bindings/scripts/CodeGeneratorJS.pm_sec3
2100
    # Private members
2104
    # Private members
2101
    push(@headerContent, "    JSCallbackData* m_data;\n");
2105
    push(@headerContent, "    JSCallbackData* m_data;\n");
2102
    push(@headerContent, "    RefPtr<DOMWrapperWorld> m_isolatedWorld;\n");
2106
    push(@headerContent, "    RefPtr<DOMWrapperWorld> m_isolatedWorld;\n");
2103
    push(@headerContent, "    ScriptExecutionContext* m_scriptExecutionContext;\n");
2104
    push(@headerContent, "};\n\n");
2107
    push(@headerContent, "};\n\n");
2105
2108
2106
    push(@headerContent, "} // namespace WebCore\n\n");
2109
    push(@headerContent, "} // namespace WebCore\n\n");
Lines 2130-2145 sub GenerateCallbackImplementation WebCore/bindings/scripts/CodeGeneratorJS.pm_sec4
2130
2133
2131
    # Constructor
2134
    # Constructor
2132
    push(@implContent, "${className}::${className}(JSObject* callback, JSDOMGlobalObject* globalObject)\n");
2135
    push(@implContent, "${className}::${className}(JSObject* callback, JSDOMGlobalObject* globalObject)\n");
2133
    push(@implContent, "    : m_data(new JSCallbackData(callback, globalObject))\n");
2136
    push(@implContent, "    : ActiveDOMCallback(globalObject->scriptExecutionContext())\n");
2137
    push(@implContent, "    , m_data(new JSCallbackData(callback, globalObject))\n");
2134
    push(@implContent, "    , m_isolatedWorld(globalObject->world())\n");
2138
    push(@implContent, "    , m_isolatedWorld(globalObject->world())\n");
2135
    push(@implContent, "    , m_scriptExecutionContext(globalObject->scriptExecutionContext())\n");
2136
    push(@implContent, "{\n");
2139
    push(@implContent, "{\n");
2137
    push(@implContent, "}\n\n");
2140
    push(@implContent, "}\n\n");
2138
2141
2139
    # Destructor
2142
    # Destructor
2140
    push(@implContent, "${className}::~${className}()\n");
2143
    push(@implContent, "${className}::~${className}()\n");
2141
    push(@implContent, "{\n");
2144
    push(@implContent, "{\n");
2142
    push(@implContent, "    m_scriptExecutionContext->postTask(DeleteCallbackDataTask::create(m_data));\n");
2145
    push(@implContent, "    scriptExecutionContext()->postTask(DeleteCallbackDataTask::create(m_data));\n");
2143
    push(@implContent, "#ifndef NDEBUG\n");
2146
    push(@implContent, "#ifndef NDEBUG\n");
2144
    push(@implContent, "    m_data = 0;\n");
2147
    push(@implContent, "    m_data = 0;\n");
2145
    push(@implContent, "#endif\n");
2148
    push(@implContent, "#endif\n");
Lines 2157-2177 sub GenerateCallbackImplementation WebCore/bindings/scripts/CodeGeneratorJS.pm_sec5
2157
            }
2160
            }
2158
2161
2159
            AddIncludesForType($function->signature->type);
2162
            AddIncludesForType($function->signature->type);
2160
            push(@implContent, "\n" . GetNativeType($function->signature->type) . " ${className}::" . $function->signature->name . "(ScriptExecutionContext* context");
2163
            push(@implContent, "\n" . GetNativeType($function->signature->type) . " ${className}::" . $function->signature->name . "(");
2161
2164
2165
            my @args = ();
2162
            foreach my $param (@params) {
2166
            foreach my $param (@params) {
2163
                AddIncludesForType($param->type, 1);
2167
                AddIncludesForType($param->type, 1);
2164
                push(@implContent, ", " . GetNativeType($param->type) . " " . $param->name);
2168
                push(@args, GetNativeType($param->type) . " " . $param->name);
2165
            }
2169
            }
2166
2170
            push(@implContent, join(", ", @args));
2167
            push(@implContent, ")\n");
2171
            push(@implContent, ")\n");
2168
2172
2169
            push(@implContent, "{\n");
2173
            push(@implContent, "{\n");
2170
            push(@implContent, "    ASSERT(m_data);\n");
2174
            push(@implContent, "    if (!m_data || !canInvokeCallback())\n");
2171
            push(@implContent, "    ASSERT(context);\n\n");
2175
            push(@implContent, "        return true;\n\n");
2172
            push(@implContent, "    RefPtr<$className> protect(this);\n\n");
2176
            push(@implContent, "    RefPtr<$className> protect(this);\n\n");
2173
            push(@implContent, "    JSLock lock(SilenceAssertionsOnly);\n\n");
2177
            push(@implContent, "    JSLock lock(SilenceAssertionsOnly);\n\n");
2174
            push(@implContent, "    JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(context, m_isolatedWorld.get());\n");
2178
            push(@implContent, "    JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(scriptExecutionContext(), m_isolatedWorld.get());\n");
2175
            push(@implContent, "    if (!globalObject)\n");
2179
            push(@implContent, "    if (!globalObject)\n");
2176
            push(@implContent, "        return true;\n\n");
2180
            push(@implContent, "        return true;\n\n");
2177
            push(@implContent, "    ExecState* exec = globalObject->globalExec();\n");
2181
            push(@implContent, "    ExecState* exec = globalObject->globalExec();\n");
- WebCore/bindings/scripts/CodeGeneratorV8.pm -26 / +33 lines
Lines 2126-2150 sub GenerateCallbackHeader WebCore/bindings/scripts/CodeGeneratorV8.pm_sec1
2126
    # - Add default header template
2126
    # - Add default header template
2127
    push(@headerContent, GenerateHeaderContentHeader($dataNode));
2127
    push(@headerContent, GenerateHeaderContentHeader($dataNode));
2128
2128
2129
    if ("$interfaceName.h" lt "WorldContextHandle.h") {
2129
    my @unsortedIncludes = ();
2130
        push(@headerContent, "#include \"$interfaceName.h\"\n");
2130
    push(@unsortedIncludes, "#include \"ActiveDOMCallback.h\"");
2131
        push(@headerContent, "#include \"WorldContextHandle.h\"\n");
2131
    push(@unsortedIncludes, "#include \"$interfaceName.h\"");
2132
    } else {
2132
    push(@unsortedIncludes, "#include \"WorldContextHandle.h\"");
2133
        push(@headerContent, "#include \"WorldContextHandle.h\"\n");
2133
    push(@unsortedIncludes, "#include <v8.h>");
2134
        push(@headerContent, "#include \"$interfaceName.h\"\n");
2134
    push(@unsortedIncludes, "#include <wtf/Forward.h>");
2135
    }
2135
    push(@headerContent, join("\n", sort @unsortedIncludes));
2136
    push(@headerContent, "#include <v8.h>\n");
2137
    push(@headerContent, "#include <wtf/Forward.h>\n");
2138
    
2136
    
2139
    push(@headerContent, "\nnamespace WebCore {\n\n");
2137
    push(@headerContent, "\n\nnamespace WebCore {\n\n");
2140
    push(@headerContent, "class $className : public $interfaceName {\n");
2138
    push(@headerContent, "class ScriptExecutionContext;\n\n");
2139
    push(@headerContent, "class $className : public $interfaceName, public ActiveDOMCallback {\n");
2141
2140
2142
    push(@headerContent, <<END);
2141
    push(@headerContent, <<END);
2143
public:
2142
public:
2144
    static PassRefPtr<${className}> create(v8::Local<v8::Value> value)
2143
    static PassRefPtr<${className}> create(v8::Local<v8::Value> value, ScriptExecutionContext* context)
2145
    {
2144
    {
2146
        ASSERT(value->IsObject());
2145
        ASSERT(value->IsObject());
2147
        return adoptRef(new ${className}(value->ToObject()));
2146
        ASSERT(context);
2147
        return adoptRef(new ${className}(value->ToObject(), context));
2148
    }
2148
    }
2149
2149
2150
    virtual ~${className}();
2150
    virtual ~${className}();
Lines 2162-2172 END WebCore/bindings/scripts/CodeGeneratorV8.pm_sec2
2162
                    push(@headerContent, "    COMPILE_ASSERT(false)");
2162
                    push(@headerContent, "    COMPILE_ASSERT(false)");
2163
            }
2163
            }
2164
2164
2165
            push(@headerContent, "    virtual " . GetNativeTypeForCallbacks($function->signature->type) . " " . $function->signature->name . "(ScriptExecutionContext*");
2165
            push(@headerContent, "    virtual " . GetNativeTypeForCallbacks($function->signature->type) . " " . $function->signature->name . "(");
2166
2167
            my @args = ();
2166
            foreach my $param (@params) {
2168
            foreach my $param (@params) {
2167
                push(@headerContent, ", " . GetNativeTypeForCallbacks($param->type) . " " . $param->name);
2169
                push(@args, GetNativeTypeForCallbacks($param->type) . " " . $param->name);
2168
            }
2170
            }
2169
2171
            push(@headerContent, join(", ", @args));
2170
            push(@headerContent, ");\n");
2172
            push(@headerContent, ");\n");
2171
        }
2173
        }
2172
    }
2174
    }
Lines 2174-2180 END WebCore/bindings/scripts/CodeGeneratorV8.pm_sec3
2174
    push(@headerContent, <<END);
2176
    push(@headerContent, <<END);
2175
2177
2176
private:
2178
private:
2177
    ${className}(v8::Local<v8::Object>);
2179
    ${className}(v8::Local<v8::Object>, ScriptExecutionContext*);
2178
2180
2179
    v8::Persistent<v8::Object> m_callback;
2181
    v8::Persistent<v8::Object> m_callback;
2180
    WorldContextHandle m_worldContext;
2182
    WorldContextHandle m_worldContext;
Lines 2206-2213 sub GenerateCallbackImplementation WebCore/bindings/scripts/CodeGeneratorV8.pm_sec4
2206
    push(@implContent, "#include <wtf/Assertions.h>\n\n");
2208
    push(@implContent, "#include <wtf/Assertions.h>\n\n");
2207
    push(@implContent, "namespace WebCore {\n\n");
2209
    push(@implContent, "namespace WebCore {\n\n");
2208
    push(@implContent, <<END);
2210
    push(@implContent, <<END);
2209
${className}::${className}(v8::Local<v8::Object> callback)
2211
${className}::${className}(v8::Local<v8::Object> callback, ScriptExecutionContext* context)
2210
    : m_callback(v8::Persistent<v8::Object>::New(callback))
2212
    : ActiveDOMCallback(context)
2213
    , m_callback(v8::Persistent<v8::Object>::New(callback))
2211
    , m_worldContext(UseCurrentWorld)
2214
    , m_worldContext(UseCurrentWorld)
2212
{
2215
{
2213
}
2216
}
Lines 2231-2252 END WebCore/bindings/scripts/CodeGeneratorV8.pm_sec5
2231
            }
2234
            }
2232
2235
2233
            AddIncludesForType($function->signature->type);
2236
            AddIncludesForType($function->signature->type);
2234
            push(@implContent, "\n" . GetNativeTypeForCallbacks($function->signature->type) . " ${className}::" . $function->signature->name . "(ScriptExecutionContext* context");
2237
            push(@implContent, "\n" . GetNativeTypeForCallbacks($function->signature->type) . " ${className}::" . $function->signature->name . "(");
2235
2238
2239
            my @args = ();
2236
            foreach my $param (@params) {
2240
            foreach my $param (@params) {
2237
                AddIncludesForType($param->type);
2241
                AddIncludesForType($param->type);
2238
                push(@implContent, ", " . GetNativeTypeForCallbacks($param->type) . " " . $param->name);
2242
                push(@args, GetNativeTypeForCallbacks($param->type) . " " . $param->name);
2239
            }
2243
            }
2244
            push(@implContent, join(", ", @args));
2240
2245
2241
            push(@implContent, ")\n");
2246
            push(@implContent, ")\n");
2242
            push(@implContent, "{\n");
2247
            push(@implContent, "{\n");
2248
            push(@implContent, "    if (!canInvokeCallback())\n");
2249
            push(@implContent, "        return true;\n\n");
2243
            push(@implContent, "    v8::HandleScope handleScope;\n\n");
2250
            push(@implContent, "    v8::HandleScope handleScope;\n\n");
2244
            push(@implContent, "    v8::Handle<v8::Context> v8Context = toV8Context(context, m_worldContext);\n");
2251
            push(@implContent, "    v8::Handle<v8::Context> v8Context = toV8Context(scriptExecutionContext(), m_worldContext);\n");
2245
            push(@implContent, "    if (v8Context.IsEmpty())\n");
2252
            push(@implContent, "    if (v8Context.IsEmpty())\n");
2246
            push(@implContent, "        return true;\n\n");
2253
            push(@implContent, "        return true;\n\n");
2247
            push(@implContent, "    v8::Context::Scope scope(v8Context);\n\n");
2254
            push(@implContent, "    v8::Context::Scope scope(v8Context);\n\n");
2248
2255
2249
            my @argvs = ();
2256
            @args = ();
2250
            foreach my $param (@params) {
2257
            foreach my $param (@params) {
2251
                my $paramName = $param->name;
2258
                my $paramName = $param->name;
2252
                push(@implContent, "    v8::Handle<v8::Value> ${paramName}Handle = toV8(${paramName});\n");
2259
                push(@implContent, "    v8::Handle<v8::Value> ${paramName}Handle = toV8(${paramName});\n");
Lines 2254-2267 END WebCore/bindings/scripts/CodeGeneratorV8.pm_sec6
2254
                push(@implContent, "        CRASH();\n");
2261
                push(@implContent, "        CRASH();\n");
2255
                push(@implContent, "        return true;\n");
2262
                push(@implContent, "        return true;\n");
2256
                push(@implContent, "    }\n");
2263
                push(@implContent, "    }\n");
2257
                push(@argvs, "        ${paramName}Handle");
2264
                push(@args, "        ${paramName}Handle");
2258
            }
2265
            }
2259
2266
2260
            push(@implContent, "\n    v8::Handle<v8::Value> argv[] = {\n");
2267
            push(@implContent, "\n    v8::Handle<v8::Value> argv[] = {\n");
2261
            push(@implContent, join(",\n", @argvs));
2268
            push(@implContent, join(",\n", @args));
2262
            push(@implContent, "\n    };\n\n");
2269
            push(@implContent, "\n    };\n\n");
2263
            push(@implContent, "    bool callbackReturnValue = false;\n");
2270
            push(@implContent, "    bool callbackReturnValue = false;\n");
2264
            push(@implContent, "    return !invokeCallback(m_callback, " . scalar(@params) . ", argv, callbackReturnValue, context);\n");
2271
            push(@implContent, "    return !invokeCallback(m_callback, " . scalar(@params) . ", argv, callbackReturnValue, scriptExecutionContext());\n");
2265
            push(@implContent, "}\n");
2272
            push(@implContent, "}\n");
2266
        }
2273
        }
2267
    }
2274
    }
- WebCore/bindings/scripts/test/JS/JSTestCallback.cpp -11 / +11 lines
Lines 35-49 using namespace JSC; WebCore/bindings/scripts/test/JS/JSTestCallback.cpp_sec1
35
namespace WebCore {
35
namespace WebCore {
36
36
37
JSTestCallback::JSTestCallback(JSObject* callback, JSDOMGlobalObject* globalObject)
37
JSTestCallback::JSTestCallback(JSObject* callback, JSDOMGlobalObject* globalObject)
38
    : m_data(new JSCallbackData(callback, globalObject))
38
    : ActiveDOMCallback(globalObject->scriptExecutionContext())
39
    , m_data(new JSCallbackData(callback, globalObject))
39
    , m_isolatedWorld(globalObject->world())
40
    , m_isolatedWorld(globalObject->world())
40
    , m_scriptExecutionContext(globalObject->scriptExecutionContext())
41
{
41
{
42
}
42
}
43
43
44
JSTestCallback::~JSTestCallback()
44
JSTestCallback::~JSTestCallback()
45
{
45
{
46
    m_scriptExecutionContext->postTask(DeleteCallbackDataTask::create(m_data));
46
    scriptExecutionContext()->postTask(DeleteCallbackDataTask::create(m_data));
47
#ifndef NDEBUG
47
#ifndef NDEBUG
48
    m_data = 0;
48
    m_data = 0;
49
#endif
49
#endif
Lines 51-66 JSTestCallback::~JSTestCallback() WebCore/bindings/scripts/test/JS/JSTestCallback.cpp_sec2
51
51
52
// Functions
52
// Functions
53
53
54
bool JSTestCallback::callbackWithClass1Param(ScriptExecutionContext* context, Class1* class1Param)
54
bool JSTestCallback::callbackWithClass1Param(Class1* class1Param)
55
{
55
{
56
    ASSERT(m_data);
56
    if (!m_data || !canInvokeCallback())
57
    ASSERT(context);
57
        return true;
58
58
59
    RefPtr<JSTestCallback> protect(this);
59
    RefPtr<JSTestCallback> protect(this);
60
60
61
    JSLock lock(SilenceAssertionsOnly);
61
    JSLock lock(SilenceAssertionsOnly);
62
62
63
    JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(context, m_isolatedWorld.get());
63
    JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(scriptExecutionContext(), m_isolatedWorld.get());
64
    if (!globalObject)
64
    if (!globalObject)
65
        return true;
65
        return true;
66
66
Lines 73-88 bool JSTestCallback::callbackWithClass1P WebCore/bindings/scripts/test/JS/JSTestCallback.cpp_sec3
73
    return !raisedException;
73
    return !raisedException;
74
}
74
}
75
75
76
bool JSTestCallback::callbackWithClass2Param(ScriptExecutionContext* context, Class2* class2Param, const String& strArg)
76
bool JSTestCallback::callbackWithClass2Param(Class2* class2Param, const String& strArg)
77
{
77
{
78
    ASSERT(m_data);
78
    if (!m_data || !canInvokeCallback())
79
    ASSERT(context);
79
        return true;
80
80
81
    RefPtr<JSTestCallback> protect(this);
81
    RefPtr<JSTestCallback> protect(this);
82
82
83
    JSLock lock(SilenceAssertionsOnly);
83
    JSLock lock(SilenceAssertionsOnly);
84
84
85
    JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(context, m_isolatedWorld.get());
85
    JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(scriptExecutionContext(), m_isolatedWorld.get());
86
    if (!globalObject)
86
    if (!globalObject)
87
        return true;
87
        return true;
88
88
- WebCore/bindings/scripts/test/JS/JSTestCallback.h -6 / +6 lines
Lines 23-35 WebCore/bindings/scripts/test/JS/JSTestCallback.h_sec1
23
23
24
#if ENABLE(DATABASE)
24
#if ENABLE(DATABASE)
25
25
26
#include "ActiveDOMCallback.h"
26
#include "JSCallbackData.h"
27
#include "JSCallbackData.h"
27
#include "TestCallback.h"
28
#include "TestCallback.h"
28
#include <wtf/Forward.h>
29
#include <wtf/Forward.h>
29
30
30
namespace WebCore {
31
namespace WebCore {
31
32
32
class JSTestCallback : public TestCallback {
33
class JSTestCallback : public TestCallback, public ActiveDOMCallback {
33
public:
34
public:
34
    static PassRefPtr<JSTestCallback> create(JSC::JSObject* callback, JSDOMGlobalObject* globalObject)
35
    static PassRefPtr<JSTestCallback> create(JSC::JSObject* callback, JSDOMGlobalObject* globalObject)
35
    {
36
    {
Lines 39-55 public: WebCore/bindings/scripts/test/JS/JSTestCallback.h_sec2
39
    virtual ~JSTestCallback();
40
    virtual ~JSTestCallback();
40
41
41
    // Functions
42
    // Functions
42
    virtual bool callbackWithClass1Param(ScriptExecutionContext*, Class1* class1Param);
43
    virtual bool callbackWithClass1Param(Class1* class1Param);
43
    virtual bool callbackWithClass2Param(ScriptExecutionContext*, Class2* class2Param, const String& strArg);
44
    virtual bool callbackWithClass2Param(Class2* class2Param, const String& strArg);
44
    COMPILE_ASSERT(false)    virtual int callbackWithNonBoolReturnType(ScriptExecutionContext*, Class3* class3Param);
45
    COMPILE_ASSERT(false)    virtual int callbackWithNonBoolReturnType(Class3* class3Param);
45
    virtual int customCallback(ScriptExecutionContext*, Class5* class5Param, Class6* class6Param);
46
    virtual int customCallback(Class5* class5Param, Class6* class6Param);
46
47
47
private:
48
private:
48
    JSTestCallback(JSC::JSObject* callback, JSDOMGlobalObject*);
49
    JSTestCallback(JSC::JSObject* callback, JSDOMGlobalObject*);
49
50
50
    JSCallbackData* m_data;
51
    JSCallbackData* m_data;
51
    RefPtr<DOMWrapperWorld> m_isolatedWorld;
52
    RefPtr<DOMWrapperWorld> m_isolatedWorld;
52
    ScriptExecutionContext* m_scriptExecutionContext;
53
};
53
};
54
54
55
} // namespace WebCore
55
} // namespace WebCore
- WebCore/bindings/scripts/test/V8/V8TestCallback.cpp -8 / +15 lines
Lines 34-41 WebCore/bindings/scripts/test/V8/V8TestCallback.cpp_sec1
34
34
35
namespace WebCore {
35
namespace WebCore {
36
36
37
V8TestCallback::V8TestCallback(v8::Local<v8::Object> callback)
37
V8TestCallback::V8TestCallback(v8::Local<v8::Object> callback, ScriptExecutionContext* context)
38
    : m_callback(v8::Persistent<v8::Object>::New(callback))
38
    : ActiveDOMCallback(context)
39
    , m_callback(v8::Persistent<v8::Object>::New(callback))
39
    , m_worldContext(UseCurrentWorld)
40
    , m_worldContext(UseCurrentWorld)
40
{
41
{
41
}
42
}
Lines 47-57 V8TestCallback::~V8TestCallback() WebCore/bindings/scripts/test/V8/V8TestCallback.cpp_sec2
47
48
48
// Functions
49
// Functions
49
50
50
bool V8TestCallback::callbackWithClass1Param(ScriptExecutionContext* context, Class1* class1Param)
51
bool V8TestCallback::callbackWithClass1Param(Class1* class1Param)
51
{
52
{
53
    if (!canInvokeCallback())
54
        return true;
55
52
    v8::HandleScope handleScope;
56
    v8::HandleScope handleScope;
53
57
54
    v8::Handle<v8::Context> v8Context = toV8Context(context, m_worldContext);
58
    v8::Handle<v8::Context> v8Context = toV8Context(scriptExecutionContext(), m_worldContext);
55
    if (v8Context.IsEmpty())
59
    if (v8Context.IsEmpty())
56
        return true;
60
        return true;
57
61
Lines 68-81 bool V8TestCallback::callbackWithClass1P WebCore/bindings/scripts/test/V8/V8TestCallback.cpp_sec3
68
    };
72
    };
69
73
70
    bool callbackReturnValue = false;
74
    bool callbackReturnValue = false;
71
    return !invokeCallback(m_callback, 1, argv, callbackReturnValue, context);
75
    return !invokeCallback(m_callback, 1, argv, callbackReturnValue, scriptExecutionContext());
72
}
76
}
73
77
74
bool V8TestCallback::callbackWithClass2Param(ScriptExecutionContext* context, Class2* class2Param, const String& strArg)
78
bool V8TestCallback::callbackWithClass2Param(Class2* class2Param, const String& strArg)
75
{
79
{
80
    if (!canInvokeCallback())
81
        return true;
82
76
    v8::HandleScope handleScope;
83
    v8::HandleScope handleScope;
77
84
78
    v8::Handle<v8::Context> v8Context = toV8Context(context, m_worldContext);
85
    v8::Handle<v8::Context> v8Context = toV8Context(scriptExecutionContext(), m_worldContext);
79
    if (v8Context.IsEmpty())
86
    if (v8Context.IsEmpty())
80
        return true;
87
        return true;
81
88
Lines 98-104 bool V8TestCallback::callbackWithClass2P WebCore/bindings/scripts/test/V8/V8TestCallback.cpp_sec4
98
    };
105
    };
99
106
100
    bool callbackReturnValue = false;
107
    bool callbackReturnValue = false;
101
    return !invokeCallback(m_callback, 2, argv, callbackReturnValue, context);
108
    return !invokeCallback(m_callback, 2, argv, callbackReturnValue, scriptExecutionContext());
102
}
109
}
103
110
104
} // namespace WebCore
111
} // namespace WebCore
- WebCore/bindings/scripts/test/V8/V8TestCallback.h -8 / +12 lines
Lines 23-28 WebCore/bindings/scripts/test/V8/V8TestCallback.h_sec1
23
#ifndef V8TestCallback_h
23
#ifndef V8TestCallback_h
24
#define V8TestCallback_h
24
#define V8TestCallback_h
25
25
26
#include "ActiveDOMCallback.h"
26
#include "TestCallback.h"
27
#include "TestCallback.h"
27
#include "WorldContextHandle.h"
28
#include "WorldContextHandle.h"
28
#include <v8.h>
29
#include <v8.h>
Lines 30-53 WebCore/bindings/scripts/test/V8/V8TestCallback.h_sec2
30
31
31
namespace WebCore {
32
namespace WebCore {
32
33
33
class V8TestCallback : public TestCallback {
34
class ScriptExecutionContext;
35
36
class V8TestCallback : public TestCallback, public ActiveDOMCallback {
34
public:
37
public:
35
    static PassRefPtr<V8TestCallback> create(v8::Local<v8::Value> value)
38
    static PassRefPtr<V8TestCallback> create(v8::Local<v8::Value> value, ScriptExecutionContext* context)
36
    {
39
    {
37
        ASSERT(value->IsObject());
40
        ASSERT(value->IsObject());
38
        return adoptRef(new V8TestCallback(value->ToObject()));
41
        ASSERT(context);
42
        return adoptRef(new V8TestCallback(value->ToObject(), context));
39
    }
43
    }
40
44
41
    virtual ~V8TestCallback();
45
    virtual ~V8TestCallback();
42
46
43
    // Functions
47
    // Functions
44
    virtual bool callbackWithClass1Param(ScriptExecutionContext*, Class1* class1Param);
48
    virtual bool callbackWithClass1Param(Class1* class1Param);
45
    virtual bool callbackWithClass2Param(ScriptExecutionContext*, Class2* class2Param, const String& strArg);
49
    virtual bool callbackWithClass2Param(Class2* class2Param, const String& strArg);
46
    COMPILE_ASSERT(false)    virtual int callbackWithNonBoolReturnType(ScriptExecutionContext*, Class3* class3Param);
50
    COMPILE_ASSERT(false)    virtual int callbackWithNonBoolReturnType(Class3* class3Param);
47
    virtual int customCallback(ScriptExecutionContext*, Class5* class5Param, Class6* class6Param);
51
    virtual int customCallback(Class5* class5Param, Class6* class6Param);
48
52
49
private:
53
private:
50
    V8TestCallback(v8::Local<v8::Object>);
54
    V8TestCallback(v8::Local<v8::Object>, ScriptExecutionContext*);
51
55
52
    v8::Persistent<v8::Object> m_callback;
56
    v8::Persistent<v8::Object> m_callback;
53
    WorldContextHandle m_worldContext;
57
    WorldContextHandle m_worldContext;
- WebCore/bindings/v8/custom/V8CustomSQLStatementErrorCallback.cpp -6 / +6 lines
Lines 43-53 WebCore/bindings/v8/custom/V8CustomSQLStatementErrorCallback.cpp_sec1
43
43
44
namespace WebCore {
44
namespace WebCore {
45
45
46
bool V8SQLStatementErrorCallback::handleEvent(ScriptExecutionContext* context, SQLTransaction* transaction, SQLError* error)
46
bool V8SQLStatementErrorCallback::handleEvent(SQLTransaction* transaction, SQLError* error)
47
{
47
{
48
    if (!canInvokeCallback())
49
        return true;
50
48
    v8::HandleScope handleScope;
51
    v8::HandleScope handleScope;
49
52
50
    v8::Handle<v8::Context> v8Context = toV8Context(context, m_worldContext);
53
    v8::Handle<v8::Context> v8Context = toV8Context(scriptExecutionContext(), m_worldContext);
51
    if (v8Context.IsEmpty())
54
    if (v8Context.IsEmpty())
52
        return true;
55
        return true;
53
56
Lines 65-79 bool V8SQLStatementErrorCallback::handle WebCore/bindings/v8/custom/V8CustomSQLStatementErrorCallback.cpp_sec2
65
        errorHandle
68
        errorHandle
66
    };
69
    };
67
70
68
    // Protect the context until the callback returns.
69
    RefPtr<ScriptExecutionContext> protector(context);
70
71
    bool callbackReturnValue = false;
71
    bool callbackReturnValue = false;
72
    // Step 6: If the error callback returns false, then move on to the next
72
    // Step 6: If the error callback returns false, then move on to the next
73
    // statement, if any, or onto the next overall step otherwise. Otherwise,
73
    // statement, if any, or onto the next overall step otherwise. Otherwise,
74
    // the error callback did not return false, or there was no error callback.
74
    // the error callback did not return false, or there was no error callback.
75
    // Jump to the last step in the overall steps.
75
    // Jump to the last step in the overall steps.
76
    return invokeCallback(m_callback, 2, argv, callbackReturnValue, context) || callbackReturnValue;
76
    return invokeCallback(m_callback, 2, argv, callbackReturnValue, scriptExecutionContext()) || callbackReturnValue;
77
}
77
}
78
78
79
} // namespace WebCore
79
} // namespace WebCore
- WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp -1 / +2 lines
Lines 804-815 v8::Handle<v8::Value> V8DOMWindow::openD WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp_sec1
804
    if (!V8BindingSecurity::canAccessFrame(V8BindingState::Only(), imp->frame(), true))
804
    if (!V8BindingSecurity::canAccessFrame(V8BindingState::Only(), imp->frame(), true))
805
        return v8::Undefined();
805
        return v8::Undefined();
806
806
807
    ScriptExecutionContext* scriptExecutionContext = getScriptExecutionContext();
807
    RefPtr<DatabaseCallback> creationCallback;
808
    RefPtr<DatabaseCallback> creationCallback;
808
    if (args.Length() >= 5) {
809
    if (args.Length() >= 5) {
809
        if (!args[4]->IsObject())
810
        if (!args[4]->IsObject())
810
            return throwError(TYPE_MISMATCH_ERR);
811
            return throwError(TYPE_MISMATCH_ERR);
811
812
812
        creationCallback = V8DatabaseCallback::create(args[4]);
813
        creationCallback = V8DatabaseCallback::create(args[4], scriptExecutionContext);
813
    }
814
    }
814
815
815
    ExceptionCode ec = 0;
816
    ExceptionCode ec = 0;
- WebCore/bindings/v8/custom/V8DatabaseCustom.cpp -4 / +4 lines
Lines 64-70 v8::Handle<v8::Value> V8Database::change WebCore/bindings/v8/custom/V8DatabaseCustom.cpp_sec1
64
        if (!args[2]->IsObject())
64
        if (!args[2]->IsObject())
65
            return throwError(TYPE_MISMATCH_ERR);
65
            return throwError(TYPE_MISMATCH_ERR);
66
66
67
        callback = V8SQLTransactionCallback::create(args[2]);
67
        callback = V8SQLTransactionCallback::create(args[2], scriptExecutionContext);
68
    }
68
    }
69
69
70
    RefPtr<V8SQLTransactionErrorCallback> errorCallback;
70
    RefPtr<V8SQLTransactionErrorCallback> errorCallback;
Lines 72-78 v8::Handle<v8::Value> V8Database::change WebCore/bindings/v8/custom/V8DatabaseCustom.cpp_sec2
72
        if (!args[3]->IsObject())
72
        if (!args[3]->IsObject())
73
            return throwError(TYPE_MISMATCH_ERR);
73
            return throwError(TYPE_MISMATCH_ERR);
74
74
75
        errorCallback = V8SQLTransactionErrorCallback::create(args[3]);
75
        errorCallback = V8SQLTransactionErrorCallback::create(args[3], scriptExecutionContext);
76
    }
76
    }
77
77
78
    RefPtr<V8CustomVoidCallback> successCallback;
78
    RefPtr<V8CustomVoidCallback> successCallback;
Lines 101-114 static v8::Handle<v8::Value> createTrans WebCore/bindings/v8/custom/V8DatabaseCustom.cpp_sec3
101
    ScriptExecutionContext* scriptExecutionContext = getScriptExecutionContext();
101
    ScriptExecutionContext* scriptExecutionContext = getScriptExecutionContext();
102
    if (!scriptExecutionContext)
102
    if (!scriptExecutionContext)
103
        return v8::Undefined();
103
        return v8::Undefined();
104
    RefPtr<V8SQLTransactionCallback> callback = V8SQLTransactionCallback::create(args[0]);
104
    RefPtr<V8SQLTransactionCallback> callback = V8SQLTransactionCallback::create(args[0], scriptExecutionContext);
105
105
106
    RefPtr<V8SQLTransactionErrorCallback> errorCallback;
106
    RefPtr<V8SQLTransactionErrorCallback> errorCallback;
107
    if (args.Length() > 1 && !isUndefinedOrNull(args[1])) {
107
    if (args.Length() > 1 && !isUndefinedOrNull(args[1])) {
108
        if (!args[1]->IsObject())
108
        if (!args[1]->IsObject())
109
            return throwError(TYPE_MISMATCH_ERR);
109
            return throwError(TYPE_MISMATCH_ERR);
110
110
111
        errorCallback = V8SQLTransactionErrorCallback::create(args[1]);
111
        errorCallback = V8SQLTransactionErrorCallback::create(args[1], scriptExecutionContext);
112
    }
112
    }
113
113
114
    RefPtr<V8CustomVoidCallback> successCallback;
114
    RefPtr<V8CustomVoidCallback> successCallback;
- WebCore/bindings/v8/custom/V8DatabaseSyncCustom.cpp -2 / +4 lines
Lines 53-64 v8::Handle<v8::Value> V8DatabaseSync::ch WebCore/bindings/v8/custom/V8DatabaseSyncCustom.cpp_sec1
53
53
54
    DatabaseSync* database = V8DatabaseSync::toNative(args.Holder());
54
    DatabaseSync* database = V8DatabaseSync::toNative(args.Holder());
55
55
56
    ScriptExecutionContext* scriptExecutionContext = getScriptExecutionContext();
56
    RefPtr<V8SQLTransactionSyncCallback> callback;
57
    RefPtr<V8SQLTransactionSyncCallback> callback;
57
    if (args.Length() > 2) {
58
    if (args.Length() > 2) {
58
        if (!args[2]->IsObject())
59
        if (!args[2]->IsObject())
59
            return throwError(TYPE_MISMATCH_ERR);
60
            return throwError(TYPE_MISMATCH_ERR);
60
61
61
        callback = V8SQLTransactionSyncCallback::create(args[2]);
62
        callback = V8SQLTransactionSyncCallback::create(args[2], scriptExecutionContext);
62
    }
63
    }
63
64
64
    ExceptionCode ec = 0;
65
    ExceptionCode ec = 0;
Lines 78-84 static v8::Handle<v8::Value> createTrans WebCore/bindings/v8/custom/V8DatabaseSyncCustom.cpp_sec2
78
79
79
    DatabaseSync* database = V8DatabaseSync::toNative(args.Holder());
80
    DatabaseSync* database = V8DatabaseSync::toNative(args.Holder());
80
81
81
    RefPtr<V8SQLTransactionSyncCallback> callback = V8SQLTransactionSyncCallback::create(args[0]);
82
    ScriptExecutionContext* scriptExecutionContext = getScriptExecutionContext();
83
    RefPtr<V8SQLTransactionSyncCallback> callback = V8SQLTransactionSyncCallback::create(args[0], scriptExecutionContext);
82
84
83
    ExceptionCode ec = 0;
85
    ExceptionCode ec = 0;
84
    database->transaction(callback.release(), readOnly, ec);
86
    database->transaction(callback.release(), readOnly, ec);
- WebCore/bindings/v8/custom/V8SQLTransactionCustom.cpp -4 / +4 lines
Lines 89-110 v8::Handle<v8::Value> V8SQLTransaction:: WebCore/bindings/v8/custom/V8SQLTransactionCustom.cpp_sec1
89
89
90
    SQLTransaction* transaction = V8SQLTransaction::toNative(args.Holder());
90
    SQLTransaction* transaction = V8SQLTransaction::toNative(args.Holder());
91
91
92
    ScriptExecutionContext* executionContext = getScriptExecutionContext();
92
    ScriptExecutionContext* scriptExecutionContext = getScriptExecutionContext();
93
    if (!executionContext)
93
    if (!scriptExecutionContext)
94
        return v8::Undefined();
94
        return v8::Undefined();
95
95
96
    RefPtr<SQLStatementCallback> callback;
96
    RefPtr<SQLStatementCallback> callback;
97
    if (args.Length() > 2 && !isUndefinedOrNull(args[2])) {
97
    if (args.Length() > 2 && !isUndefinedOrNull(args[2])) {
98
        if (!args[2]->IsObject())
98
        if (!args[2]->IsObject())
99
            return throwError(TYPE_MISMATCH_ERR);
99
            return throwError(TYPE_MISMATCH_ERR);
100
        callback = V8SQLStatementCallback::create(args[2]);
100
        callback = V8SQLStatementCallback::create(args[2], scriptExecutionContext);
101
    }
101
    }
102
102
103
    RefPtr<SQLStatementErrorCallback> errorCallback;
103
    RefPtr<SQLStatementErrorCallback> errorCallback;
104
    if (args.Length() > 3 && !isUndefinedOrNull(args[3])) {
104
    if (args.Length() > 3 && !isUndefinedOrNull(args[3])) {
105
        if (!args[3]->IsObject())
105
        if (!args[3]->IsObject())
106
            return throwError(TYPE_MISMATCH_ERR);
106
            return throwError(TYPE_MISMATCH_ERR);
107
        errorCallback = V8SQLStatementErrorCallback::create(args[3]);
107
        errorCallback = V8SQLStatementErrorCallback::create(args[3], scriptExecutionContext);
108
    }
108
    }
109
109
110
    ExceptionCode ec = 0;
110
    ExceptionCode ec = 0;
- WebCore/bindings/v8/custom/V8WorkerContextCustom.cpp -2 / +4 lines
Lines 157-168 v8::Handle<v8::Value> V8WorkerContext::o WebCore/bindings/v8/custom/V8WorkerContextCustom.cpp_sec1
157
157
158
    WorkerContext* workerContext = V8WorkerContext::toNative(args.Holder());
158
    WorkerContext* workerContext = V8WorkerContext::toNative(args.Holder());
159
159
160
    ScriptExecutionContext* scriptExecutionContext = getScriptExecutionContext();
160
    RefPtr<DatabaseCallback> creationCallback;
161
    RefPtr<DatabaseCallback> creationCallback;
161
    if (args.Length() >= 5) {
162
    if (args.Length() >= 5) {
162
        if (!args[4]->IsObject())
163
        if (!args[4]->IsObject())
163
            return throwError(TYPE_MISMATCH_ERR);
164
            return throwError(TYPE_MISMATCH_ERR);
164
165
165
        creationCallback = V8DatabaseCallback::create(args[4]);
166
        creationCallback = V8DatabaseCallback::create(args[4], scriptExecutionContext);
166
    }
167
    }
167
168
168
    ExceptionCode ec = 0;
169
    ExceptionCode ec = 0;
Lines 185-196 v8::Handle<v8::Value> V8WorkerContext::o WebCore/bindings/v8/custom/V8WorkerContextCustom.cpp_sec2
185
186
186
    WorkerContext* workerContext = V8WorkerContext::toNative(args.Holder());
187
    WorkerContext* workerContext = V8WorkerContext::toNative(args.Holder());
187
188
189
    ScriptExecutionContext* scriptExecutionContext = getScriptExecutionContext();
188
    RefPtr<DatabaseCallback> creationCallback;
190
    RefPtr<DatabaseCallback> creationCallback;
189
    if (args.Length() >= 5) {
191
    if (args.Length() >= 5) {
190
        if (!args[4]->IsObject())
192
        if (!args[4]->IsObject())
191
            return throwError(TYPE_MISMATCH_ERR);
193
            return throwError(TYPE_MISMATCH_ERR);
192
194
193
        creationCallback = V8DatabaseCallback::create(args[4]);
195
        creationCallback = V8DatabaseCallback::create(args[4], scriptExecutionContext);
194
    }
196
    }
195
197
196
    ExceptionCode ec = 0;
198
    ExceptionCode ec = 0;
- WebCore/dom/ActiveDOMObject.cpp -10 / +2 lines
Lines 37-58 ActiveDOMObject::ActiveDOMObject(ScriptE WebCore/dom/ActiveDOMObject.cpp_sec1
37
    : m_scriptExecutionContext(scriptExecutionContext)
37
    : m_scriptExecutionContext(scriptExecutionContext)
38
    , m_pendingActivityCount(0)
38
    , m_pendingActivityCount(0)
39
{
39
{
40
#if ENABLE(WORKERS)
40
    ASSERT(m_scriptExecutionContext->isContextThread());
41
    ASSERT((m_scriptExecutionContext->isDocument() && isMainThread())
42
        || (m_scriptExecutionContext->isWorkerContext() && currentThread() == static_cast<WorkerContext*>(m_scriptExecutionContext)->thread()->threadID()));
43
#endif
44
45
    m_scriptExecutionContext->createdActiveDOMObject(this, upcastPointer);
41
    m_scriptExecutionContext->createdActiveDOMObject(this, upcastPointer);
46
}
42
}
47
43
48
ActiveDOMObject::~ActiveDOMObject()
44
ActiveDOMObject::~ActiveDOMObject()
49
{
45
{
50
    if (m_scriptExecutionContext) {
46
    if (m_scriptExecutionContext) {
51
#if ENABLE(WORKERS)
47
        ASSERT(m_scriptExecutionContext->isContextThread());
52
        ASSERT((m_scriptExecutionContext->isDocument() && isMainThread())
53
            || (m_scriptExecutionContext->isWorkerContext() && currentThread() == static_cast<WorkerContext*>(m_scriptExecutionContext)->thread()->threadID()));
54
#endif
55
56
        m_scriptExecutionContext->destroyedActiveDOMObject(this);
48
        m_scriptExecutionContext->destroyedActiveDOMObject(this);
57
    }
49
    }
58
}
50
}
- WebCore/storage/Database.cpp -1 / +1 lines
Lines 759-765 Vector<String> Database::performGetTable WebCore/storage/Database.cpp_sec1
759
759
760
void Database::performCreationCallback()
760
void Database::performCreationCallback()
761
{
761
{
762
    m_creationCallback->handleEvent(m_scriptExecutionContext.get(), this);
762
    m_creationCallback->handleEvent(this);
763
}
763
}
764
764
765
SQLTransactionClient* Database::transactionClient() const
765
SQLTransactionClient* Database::transactionClient() const
- WebCore/storage/DatabaseCallback.h -3 / +2 lines
Lines 39-51 namespace WebCore { WebCore/storage/DatabaseCallback.h_sec1
39
39
40
class Database;
40
class Database;
41
class DatabaseSync;
41
class DatabaseSync;
42
class ScriptExecutionContext;
43
42
44
class DatabaseCallback : public ThreadSafeShared<DatabaseCallback> {
43
class DatabaseCallback : public ThreadSafeShared<DatabaseCallback> {
45
public:
44
public:
46
    virtual ~DatabaseCallback() { }
45
    virtual ~DatabaseCallback() { }
47
    virtual bool handleEvent(ScriptExecutionContext*, Database*) = 0;
46
    virtual bool handleEvent(Database*) = 0;
48
    virtual bool handleEvent(ScriptExecutionContext*, DatabaseSync*) = 0;
47
    virtual bool handleEvent(DatabaseSync*) = 0;
49
};
48
};
50
49
51
}
50
}
- WebCore/storage/SQLStatement.cpp -2 / +2 lines
Lines 170-178 bool SQLStatement::performCallback(SQLTr WebCore/storage/SQLStatement.cpp_sec1
170
    // because then we need to jump to the transaction error callback.
170
    // because then we need to jump to the transaction error callback.
171
    if (m_error) {
171
    if (m_error) {
172
        ASSERT(m_statementErrorCallback);
172
        ASSERT(m_statementErrorCallback);
173
        callbackError = m_statementErrorCallback->handleEvent(transaction->database()->scriptExecutionContext(), transaction, m_error.get());
173
        callbackError = m_statementErrorCallback->handleEvent(transaction, m_error.get());
174
    } else if (m_statementCallback)
174
    } else if (m_statementCallback)
175
        callbackError = !m_statementCallback->handleEvent(transaction->database()->scriptExecutionContext(), transaction, m_resultSet.get());
175
        callbackError = !m_statementCallback->handleEvent(transaction, m_resultSet.get());
176
176
177
    // Now release our callbacks, to break reference cycles.
177
    // Now release our callbacks, to break reference cycles.
178
    m_statementCallback = 0;
178
    m_statementCallback = 0;
- WebCore/storage/SQLStatementCallback.h -2 / +1 lines
Lines 34-47 WebCore/storage/SQLStatementCallback.h_sec1
34
34
35
namespace WebCore {
35
namespace WebCore {
36
36
37
class ScriptExecutionContext;
38
class SQLTransaction;
37
class SQLTransaction;
39
class SQLResultSet;
38
class SQLResultSet;
40
39
41
class SQLStatementCallback : public ThreadSafeShared<SQLStatementCallback> {
40
class SQLStatementCallback : public ThreadSafeShared<SQLStatementCallback> {
42
public:
41
public:
43
    virtual ~SQLStatementCallback() { }
42
    virtual ~SQLStatementCallback() { }
44
    virtual bool handleEvent(ScriptExecutionContext*, SQLTransaction*, SQLResultSet*) = 0;
43
    virtual bool handleEvent(SQLTransaction*, SQLResultSet*) = 0;
45
};
44
};
46
45
47
}
46
}
- WebCore/storage/SQLStatementErrorCallback.h -2 / +1 lines
Lines 35-48 WebCore/storage/SQLStatementErrorCallback.h_sec1
35
35
36
namespace WebCore {
36
namespace WebCore {
37
37
38
class ScriptExecutionContext;
39
class SQLTransaction;
38
class SQLTransaction;
40
class SQLError;
39
class SQLError;
41
40
42
class SQLStatementErrorCallback : public ThreadSafeShared<SQLStatementErrorCallback> {
41
class SQLStatementErrorCallback : public ThreadSafeShared<SQLStatementErrorCallback> {
43
public:
42
public:
44
    virtual ~SQLStatementErrorCallback() { }
43
    virtual ~SQLStatementErrorCallback() { }
45
    virtual bool handleEvent(ScriptExecutionContext*, SQLTransaction*, SQLError*) = 0;
44
    virtual bool handleEvent(SQLTransaction*, SQLError*) = 0;
46
};
45
};
47
46
48
}
47
}
- WebCore/storage/SQLTransaction.cpp -2 / +2 lines
Lines 291-297 void SQLTransaction::deliverTransactionC WebCore/storage/SQLTransaction.cpp_sec1
291
291
292
    if (m_callback) {
292
    if (m_callback) {
293
        m_executeSqlAllowed = true;
293
        m_executeSqlAllowed = true;
294
        shouldDeliverErrorCallback = !m_callback->handleEvent(m_database->scriptExecutionContext(), this);
294
        shouldDeliverErrorCallback = !m_callback->handleEvent(this);
295
        m_executeSqlAllowed = false;
295
        m_executeSqlAllowed = false;
296
    } else
296
    } else
297
        shouldDeliverErrorCallback = true;
297
        shouldDeliverErrorCallback = true;
Lines 549-555 void SQLTransaction::deliverTransactionE WebCore/storage/SQLTransaction.cpp_sec2
549
    // Transaction Step 12 - If exists, invoke error callback with the last
549
    // Transaction Step 12 - If exists, invoke error callback with the last
550
    // error to have occurred in this transaction.
550
    // error to have occurred in this transaction.
551
    if (m_errorCallback)
551
    if (m_errorCallback)
552
        m_errorCallback->handleEvent(m_database->scriptExecutionContext(), m_transactionError.get());
552
        m_errorCallback->handleEvent(m_transactionError.get());
553
553
554
    m_nextStep = &SQLTransaction::cleanupAfterTransactionErrorCallback;
554
    m_nextStep = &SQLTransaction::cleanupAfterTransactionErrorCallback;
555
    LOG(StorageAPI, "Scheduling cleanupAfterTransactionErrorCallback for transaction %p\n", this);
555
    LOG(StorageAPI, "Scheduling cleanupAfterTransactionErrorCallback for transaction %p\n", this);
- WebCore/storage/SQLTransactionCallback.h -2 / +1 lines
Lines 35-47 WebCore/storage/SQLTransactionCallback.h_sec1
35
35
36
namespace WebCore {
36
namespace WebCore {
37
37
38
class ScriptExecutionContext;
39
class SQLTransaction;
38
class SQLTransaction;
40
39
41
class SQLTransactionCallback : public ThreadSafeShared<SQLTransactionCallback> {
40
class SQLTransactionCallback : public ThreadSafeShared<SQLTransactionCallback> {
42
public:
41
public:
43
    virtual ~SQLTransactionCallback() { }
42
    virtual ~SQLTransactionCallback() { }
44
    virtual bool handleEvent(ScriptExecutionContext*, SQLTransaction*) = 0;
43
    virtual bool handleEvent(SQLTransaction*) = 0;
45
};
44
};
46
45
47
}
46
}
- WebCore/storage/SQLTransactionErrorCallback.h -2 / +1 lines
Lines 35-47 WebCore/storage/SQLTransactionErrorCallback.h_sec1
35
35
36
namespace WebCore {
36
namespace WebCore {
37
37
38
class ScriptExecutionContext;
39
class SQLError;
38
class SQLError;
40
39
41
class SQLTransactionErrorCallback : public ThreadSafeShared<SQLTransactionErrorCallback> {
40
class SQLTransactionErrorCallback : public ThreadSafeShared<SQLTransactionErrorCallback> {
42
public:
41
public:
43
    virtual ~SQLTransactionErrorCallback() { }
42
    virtual ~SQLTransactionErrorCallback() { }
44
    virtual bool handleEvent(ScriptExecutionContext*, SQLError*) = 0;
43
    virtual bool handleEvent(SQLError*) = 0;
45
};
44
};
46
45
47
}
46
}
- WebCore/storage/SQLTransactionSyncCallback.h -3 / +1 lines
Lines 32-49 WebCore/storage/SQLTransactionSyncCallback.h_sec1
32
#if ENABLE(DATABASE)
32
#if ENABLE(DATABASE)
33
33
34
#include <wtf/RefCounted.h>
34
#include <wtf/RefCounted.h>
35
#include <wtf/Threading.h>
36
35
37
namespace WebCore {
36
namespace WebCore {
38
37
39
class ScriptExecutionContext;
40
class SQLTransactionSync;
38
class SQLTransactionSync;
41
39
42
// Instances of this class should be created and used only on the worker's context thread.
40
// Instances of this class should be created and used only on the worker's context thread.
43
class SQLTransactionSyncCallback : public RefCounted<SQLTransactionSyncCallback> {
41
class SQLTransactionSyncCallback : public RefCounted<SQLTransactionSyncCallback> {
44
public:
42
public:
45
    virtual ~SQLTransactionSyncCallback() { }
43
    virtual ~SQLTransactionSyncCallback() { }
46
    virtual bool handleEvent(ScriptExecutionContext*, SQLTransactionSync*) = 0;
44
    virtual bool handleEvent(SQLTransactionSync*) = 0;
47
};
45
};
48
46
49
}
47
}
- LayoutTests/ChangeLog +18 lines
Lines 1-3 LayoutTests/ChangeLog_sec1
1
2010-06-21  Dumitru Daniliuc  <dumi@chromium.org>
2
3
        Reviewed by NOBODY (OOPS!).
4
5
        Make sure DB callbacks are executed in the context they're created.
6
        https://bugs.webkit.org/show_bug.cgi?id=40112
7
8
        * storage/callbacks-are-called-in-correct-context-expected.txt: Added.
9
        * storage/callbacks-are-called-in-correct-context.html: Added.
10
        * storage/resources/callbacks-are-called-in-correct-context-helper-frame.html: Added.
11
        * storage/resources/callbacks-are-called-in-correct-context-test-frame.html: Added.
12
        * storage/resources/common-output-frame.html: Added.
13
        * storage/resources/database-common.js:
14
        (log):
15
        (logToOutputFrame):
16
        (setupAndRunTest):
17
        (setupAndRunFramesTest):
18
1
2010-06-21  Dumitru Daniliuc  <dumi@chromium.org>
19
2010-06-21  Dumitru Daniliuc  <dumi@chromium.org>
2
20
3
        Unreviewed, fixing expectations.
21
        Unreviewed, fixing expectations.
- LayoutTests/storage/callbacks-are-called-in-correct-context-expected.txt +27 lines
Line 0 LayoutTests/storage/callbacks-are-called-in-correct-context-expected.txt_sec1
1
2
3
--------
4
Frame: 'outputFrame'
5
--------
6
This test tests that all DB callbacks are called in the context they were created, rather than the context where the DB handle was created.
7
PASS: The transaction callback was called in the correct context.
8
PASS: The statement success callback was called in the correct context.
9
PASS: The statement error callback was called in the correct context.
10
PASS: The transaction error callback was called in the correct context.
11
PASS: The transaction success callback was called in the correct context.
12
PASS: The transaction callback was called in the correct context.
13
PASS: The statement success callback was called in the correct context.
14
PASS: The statement error callback was called in the correct context.
15
PASS: The transaction error callback was called in the correct context.
16
PASS: The transaction success callback was called in the correct context.
17
18
19
--------
20
Frame: 'testFrame'
21
--------
22
23
24
--------
25
Frame: 'helperFrame'
26
--------
27
- LayoutTests/storage/callbacks-are-called-in-correct-context.html +10 lines
Line 0 LayoutTests/storage/callbacks-are-called-in-correct-context.html_sec1
1
<html>
2
<head>
3
<script src="resources/database-common.js"></script>
4
</head>
5
<frameset onload="setupAndRunFramesTest()">
6
<frame name="outputFrame" src="resources/common-output-frame.html">
7
<frame name="testFrame" src="resources/callbacks-are-called-in-correct-context-test-frame.html">
8
<frame name="helperFrame" src="resources/callbacks-are-called-in-correct-context-helper-frame.html">
9
</frameset>
10
</html>
- LayoutTests/storage/resources/callbacks-are-called-in-correct-context-helper-frame.html +58 lines
Line 0 LayoutTests/storage/resources/callbacks-are-called-in-correct-context-helper-frame.html_sec1
1
<html>
2
<head>
3
<script src="database-common.js"></script>
4
<script>
5
var done = false;
6
7
function logCallback(callbackType)
8
{
9
    logToOutputFrame("PASS: The " + callbackType + " callback was called in the correct context.");
10
}
11
12
function failingTransactionCallback(tx)
13
{
14
    logCallback("transaction");
15
    tx.executeSql("CREATE TABLE IF NOT EXISTS Test (Foo INT)", [], successStatementCallback, null);
16
    tx.executeSql("BAD SQL STATEMENT", [], null, errorStatementCallback);
17
}
18
19
function errorStatementCallback(tx, error)
20
{
21
    logCallback("statement error");
22
    return true; // fail the transaction
23
}
24
25
function successStatementCallback(tx, data)
26
{
27
    logCallback("statement success");
28
}
29
30
function errorTransactionCallback(error)
31
{
32
    logCallback("transaction error");
33
}
34
35
function successTransactionCallback()
36
{
37
    logCallback("transaction success");
38
    if (!done)
39
        testStartTransactionsInThisContext();
40
    else {
41
        if (window.layoutTestController)
42
            layoutTestController.notifyDone();
43
    }
44
}
45
46
function testStartTransactionsInThisContext()
47
{
48
    done = true;
49
50
    // test that all callbacks are executed in this context, even though 'db' is defined in another context
51
    top.frames[1].db.transaction(failingTransactionCallback, errorTransactionCallback);
52
    top.frames[1].db.transaction(function(tx) { }, null, successTransactionCallback);
53
}
54
</script>
55
</head>
56
<body>
57
</body>
58
</html>
- LayoutTests/storage/resources/callbacks-are-called-in-correct-context-test-frame.html +22 lines
Line 0 LayoutTests/storage/resources/callbacks-are-called-in-correct-context-test-frame.html_sec1
1
<html>
2
<head>
3
<script src="database-common.js"></script>
4
<script>
5
var db = openDatabaseWithSuffix("CallbacksAreCalledInCorrectContextTest", "1.0", "", 1);
6
7
function logCallback(callbackType)
8
{
9
    logToOutputFrame("FAIL: The " + callbackType + " callback was called in the wrong context.");
10
}
11
12
function runTest()
13
{
14
    // test that transaction callbacks defined in another frame are executed in the context of that frame
15
    db.transaction(top.frames[2].failingTransactionCallback, top.frames[2].errorTransactionCallback);
16
    db.transaction(function(tx) { }, null, top.frames[2].successTransactionCallback);
17
}
18
</script>
19
</head>
20
<body>
21
</body>
22
</html>
- LayoutTests/storage/resources/common-output-frame.html +10 lines
Line 0 LayoutTests/storage/resources/common-output-frame.html_sec1
1
<html>
2
<head>
3
</head>
4
<body>
5
This test tests that all DB callbacks are called in the context they were created, rather than the context where the DB handle was created.
6
<pre id="console">
7
FAILURE: test didn't run.
8
</pre>
9
</body>
10
</html>
- LayoutTests/storage/resources/database-common.js -2 / +18 lines
Lines 11-17 function openDatabaseWithSuffix(name, ve LayoutTests/storage/resources/database-common.js_sec1
11
11
12
function log(message)
12
function log(message)
13
{
13
{
14
    document.getElementById("console").innerText += message + "\n";
14
    window.document.getElementById("console").innerText += message + "\n";
15
}
16
17
function logToOutputFrame(message)
18
{
19
    top.frames[0].document.getElementById("console").innerText += message + "\n";
15
}
20
}
16
21
17
function setLocationHash(hash) {
22
function setLocationHash(hash) {
Lines 24-29 function setupAndRunTest() LayoutTests/storage/resources/database-common.js_sec2
24
        layoutTestController.dumpAsText();
29
        layoutTestController.dumpAsText();
25
        layoutTestController.waitUntilDone();
30
        layoutTestController.waitUntilDone();
26
    }
31
    }
27
    document.getElementById("console").innerText = "";
32
    window.document.getElementById("console").innerText = "";
28
    runTest();
33
    runTest();
29
}
34
}
35
36
function setupAndRunFramesTest()
37
{
38
    if (window.layoutTestController) {
39
        layoutTestController.dumpAsText();
40
        layoutTestController.dumpChildFramesAsText();
41
        layoutTestController.waitUntilDone();
42
    }
43
    top.frames[0].document.getElementById("console").innerText = "";
44
    top.frames[1].runTest();
45
}

Return to Bug 40112