[WK2] IPC callback classes should not be tightly coupled to C API
authorap@apple.com <ap@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 20 Feb 2014 03:21:41 +0000 (03:21 +0000)
committerap@apple.com <ap@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 20 Feb 2014 03:21:41 +0000 (03:21 +0000)
https://bugs.webkit.org/show_bug.cgi?id=129030

Reviewed by Anders Carlsson.

Changed CallbackBase subclasses to take an std::function (with context captured inside).
Instead of C API objects, these callback functions take implementation ones.
There are VoidAPICallback and GenericAPICallback helpers for the common case of C API.

* Shared/SecurityOriginData.h:
* UIProcess/API/C/WKApplicationCacheManager.cpp:
(WKApplicationCacheManagerGetApplicationCacheOrigins):
* UIProcess/API/C/WKContext.cpp:
(WKContextGetStatistics):
(WKContextGetStatisticsWithOptions):
* UIProcess/API/C/WKCookieManager.cpp:
(WKCookieManagerGetHostnamesWithCookies):
(WKCookieManagerGetHTTPCookieAcceptPolicy):
* UIProcess/API/C/WKDatabaseManager.cpp:
(WKDatabaseManagerGetDatabasesByOrigin):
(WKDatabaseManagerGetDatabaseOrigins):
* UIProcess/API/C/WKFrame.cpp:
(WKFrameGetMainResourceData):
(WKFrameGetResourceData):
(WKFrameGetWebArchive):
* UIProcess/API/C/WKKeyValueStorageManager.cpp:
(WKKeyValueStorageManagerGetKeyValueStorageOrigins):
(WKKeyValueStorageManagerGetStorageDetailsByOrigin):
* UIProcess/API/C/WKMediaCacheManager.cpp:
(WKMediaCacheManagerGetHostnamesWithMediaCache):
* UIProcess/API/C/WKOriginDataManager.cpp:
(WKOriginDataManagerGetOrigins):
* UIProcess/API/C/WKPage.cpp:
(WKPageRunJavaScriptInMainFrame):
(WKPageRenderTreeExternalRepresentation):
(WKPageGetSourceForFrame):
(WKPageGetContentsAsString):
(WKPageGetSelectionAsWebArchiveData):
(WKPageGetContentsAsMHTMLData):
(WKPageForceRepaint):
(WKPageValidateCommand):
(WKPageComputePagesForPrinting):
(WKPageDrawPagesToPDF):
* UIProcess/API/C/WKPluginSiteDataManager.cpp:
(WKPluginSiteDataManagerGetSitesWithData):
(WKPluginSiteDataManagerClearSiteData):
(WKPluginSiteDataManagerClearAllSiteData):
* UIProcess/API/C/WKResourceCacheManager.cpp:
(WKResourceCacheManagerGetCacheOrigins):
* UIProcess/API/gtk/WebKitCookieManager.cpp:
(webkit_cookie_manager_get_accept_policy):
(webkit_cookie_manager_get_domains_with_cookies):
* UIProcess/API/gtk/WebKitPrintOperation.cpp:
(drawPagesForPrintingCompleted):
(webkitPrintOperationPrintPagesForFrame):
* UIProcess/API/gtk/WebKitWebResource.cpp:
(resourceDataCallback):
(webkit_web_resource_get_data):
* UIProcess/API/gtk/WebKitWebView.cpp:
(webkit_web_view_can_execute_editing_command):
(webkitWebViewRunJavaScriptCallback):
(webkit_web_view_run_javascript):
(resourcesStreamReadCallback):
(getContentsAsMHTMLDataCallback):
(webkit_web_view_save):
(webkit_web_view_save_to_file):
* UIProcess/API/ios/WKInteractionView.mm:
(-[WKInteractionView _define:]):
(selectionChangedWithGesture):
(selectionChangedWithTouch):
(-[WKInteractionView changeSelectionWithGestureAt:withGesture:withState:]):
(-[WKInteractionView changeSelectionWithTouchAt:withSelectionTouch:baseIsStart:]):
(-[WKInteractionView changeSelectionWithTouchesFrom:to:withGesture:withState:]):
(-[WKInteractionView requestAutocorrectionRectsForString:withCompletionHandler:]):
(-[WKInteractionView applyAutocorrection:toString:withCompletionHandler:]):
(-[WKInteractionView requestAutocorrectionContextWithCompletionHandler:]):
* UIProcess/API/mac/WKPrintingView.mm:
(pageDidDrawToImage):
(-[WKPrintingView _preparePDFDataForPrintingOnSecondaryThread]):
(pageDidComputePageRects):
(-[WKPrintingView _askPageToComputePageRects]):
(-[WKPrintingView _drawPreview:]):
* UIProcess/API/mac/WKView.mm:
(-[WKView validateUserInterfaceItem:]):
(-[WKView startSpeaking:]):
* UIProcess/AutoCorrectionCallback.h:
(WebKit::AutocorrectionDataCallback::create):
(WebKit::AutocorrectionDataCallback::performCallbackWithReturnValue):
(WebKit::AutocorrectionDataCallback::invalidate):
(WebKit::AutocorrectionDataCallback::AutocorrectionDataCallback):
(WebKit::AutocorrectionContextCallback::create):
(WebKit::AutocorrectionContextCallback::performCallbackWithReturnValue):
(WebKit::AutocorrectionContextCallback::invalidate):
(WebKit::AutocorrectionContextCallback::AutocorrectionContextCallback):
* UIProcess/GenericCallback.h:
(WebKit::CallbackBase::CallbackBase):
(WebKit::CallbackBase::generateCallbackID):
(WebKit::VoidCallback::create):
(WebKit::VoidCallback::performCallback):
(WebKit::VoidCallback::invalidate):
(WebKit::VoidCallback::VoidCallback):
(WebKit::VoidAPICallback::create):
(WebKit::GenericCallback::create):
(WebKit::GenericCallback::performCallbackWithReturnValue):
(WebKit::GenericCallback::invalidate):
(WebKit::GenericCallback::GenericCallback):
(WebKit::GenericAPICallback::create):
(WebKit::ComputedPagesCallback::create):
(WebKit::ComputedPagesCallback::performCallbackWithReturnValue):
(WebKit::ComputedPagesCallback::invalidate):
(WebKit::ComputedPagesCallback::ComputedPagesCallback):
(WebKit::ImageCallback::create):
(WebKit::ImageCallback::performCallbackWithReturnValue):
(WebKit::ImageCallback::invalidate):
(WebKit::ImageCallback::ImageCallback):
* UIProcess/Plugins/WebPluginSiteDataManager.h:
* UIProcess/StatisticsRequest.h:
* UIProcess/WebApplicationCacheManagerProxy.h:
* UIProcess/WebContext.h:
* UIProcess/WebCookieManagerProxy.h:
* UIProcess/WebDatabaseManagerProxy.h:
* UIProcess/WebFrameProxy.h:
* UIProcess/WebKeyValueStorageManager.h:
* UIProcess/WebMediaCacheManagerProxy.h:
* UIProcess/WebOriginDataManagerProxy.h:
* UIProcess/WebPageProxy.h:
(WebKit::ValidateCommandCallback::create):
(WebKit::ValidateCommandCallback::performCallbackWithReturnValue):
(WebKit::ValidateCommandCallback::invalidate):
(WebKit::ValidateCommandCallback::ValidateCommandCallback):
(WebKit::GestureCallback::create):
(WebKit::GestureCallback::performCallbackWithReturnValue):
(WebKit::GestureCallback::invalidate):
(WebKit::GestureCallback::GestureCallback):
(WebKit::TouchesCallback::create):
(WebKit::TouchesCallback::performCallbackWithReturnValue):
(WebKit::TouchesCallback::invalidate):
(WebKit::TouchesCallback::TouchesCallback):
* UIProcess/WebResourceCacheManagerProxy.h:
* UIProcess/mac/WKFullScreenWindowController.mm:
(-[WKFullScreenWindowController finishedExitFullScreenAnimation:]):

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

35 files changed:
Source/WebKit2/ChangeLog
Source/WebKit2/Shared/SecurityOriginData.h
Source/WebKit2/UIProcess/API/C/WKApplicationCacheManager.cpp
Source/WebKit2/UIProcess/API/C/WKContext.cpp
Source/WebKit2/UIProcess/API/C/WKCookieManager.cpp
Source/WebKit2/UIProcess/API/C/WKDatabaseManager.cpp
Source/WebKit2/UIProcess/API/C/WKFrame.cpp
Source/WebKit2/UIProcess/API/C/WKKeyValueStorageManager.cpp
Source/WebKit2/UIProcess/API/C/WKMediaCacheManager.cpp
Source/WebKit2/UIProcess/API/C/WKOriginDataManager.cpp
Source/WebKit2/UIProcess/API/C/WKPage.cpp
Source/WebKit2/UIProcess/API/C/WKPluginSiteDataManager.cpp
Source/WebKit2/UIProcess/API/C/WKResourceCacheManager.cpp
Source/WebKit2/UIProcess/API/gtk/WebKitCookieManager.cpp
Source/WebKit2/UIProcess/API/gtk/WebKitPrintOperation.cpp
Source/WebKit2/UIProcess/API/gtk/WebKitWebResource.cpp
Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp
Source/WebKit2/UIProcess/API/ios/WKInteractionView.mm
Source/WebKit2/UIProcess/API/mac/WKPrintingView.mm
Source/WebKit2/UIProcess/API/mac/WKView.mm
Source/WebKit2/UIProcess/AutoCorrectionCallback.h
Source/WebKit2/UIProcess/GenericCallback.h
Source/WebKit2/UIProcess/Plugins/WebPluginSiteDataManager.h
Source/WebKit2/UIProcess/StatisticsRequest.h
Source/WebKit2/UIProcess/WebApplicationCacheManagerProxy.h
Source/WebKit2/UIProcess/WebContext.h
Source/WebKit2/UIProcess/WebCookieManagerProxy.h
Source/WebKit2/UIProcess/WebDatabaseManagerProxy.h
Source/WebKit2/UIProcess/WebFrameProxy.h
Source/WebKit2/UIProcess/WebKeyValueStorageManager.h
Source/WebKit2/UIProcess/WebMediaCacheManagerProxy.h
Source/WebKit2/UIProcess/WebOriginDataManagerProxy.h
Source/WebKit2/UIProcess/WebPageProxy.h
Source/WebKit2/UIProcess/WebResourceCacheManagerProxy.h
Source/WebKit2/UIProcess/mac/WKFullScreenWindowController.mm

index b1e4520..c4dd52a 100644 (file)
@@ -1,3 +1,147 @@
+2014-02-18  Alexey Proskuryakov  <ap@apple.com>
+
+        [WK2] IPC callback classes should not be tightly coupled to C API
+        https://bugs.webkit.org/show_bug.cgi?id=129030
+
+        Reviewed by Anders Carlsson.
+
+        Changed CallbackBase subclasses to take an std::function (with context captured inside).
+        Instead of C API objects, these callback functions take implementation ones.
+        There are VoidAPICallback and GenericAPICallback helpers for the common case of C API.
+
+        * Shared/SecurityOriginData.h:
+        * UIProcess/API/C/WKApplicationCacheManager.cpp:
+        (WKApplicationCacheManagerGetApplicationCacheOrigins):
+        * UIProcess/API/C/WKContext.cpp:
+        (WKContextGetStatistics):
+        (WKContextGetStatisticsWithOptions):
+        * UIProcess/API/C/WKCookieManager.cpp:
+        (WKCookieManagerGetHostnamesWithCookies):
+        (WKCookieManagerGetHTTPCookieAcceptPolicy):
+        * UIProcess/API/C/WKDatabaseManager.cpp:
+        (WKDatabaseManagerGetDatabasesByOrigin):
+        (WKDatabaseManagerGetDatabaseOrigins):
+        * UIProcess/API/C/WKFrame.cpp:
+        (WKFrameGetMainResourceData):
+        (WKFrameGetResourceData):
+        (WKFrameGetWebArchive):
+        * UIProcess/API/C/WKKeyValueStorageManager.cpp:
+        (WKKeyValueStorageManagerGetKeyValueStorageOrigins):
+        (WKKeyValueStorageManagerGetStorageDetailsByOrigin):
+        * UIProcess/API/C/WKMediaCacheManager.cpp:
+        (WKMediaCacheManagerGetHostnamesWithMediaCache):
+        * UIProcess/API/C/WKOriginDataManager.cpp:
+        (WKOriginDataManagerGetOrigins):
+        * UIProcess/API/C/WKPage.cpp:
+        (WKPageRunJavaScriptInMainFrame):
+        (WKPageRenderTreeExternalRepresentation):
+        (WKPageGetSourceForFrame):
+        (WKPageGetContentsAsString):
+        (WKPageGetSelectionAsWebArchiveData):
+        (WKPageGetContentsAsMHTMLData):
+        (WKPageForceRepaint):
+        (WKPageValidateCommand):
+        (WKPageComputePagesForPrinting):
+        (WKPageDrawPagesToPDF):
+        * UIProcess/API/C/WKPluginSiteDataManager.cpp:
+        (WKPluginSiteDataManagerGetSitesWithData):
+        (WKPluginSiteDataManagerClearSiteData):
+        (WKPluginSiteDataManagerClearAllSiteData):
+        * UIProcess/API/C/WKResourceCacheManager.cpp:
+        (WKResourceCacheManagerGetCacheOrigins):
+        * UIProcess/API/gtk/WebKitCookieManager.cpp:
+        (webkit_cookie_manager_get_accept_policy):
+        (webkit_cookie_manager_get_domains_with_cookies):
+        * UIProcess/API/gtk/WebKitPrintOperation.cpp:
+        (drawPagesForPrintingCompleted):
+        (webkitPrintOperationPrintPagesForFrame):
+        * UIProcess/API/gtk/WebKitWebResource.cpp:
+        (resourceDataCallback):
+        (webkit_web_resource_get_data):
+        * UIProcess/API/gtk/WebKitWebView.cpp:
+        (webkit_web_view_can_execute_editing_command):
+        (webkitWebViewRunJavaScriptCallback):
+        (webkit_web_view_run_javascript):
+        (resourcesStreamReadCallback):
+        (getContentsAsMHTMLDataCallback):
+        (webkit_web_view_save):
+        (webkit_web_view_save_to_file):
+        * UIProcess/API/ios/WKInteractionView.mm:
+        (-[WKInteractionView _define:]):
+        (selectionChangedWithGesture):
+        (selectionChangedWithTouch):
+        (-[WKInteractionView changeSelectionWithGestureAt:withGesture:withState:]):
+        (-[WKInteractionView changeSelectionWithTouchAt:withSelectionTouch:baseIsStart:]):
+        (-[WKInteractionView changeSelectionWithTouchesFrom:to:withGesture:withState:]):
+        (-[WKInteractionView requestAutocorrectionRectsForString:withCompletionHandler:]):
+        (-[WKInteractionView applyAutocorrection:toString:withCompletionHandler:]):
+        (-[WKInteractionView requestAutocorrectionContextWithCompletionHandler:]):
+        * UIProcess/API/mac/WKPrintingView.mm:
+        (pageDidDrawToImage):
+        (-[WKPrintingView _preparePDFDataForPrintingOnSecondaryThread]):
+        (pageDidComputePageRects):
+        (-[WKPrintingView _askPageToComputePageRects]):
+        (-[WKPrintingView _drawPreview:]):
+        * UIProcess/API/mac/WKView.mm:
+        (-[WKView validateUserInterfaceItem:]):
+        (-[WKView startSpeaking:]):
+        * UIProcess/AutoCorrectionCallback.h:
+        (WebKit::AutocorrectionDataCallback::create):
+        (WebKit::AutocorrectionDataCallback::performCallbackWithReturnValue):
+        (WebKit::AutocorrectionDataCallback::invalidate):
+        (WebKit::AutocorrectionDataCallback::AutocorrectionDataCallback):
+        (WebKit::AutocorrectionContextCallback::create):
+        (WebKit::AutocorrectionContextCallback::performCallbackWithReturnValue):
+        (WebKit::AutocorrectionContextCallback::invalidate):
+        (WebKit::AutocorrectionContextCallback::AutocorrectionContextCallback):
+        * UIProcess/GenericCallback.h:
+        (WebKit::CallbackBase::CallbackBase):
+        (WebKit::CallbackBase::generateCallbackID):
+        (WebKit::VoidCallback::create):
+        (WebKit::VoidCallback::performCallback):
+        (WebKit::VoidCallback::invalidate):
+        (WebKit::VoidCallback::VoidCallback):
+        (WebKit::VoidAPICallback::create):
+        (WebKit::GenericCallback::create):
+        (WebKit::GenericCallback::performCallbackWithReturnValue):
+        (WebKit::GenericCallback::invalidate):
+        (WebKit::GenericCallback::GenericCallback):
+        (WebKit::GenericAPICallback::create):
+        (WebKit::ComputedPagesCallback::create):
+        (WebKit::ComputedPagesCallback::performCallbackWithReturnValue):
+        (WebKit::ComputedPagesCallback::invalidate):
+        (WebKit::ComputedPagesCallback::ComputedPagesCallback):
+        (WebKit::ImageCallback::create):
+        (WebKit::ImageCallback::performCallbackWithReturnValue):
+        (WebKit::ImageCallback::invalidate):
+        (WebKit::ImageCallback::ImageCallback):
+        * UIProcess/Plugins/WebPluginSiteDataManager.h:
+        * UIProcess/StatisticsRequest.h:
+        * UIProcess/WebApplicationCacheManagerProxy.h:
+        * UIProcess/WebContext.h:
+        * UIProcess/WebCookieManagerProxy.h:
+        * UIProcess/WebDatabaseManagerProxy.h:
+        * UIProcess/WebFrameProxy.h:
+        * UIProcess/WebKeyValueStorageManager.h:
+        * UIProcess/WebMediaCacheManagerProxy.h:
+        * UIProcess/WebOriginDataManagerProxy.h:
+        * UIProcess/WebPageProxy.h:
+        (WebKit::ValidateCommandCallback::create):
+        (WebKit::ValidateCommandCallback::performCallbackWithReturnValue):
+        (WebKit::ValidateCommandCallback::invalidate):
+        (WebKit::ValidateCommandCallback::ValidateCommandCallback):
+        (WebKit::GestureCallback::create):
+        (WebKit::GestureCallback::performCallbackWithReturnValue):
+        (WebKit::GestureCallback::invalidate):
+        (WebKit::GestureCallback::GestureCallback):
+        (WebKit::TouchesCallback::create):
+        (WebKit::TouchesCallback::performCallbackWithReturnValue):
+        (WebKit::TouchesCallback::invalidate):
+        (WebKit::TouchesCallback::TouchesCallback):
+        * UIProcess/WebResourceCacheManagerProxy.h:
+        * UIProcess/mac/WKFullScreenWindowController.mm:
+        (-[WKFullScreenWindowController finishedExitFullScreenAnimation:]):
+
 2014-02-19  Simon Fraser  <simon.fraser@apple.com>
 
         Avoid sending redundant layer properties to the UI process, and avoid allocation of RemoteLayerBackingStore unless we need it
index 96404e5..aa40ca4 100644 (file)
@@ -37,7 +37,7 @@ namespace IPC {
 
 namespace WebKit {
 
-typedef GenericCallback<WKArrayRef> ArrayCallback;
+typedef GenericCallback<API::Array*> ArrayCallback;
 
 struct SecurityOriginData {
     static SecurityOriginData fromSecurityOrigin(const WebCore::SecurityOrigin*);
index 2d95c67..7f3c1d3 100644 (file)
@@ -31,6 +31,8 @@
 
 using namespace WebKit;
 
+typedef GenericAPICallback<WKArrayRef> ArrayAPICallback;
+
 WKTypeID WKApplicationCacheManagerGetTypeID()
 {
     return toAPI(WebApplicationCacheManagerProxy::APIType);
@@ -38,7 +40,7 @@ WKTypeID WKApplicationCacheManagerGetTypeID()
 
 void WKApplicationCacheManagerGetApplicationCacheOrigins(WKApplicationCacheManagerRef applicationCacheManagerRef, void* context, WKApplicationCacheManagerGetApplicationCacheOriginsFunction callback)
 {
-    toImpl(applicationCacheManagerRef)->getApplicationCacheOrigins(ArrayCallback::create(context, callback));
+    toImpl(applicationCacheManagerRef)->getApplicationCacheOrigins(ArrayAPICallback::create(context, callback));
 }
 
 void WKApplicationCacheManagerDeleteEntriesForOrigin(WKApplicationCacheManagerRef applicationCacheManagerRef, WKSecurityOriginRef originRef)
index 781f3e0..79ff6b7 100644 (file)
@@ -63,6 +63,8 @@ template<> struct ClientTraits<WKContextHistoryClientBase> {
 
 using namespace WebKit;
 
+typedef GenericAPICallback<WKDictionaryRef> DictionaryAPICallback;
+
 WKTypeID WKContextGetTypeID()
 {
     return toAPI(WebContext::APIType);
@@ -416,12 +418,12 @@ void WKContextWarmInitialProcess(WKContextRef contextRef)
 
 void WKContextGetStatistics(WKContextRef contextRef, void* context, WKContextGetStatisticsFunction callback)
 {
-    toImpl(contextRef)->getStatistics(0xFFFFFFFF, DictionaryCallback::create(context, callback));
+    toImpl(contextRef)->getStatistics(0xFFFFFFFF, DictionaryAPICallback::create(context, callback));
 }
 
 void WKContextGetStatisticsWithOptions(WKContextRef contextRef, WKStatisticsOptions optionsMask, void* context, WKContextGetStatisticsFunction callback)
 {
-    toImpl(contextRef)->getStatistics(optionsMask, DictionaryCallback::create(context, callback));
+    toImpl(contextRef)->getStatistics(optionsMask, DictionaryAPICallback::create(context, callback));
 }
 
 void WKContextGarbageCollectJavaScriptObjects(WKContextRef contextRef)
index 3757b00..5055033 100644 (file)
@@ -31,6 +31,9 @@
 
 using namespace WebKit;
 
+typedef GenericAPICallback<WKArrayRef> ArrayAPICallback;
+typedef GenericAPICallback<WKHTTPCookieAcceptPolicy, HTTPCookieAcceptPolicy> HTTPCookieAcceptPolicyAPICallback;
+
 WKTypeID WKCookieManagerGetTypeID()
 {
     return toAPI(WebCookieManagerProxy::APIType);
@@ -43,7 +46,7 @@ void WKCookieManagerSetClient(WKCookieManagerRef cookieManagerRef, const WKCooki
 
 void WKCookieManagerGetHostnamesWithCookies(WKCookieManagerRef cookieManagerRef, void* context, WKCookieManagerGetCookieHostnamesFunction callback)
 {
-    toImpl(cookieManagerRef)->getHostnamesWithCookies(ArrayCallback::create(context, callback));
+    toImpl(cookieManagerRef)->getHostnamesWithCookies(ArrayAPICallback::create(context, callback));
 }
 
 void WKCookieManagerDeleteCookiesForHostname(WKCookieManagerRef cookieManagerRef, WKStringRef hostname)
@@ -68,7 +71,7 @@ void WKCookieManagerSetHTTPCookieAcceptPolicy(WKCookieManagerRef cookieManager,
 
 void WKCookieManagerGetHTTPCookieAcceptPolicy(WKCookieManagerRef cookieManager, void* context, WKCookieManagerGetHTTPCookieAcceptPolicyFunction callback)
 {
-    toImpl(cookieManager)->getHTTPCookieAcceptPolicy(HTTPCookieAcceptPolicyCallback::create(context, callback));
+    toImpl(cookieManager)->getHTTPCookieAcceptPolicy(HTTPCookieAcceptPolicyAPICallback::create(context, callback));
 }
 
 void WKCookieManagerStartObservingCookieChanges(WKCookieManagerRef cookieManager)
index 5aa9dcf..ae70637 100644 (file)
@@ -31,6 +31,8 @@
 
 using namespace WebKit;
 
+typedef GenericAPICallback<WKArrayRef> ArrayAPICallback;
+
 WKTypeID WKDatabaseManagerGetTypeID()
 {
 #if ENABLE(SQL_DATABASE)
@@ -155,7 +157,7 @@ void WKDatabaseManagerSetClient(WKDatabaseManagerRef databaseManagerRef, const W
 void WKDatabaseManagerGetDatabasesByOrigin(WKDatabaseManagerRef databaseManagerRef, void* context, WKDatabaseManagerGetDatabasesByOriginFunction callback)
 {
 #if ENABLE(SQL_DATABASE)
-    toImpl(databaseManagerRef)->getDatabasesByOrigin(ArrayCallback::create(context, callback));
+    toImpl(databaseManagerRef)->getDatabasesByOrigin(ArrayAPICallback::create(context, callback));
 #else
     UNUSED_PARAM(databaseManagerRef);
     UNUSED_PARAM(context);
@@ -166,7 +168,7 @@ void WKDatabaseManagerGetDatabasesByOrigin(WKDatabaseManagerRef databaseManagerR
 void WKDatabaseManagerGetDatabaseOrigins(WKDatabaseManagerRef databaseManagerRef, void* context, WKDatabaseManagerGetDatabaseOriginsFunction callback)
 {
 #if ENABLE(SQL_DATABASE)
-    toImpl(databaseManagerRef)->getDatabaseOrigins(ArrayCallback::create(context, callback));
+    toImpl(databaseManagerRef)->getDatabaseOrigins(ArrayAPICallback::create(context, callback));
 #else
     UNUSED_PARAM(databaseManagerRef);
     UNUSED_PARAM(context);
index 2f74c6d..7a6eca8 100644 (file)
@@ -31,6 +31,8 @@
 
 using namespace WebKit;
 
+typedef GenericAPICallback<WKDataRef> DataAPICallback;
+
 WKTypeID WKFrameGetTypeID()
 {
     return toAPI(WebFrameProxy::APIType);
@@ -124,17 +126,17 @@ bool WKFrameIsFrameSet(WKFrameRef frameRef)
 
 void WKFrameGetMainResourceData(WKFrameRef frameRef, WKFrameGetResourceDataFunction callback, void* context)
 {
-    toImpl(frameRef)->getMainResourceData(DataCallback::create(context, callback));
+    toImpl(frameRef)->getMainResourceData(DataAPICallback::create(context, callback));
 }
 
 void WKFrameGetResourceData(WKFrameRef frameRef, WKURLRef resourceURL, WKFrameGetResourceDataFunction callback, void* context)
 {
-    toImpl(frameRef)->getResourceData(toImpl(resourceURL), DataCallback::create(context, callback));
+    toImpl(frameRef)->getResourceData(toImpl(resourceURL), DataAPICallback::create(context, callback));
 }
 
 void WKFrameGetWebArchive(WKFrameRef frameRef, WKFrameGetWebArchiveFunction callback, void* context)
 {
-    toImpl(frameRef)->getWebArchive(DataCallback::create(context, callback));
+    toImpl(frameRef)->getWebArchive(DataAPICallback::create(context, callback));
 }
 
 // NOTE: These are deprecated and should be removed. They currently do nothing.
index dd7cc55..09edcec 100644 (file)
@@ -31,6 +31,8 @@
 
 using namespace WebKit;
 
+typedef GenericAPICallback<WKArrayRef> ArrayAPICallback;
+
 WKTypeID WKKeyValueStorageManagerGetTypeID()
 {
     return toAPI(WebKeyValueStorageManager::APIType);
@@ -56,12 +58,12 @@ WKStringRef WKKeyValueStorageManagerGetModificationTimeKey()
 
 void WKKeyValueStorageManagerGetKeyValueStorageOrigins(WKKeyValueStorageManagerRef keyValueStorageManagerRef, void* context, WKKeyValueStorageManagerGetKeyValueStorageOriginsFunction callback)
 {
-    toImpl(keyValueStorageManagerRef)->getKeyValueStorageOrigins(ArrayCallback::create(context, callback));
+    toImpl(keyValueStorageManagerRef)->getKeyValueStorageOrigins(ArrayAPICallback::create(context, callback));
 }
 
 void WKKeyValueStorageManagerGetStorageDetailsByOrigin(WKKeyValueStorageManagerRef keyValueStorageManagerRef, void* context, WKKeyValueStorageManagerGetStorageDetailsByOriginFunction callback)
 {
-    toImpl(keyValueStorageManagerRef)->getStorageDetailsByOrigin(ArrayCallback::create(context, callback));
+    toImpl(keyValueStorageManagerRef)->getStorageDetailsByOrigin(ArrayAPICallback::create(context, callback));
 }
 
 void WKKeyValueStorageManagerDeleteEntriesForOrigin(WKKeyValueStorageManagerRef keyValueStorageManagerRef, WKSecurityOriginRef originRef)
index 6e2ecce..874ac18 100644 (file)
@@ -31,6 +31,8 @@
 
 using namespace WebKit;
 
+typedef GenericAPICallback<WKArrayRef> ArrayAPICallback;
+
 WKTypeID WKMediaCacheManagerGetTypeID()
 {
     return toAPI(WebMediaCacheManagerProxy::APIType);
@@ -38,7 +40,7 @@ WKTypeID WKMediaCacheManagerGetTypeID()
 
 void WKMediaCacheManagerGetHostnamesWithMediaCache(WKMediaCacheManagerRef mediaCacheManagerRef, void* context, WKMediaCacheManagerGetHostnamesWithMediaCacheFunction callback)
 {
-    toImpl(mediaCacheManagerRef)->getHostnamesWithMediaCache(ArrayCallback::create(context, callback));
+    toImpl(mediaCacheManagerRef)->getHostnamesWithMediaCache(ArrayAPICallback::create(context, callback));
 }
 
 void WKMediaCacheManagerClearCacheForHostname(WKMediaCacheManagerRef mediaCacheManagerRef, WKStringRef hostname)
index 8ab0f37..76c909b 100644 (file)
@@ -31,6 +31,8 @@
 
 using namespace WebKit;
 
+typedef GenericAPICallback<WKArrayRef> ArrayAPICallback;
+
 WKTypeID WKOriginDataManagerGetTypeID()
 {
     return toAPI(WebOriginDataManagerProxy::APIType);
@@ -38,7 +40,7 @@ WKTypeID WKOriginDataManagerGetTypeID()
 
 void WKOriginDataManagerGetOrigins(WKOriginDataManagerRef originDataManagerRef, WKOriginDataTypes types, void* context, WKOriginDataManagerGetOriginsFunction callback)
 {
-    toImpl(originDataManagerRef)->getOrigins(types, ArrayCallback::create(context, callback));
+    toImpl(originDataManagerRef)->getOrigins(types, ArrayAPICallback::create(context, callback));
 }
 
 void WKOriginDataManagerDeleteEntriesForOrigin(WKOriginDataManagerRef originDataManagerRef, WKOriginDataTypes types, WKSecurityOriginRef originRef)
index 2fbebc5..f98beb0 100644 (file)
@@ -74,6 +74,10 @@ template<> struct ClientTraits<WKPageUIClientBase> {
 
 }
 
+typedef GenericAPICallback<WKDataRef> DataAPICallback;
+typedef GenericAPICallback<WKStringRef, StringImpl*> StringAPICallback;
+typedef GenericAPICallback<WKSerializedScriptValueRef> ScriptValueAPICallback;
+
 WKTypeID WKPageGetTypeID()
 {
     return toAPI(WebPageProxy::APIType);
@@ -1472,7 +1476,7 @@ void WKPageSetSession(WKPageRef pageRef, WKSessionRef session)
 
 void WKPageRunJavaScriptInMainFrame(WKPageRef pageRef, WKStringRef scriptRef, void* context, WKPageRunJavaScriptFunction callback)
 {
-    toImpl(pageRef)->runJavaScriptInMainFrame(toImpl(scriptRef)->string(), ScriptValueCallback::create(context, callback));
+    toImpl(pageRef)->runJavaScriptInMainFrame(toImpl(scriptRef)->string(), ScriptValueAPICallback::create(context, callback));
 }
 
 #ifdef __BLOCKS__
@@ -1491,17 +1495,17 @@ void WKPageRunJavaScriptInMainFrame_b(WKPageRef pageRef, WKStringRef scriptRef,
 
 void WKPageRenderTreeExternalRepresentation(WKPageRef pageRef, void* context, WKPageRenderTreeExternalRepresentationFunction callback)
 {
-    toImpl(pageRef)->getRenderTreeExternalRepresentation(StringCallback::create(context, callback));
+    toImpl(pageRef)->getRenderTreeExternalRepresentation(StringAPICallback::create(context, callback));
 }
 
 void WKPageGetSourceForFrame(WKPageRef pageRef, WKFrameRef frameRef, void* context, WKPageGetSourceForFrameFunction callback)
 {
-    toImpl(pageRef)->getSourceForFrame(toImpl(frameRef), StringCallback::create(context, callback));
+    toImpl(pageRef)->getSourceForFrame(toImpl(frameRef), StringAPICallback::create(context, callback));
 }
 
 void WKPageGetContentsAsString(WKPageRef pageRef, void* context, WKPageGetContentsAsStringFunction callback)
 {
-    toImpl(pageRef)->getContentsAsString(StringCallback::create(context, callback));
+    toImpl(pageRef)->getContentsAsString(StringAPICallback::create(context, callback));
 }
 
 void WKPageGetBytecodeProfile(WKPageRef pageRef, void* context, WKPageGetBytecodeProfileFunction callback)
@@ -1511,13 +1515,13 @@ void WKPageGetBytecodeProfile(WKPageRef pageRef, void* context, WKPageGetBytecod
 
 void WKPageGetSelectionAsWebArchiveData(WKPageRef pageRef, void* context, WKPageGetSelectionAsWebArchiveDataFunction callback)
 {
-    toImpl(pageRef)->getSelectionAsWebArchiveData(DataCallback::create(context, callback));
+    toImpl(pageRef)->getSelectionAsWebArchiveData(DataAPICallback::create(context, callback));
 }
 
 void WKPageGetContentsAsMHTMLData(WKPageRef pageRef, bool useBinaryEncoding, void* context, WKPageGetContentsAsMHTMLDataFunction callback)
 {
 #if ENABLE(MHTML)
-    toImpl(pageRef)->getContentsAsMHTMLData(DataCallback::create(context, callback), useBinaryEncoding);
+    toImpl(pageRef)->getContentsAsMHTMLData(DataAPICallback::create(context, callback), useBinaryEncoding);
 #else
     UNUSED_PARAM(pageRef);
     UNUSED_PARAM(useBinaryEncoding);
@@ -1528,7 +1532,7 @@ void WKPageGetContentsAsMHTMLData(WKPageRef pageRef, bool useBinaryEncoding, voi
 
 void WKPageForceRepaint(WKPageRef pageRef, void* context, WKPageForceRepaintFunction callback)
 {
-    toImpl(pageRef)->forceRepaint(VoidCallback::create(context, callback));
+    toImpl(pageRef)->forceRepaint(VoidAPICallback::create(context, callback));
 }
 
 WK_EXPORT WKURLRef WKPageCopyPendingAPIRequestURL(WKPageRef pageRef)
@@ -1563,7 +1567,9 @@ WKStringRef WKPageCopyStandardUserAgentWithApplicationName(WKStringRef applicati
 
 void WKPageValidateCommand(WKPageRef pageRef, WKStringRef command, void* context, WKPageValidateCommandCallback callback)
 {
-    toImpl(pageRef)->validateCommand(toImpl(command)->string(), ValidateCommandCallback::create(context, callback)); 
+    toImpl(pageRef)->validateCommand(toImpl(command)->string(), ValidateCommandCallback::create([context, callback](bool error, StringImpl* commandName, bool isEnabled, int32_t state) {
+        callback(toAPI(commandName), isEnabled, state, error ? toAPI(API::Error::create().get()) : 0, context);
+    }));
 }
 
 void WKPageExecuteCommand(WKPageRef pageRef, WKStringRef command)
@@ -1572,25 +1578,6 @@ void WKPageExecuteCommand(WKPageRef pageRef, WKStringRef command)
 }
 
 #if PLATFORM(COCOA)
-struct ComputedPagesContext {
-    ComputedPagesContext(WKPageComputePagesForPrintingFunction callback, void* context)
-        : callback(callback)
-        , context(context)
-    {
-    }
-    WKPageComputePagesForPrintingFunction callback;
-    void* context;
-};
-
-static void computedPagesCallback(const Vector<WebCore::IntRect>& rects, double scaleFactor, WKErrorRef error, void* untypedContext)
-{
-    OwnPtr<ComputedPagesContext> context = adoptPtr(static_cast<ComputedPagesContext*>(untypedContext));
-    Vector<WKRect> wkRects(rects.size());
-    for (size_t i = 0; i < rects.size(); ++i)
-        wkRects[i] = toAPI(rects[i]);
-    context->callback(wkRects.data(), wkRects.size(), scaleFactor, error, context->context);
-}
-
 static PrintInfo printInfoFromWKPrintInfo(const WKPrintInfo& printInfo)
 {
     PrintInfo result;
@@ -1602,7 +1589,12 @@ static PrintInfo printInfoFromWKPrintInfo(const WKPrintInfo& printInfo)
 
 void WKPageComputePagesForPrinting(WKPageRef page, WKFrameRef frame, WKPrintInfo printInfo, WKPageComputePagesForPrintingFunction callback, void* context)
 {
-    toImpl(page)->computePagesForPrinting(toImpl(frame), printInfoFromWKPrintInfo(printInfo), ComputedPagesCallback::create(new ComputedPagesContext(callback, context), computedPagesCallback));
+    toImpl(page)->computePagesForPrinting(toImpl(frame), printInfoFromWKPrintInfo(printInfo), ComputedPagesCallback::create([context, callback](bool error, const Vector<WebCore::IntRect>& rects, double scaleFactor) {
+        Vector<WKRect> wkRects(rects.size());
+        for (size_t i = 0; i < rects.size(); ++i)
+            wkRects[i] = toAPI(rects[i]);
+        callback(wkRects.data(), wkRects.size(), scaleFactor, error ? toAPI(API::Error::create().get()) : 0, context);
+    }));
 }
 
 void WKPageBeginPrinting(WKPageRef page, WKFrameRef frame, WKPrintInfo printInfo)
@@ -1612,7 +1604,7 @@ void WKPageBeginPrinting(WKPageRef page, WKFrameRef frame, WKPrintInfo printInfo
 
 void WKPageDrawPagesToPDF(WKPageRef page, WKFrameRef frame, WKPrintInfo printInfo, uint32_t first, uint32_t count, WKPageDrawToPDFFunction callback, void* context)
 {
-    toImpl(page)->drawPagesToPDF(toImpl(frame), printInfoFromWKPrintInfo(printInfo), first, count, DataCallback::create(context, callback));
+    toImpl(page)->drawPagesToPDF(toImpl(frame), printInfoFromWKPrintInfo(printInfo), first, count, DataAPICallback::create(context, callback));
 }
 
 void WKPageEndPrinting(WKPageRef page)
index 5ae8abf..ecc8fe9 100644 (file)
 
 using namespace WebKit;
 
+#if ENABLE(NETSCAPE_PLUGIN_API)
+typedef GenericAPICallback<WKArrayRef> ArrayAPICallback;
+#endif
+
 WKTypeID WKPluginSiteDataManagerGetTypeID()
 {
 #if ENABLE(NETSCAPE_PLUGIN_API)
@@ -48,7 +52,7 @@ WKTypeID WKPluginSiteDataManagerGetTypeID()
 void WKPluginSiteDataManagerGetSitesWithData(WKPluginSiteDataManagerRef managerRef, void* context, WKPluginSiteDataManagerGetSitesWithDataFunction callback)
 {
 #if ENABLE(NETSCAPE_PLUGIN_API)
-    toImpl(managerRef)->getSitesWithData(ArrayCallback::create(context, callback));
+    toImpl(managerRef)->getSitesWithData(ArrayAPICallback::create(context, callback));
 #else
     UNUSED_PARAM(managerRef);
     UNUSED_PARAM(context);
@@ -72,7 +76,7 @@ static uint64_t toNPClearSiteDataFlags(WKClearSiteDataFlags flags)
 void WKPluginSiteDataManagerClearSiteData(WKPluginSiteDataManagerRef managerRef, WKArrayRef sitesRef, WKClearSiteDataFlags flags, uint64_t maxAgeInSeconds, void* context, WKPluginSiteDataManagerClearSiteDataFunction function)
 {
 #if ENABLE(NETSCAPE_PLUGIN_API)
-    toImpl(managerRef)->clearSiteData(toImpl(sitesRef), toNPClearSiteDataFlags(flags), maxAgeInSeconds, VoidCallback::create(context, function));
+    toImpl(managerRef)->clearSiteData(toImpl(sitesRef), toNPClearSiteDataFlags(flags), maxAgeInSeconds, VoidAPICallback::create(context, function));
 #else
     UNUSED_PARAM(managerRef);
     UNUSED_PARAM(sitesRef);
@@ -86,7 +90,7 @@ void WKPluginSiteDataManagerClearSiteData(WKPluginSiteDataManagerRef managerRef,
 void WKPluginSiteDataManagerClearAllSiteData(WKPluginSiteDataManagerRef managerRef, void* context, WKPluginSiteDataManagerClearSiteDataFunction function)
 {
 #if ENABLE(NETSCAPE_PLUGIN_API)
-    toImpl(managerRef)->clearSiteData(0, NP_CLEAR_ALL, std::numeric_limits<uint64_t>::max(), VoidCallback::create(context, function));
+    toImpl(managerRef)->clearSiteData(0, NP_CLEAR_ALL, std::numeric_limits<uint64_t>::max(), VoidAPICallback::create(context, function));
 #else
     UNUSED_PARAM(managerRef);
     UNUSED_PARAM(context);
index a5711e0..3990d7a 100644 (file)
@@ -31,6 +31,8 @@
 
 using namespace WebKit;
 
+typedef GenericAPICallback<WKArrayRef> ArrayAPICallback;
+
 WKTypeID WKResourceCacheManagerGetTypeID()
 {
     return toAPI(WebResourceCacheManagerProxy::APIType);
@@ -38,7 +40,7 @@ WKTypeID WKResourceCacheManagerGetTypeID()
 
 void WKResourceCacheManagerGetCacheOrigins(WKResourceCacheManagerRef cacheManagerRef, void* context, WKResourceCacheManagerGetCacheOriginsFunction callback)
 {
-    toImpl(cacheManagerRef)->getCacheOrigins(ArrayCallback::create(context, callback));
+    toImpl(cacheManagerRef)->getCacheOrigins(ArrayAPICallback::create(context, callback));
 }
 
 void WKResourceCacheManagerClearCacheForOrigin(WKResourceCacheManagerRef cacheManagerRef, WKSecurityOriginRef originRef, WKResourceCachesToClear cachesToClear)
index 2c1ef45..364e4e4 100644 (file)
@@ -30,6 +30,9 @@
 
 using namespace WebKit;
 
+typedef GenericAPICallback<WKArrayRef> ArrayAPICallback;
+typedef GenericAPICallback<WKHTTPCookieAcceptPolicy, HTTPCookieAcceptPolicy> HTTPCookieAcceptPolicyAPICallback;
+
 /**
  * SECTION: WebKitCookieManager
  * @Short_description: Defines how to handle cookies in a #WebKitWebContext
@@ -175,7 +178,7 @@ void webkit_cookie_manager_get_accept_policy(WebKitCookieManager* manager, GCanc
     g_return_if_fail(WEBKIT_IS_COOKIE_MANAGER(manager));
 
     GTask* task = g_task_new(manager, cancellable, callback, userData);
-    manager->priv->webCookieManager->getHTTPCookieAcceptPolicy(HTTPCookieAcceptPolicyCallback::create(task, webkitCookieManagerGetAcceptPolicyCallback));
+    manager->priv->webCookieManager->getHTTPCookieAcceptPolicy(HTTPCookieAcceptPolicyAPICallback::create(task, webkitCookieManagerGetAcceptPolicyCallback));
 }
 
 /**
@@ -233,7 +236,7 @@ void webkit_cookie_manager_get_domains_with_cookies(WebKitCookieManager* manager
     g_return_if_fail(WEBKIT_IS_COOKIE_MANAGER(manager));
 
     GTask* task = g_task_new(manager, cancellable, callback, userData);
-    manager->priv->webCookieManager->getHostnamesWithCookies(ArrayCallback::create(task, webkitCookieManagerGetDomainsWithCookiesCallback));
+    manager->priv->webCookieManager->getHostnamesWithCookies(ArrayAPICallback::create(task, webkitCookieManagerGetDomainsWithCookiesCallback));
 }
 
 /**
index ee97248..810d2c7 100644 (file)
@@ -252,30 +252,31 @@ static WebKitPrintOperationResponse webkitPrintOperationRunDialog(WebKitPrintOpe
 }
 #endif
 
-static void drawPagesForPrintingCompleted(WKErrorRef wkPrintError, WKErrorRef, void* context)
+static void drawPagesForPrintingCompleted(API::Error* wkPrintError, WebKitPrintOperation* printOperation)
 {
-    GRefPtr<WebKitPrintOperation> printOperation = adoptGRef(WEBKIT_PRINT_OPERATION(context));
-
     // When running synchronously WebPageProxy::printFrame() calls endPrinting().
     if (printOperation->priv->printMode == PrintInfo::PrintModeAsync && printOperation->priv->webView) {
         WebPageProxy* page = webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(printOperation->priv->webView));
         page->endPrinting();
     }
 
-    const WebCore::ResourceError& resourceError = wkPrintError ? toImpl(wkPrintError)->platformError() : WebCore::ResourceError();
+    const WebCore::ResourceError& resourceError = wkPrintError ? wkPrintError->platformError() : WebCore::ResourceError();
     if (!resourceError.isNull()) {
         GUniquePtr<GError> printError(g_error_new_literal(g_quark_from_string(resourceError.domain().utf8().data()),
             resourceError.errorCode(), resourceError.localizedDescription().utf8().data()));
-        g_signal_emit(printOperation.get(), signals[FAILED], 0, printError.get());
+        g_signal_emit(printOperation, signals[FAILED], 0, printError.get());
     }
-    g_signal_emit(printOperation.get(), signals[FINISHED], 0, NULL);
+    g_signal_emit(printOperation, signals[FINISHED], 0, NULL);
 }
 
 static void webkitPrintOperationPrintPagesForFrame(WebKitPrintOperation* printOperation, WebFrameProxy* webFrame, GtkPrintSettings* printSettings, GtkPageSetup* pageSetup)
 {
     PrintInfo printInfo(printSettings, pageSetup, printOperation->priv->printMode);
     WebPageProxy* page = webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(printOperation->priv->webView));
-    page->drawPagesForPrinting(webFrame, printInfo, PrintFinishedCallback::create(g_object_ref(printOperation), &drawPagesForPrintingCompleted));
+    g_object_ref(printOperation);
+    page->drawPagesForPrinting(webFrame, printInfo, PrintFinishedCallback::create([printOperation](bool /*error*/, API::Error* printError) {
+        drawPagesForPrintingCompleted(printError, adoptGRef(printOperation).get());
+    }));
 }
 
 WebKitPrintOperationResponse webkitPrintOperationRunDialogForFrame(WebKitPrintOperation* printOperation, GtkWindow* parent, WebFrameProxy* webFrame)
index b370af2..08bfd51 100644 (file)
@@ -314,12 +314,11 @@ struct ResourceGetDataAsyncData {
 };
 WEBKIT_DEFINE_ASYNC_DATA_STRUCT(ResourceGetDataAsyncData)
 
-static void resourceDataCallback(WKDataRef wkData, WKErrorRef, void* context)
+static void resourceDataCallback(API::Data* wkData, GTask* task)
 {
-    GRefPtr<GTask> task = adoptGRef(G_TASK(context));
-    ResourceGetDataAsyncData* data = static_cast<ResourceGetDataAsyncData*>(g_task_get_task_data(task.get()));
-    data->webData = toImpl(wkData);
-    g_task_return_boolean(task.get(), TRUE);
+    ResourceGetDataAsyncData* data = static_cast<ResourceGetDataAsyncData*>(g_task_get_task_data(task));
+    data->webData = wkData;
+    g_task_return_boolean(task, TRUE);
 }
 
 /**
@@ -341,10 +340,14 @@ void webkit_web_resource_get_data(WebKitWebResource* resource, GCancellable* can
     GTask* task = g_task_new(resource, cancellable, callback, userData);
     g_task_set_task_data(task, createResourceGetDataAsyncData(), reinterpret_cast<GDestroyNotify>(destroyResourceGetDataAsyncData));
     if (resource->priv->isMainResource)
-        resource->priv->frame->getMainResourceData(DataCallback::create(task, resourceDataCallback));
+        resource->priv->frame->getMainResourceData(DataCallback::create([task](bool /*error*/, API::Data* data) {
+            resourceDataCallback(data, adoptGRef(task).get());
+        }));
     else {
         String url = String::fromUTF8(resource->priv->uri.data());
-        resource->priv->frame->getResourceData(API::URL::create(url).get(), DataCallback::create(task, resourceDataCallback));
+        resource->priv->frame->getResourceData(API::URL::create(url).get(), DataCallback::create([task](bool /*error*/, API::Data* data) {
+            resourceDataCallback(data, adoptGRef(task).get());
+        }));
     }
 }
 
index 49d954d..8f7290b 100644 (file)
@@ -2510,12 +2510,6 @@ gdouble webkit_web_view_get_zoom_level(WebKitWebView* webView)
     return zoomTextOnly ? page->textZoomFactor() : page->pageZoomFactor();
 }
 
-static void didValidateCommand(WKStringRef command, bool isEnabled, int32_t state, WKErrorRef, void* context)
-{
-    GRefPtr<GTask> task = adoptGRef(G_TASK(context));
-    g_task_return_boolean(task.get(), isEnabled);
-}
-
 /**
  * webkit_web_view_can_execute_editing_command:
  * @web_view: a #WebKitWebView
@@ -2535,7 +2529,9 @@ void webkit_web_view_can_execute_editing_command(WebKitWebView* webView, const c
     g_return_if_fail(command);
 
     GTask* task = g_task_new(webView, cancellable, callback, userData);
-    getPage(webView)->validateCommand(String::fromUTF8(command), ValidateCommandCallback::create(task, didValidateCommand));
+    getPage(webView)->validateCommand(String::fromUTF8(command), ValidateCommandCallback::create([task](bool /*error*/, StringImpl* /*command*/, bool isEnabled, int32_t /*state*/) {
+        g_task_return_boolean(adoptGRef(task).get(), isEnabled);        
+    }));
 }
 
 /**
@@ -2612,20 +2608,19 @@ JSGlobalContextRef webkit_web_view_get_javascript_global_context(WebKitWebView*
     return webView->priv->javascriptGlobalContext;
 }
 
-static void webkitWebViewRunJavaScriptCallback(WKSerializedScriptValueRef wkSerializedScriptValue, WKErrorRef, void* context)
+static void webkitWebViewRunJavaScriptCallback(WebSerializedScriptValue* wkSerializedScriptValue, GTask* task)
 {
-    GRefPtr<GTask> task = adoptGRef(G_TASK(context));
-    if (g_task_return_error_if_cancelled(task.get()))
+    if (g_task_return_error_if_cancelled(task))
         return;
 
     if (!wkSerializedScriptValue) {
-        g_task_return_new_error(task.get(), WEBKIT_JAVASCRIPT_ERROR, WEBKIT_JAVASCRIPT_ERROR_SCRIPT_FAILED,
+        g_task_return_new_error(task, WEBKIT_JAVASCRIPT_ERROR, WEBKIT_JAVASCRIPT_ERROR_SCRIPT_FAILED,
             _("An exception was raised in JavaScript"));
         return;
     }
 
-    WebKitWebView* webView = WEBKIT_WEB_VIEW(g_task_get_source_object(task.get()));
-    g_task_return_pointer(task.get(), webkitJavascriptResultCreate(webView, toImpl(wkSerializedScriptValue)),
+    WebKitWebView* webView = WEBKIT_WEB_VIEW(g_task_get_source_object(task));
+    g_task_return_pointer(task, webkitJavascriptResultCreate(webView, wkSerializedScriptValue),
         reinterpret_cast<GDestroyNotify>(webkit_javascript_result_unref));
 }
 
@@ -2649,7 +2644,9 @@ void webkit_web_view_run_javascript(WebKitWebView* webView, const gchar* script,
     g_return_if_fail(script);
 
     GTask* task = g_task_new(webView, cancellable, callback, userData);
-    getPage(webView)->runJavaScriptInMainFrame(String::fromUTF8(script), ScriptValueCallback::create(task, webkitWebViewRunJavaScriptCallback));
+    getPage(webView)->runJavaScriptInMainFrame(String::fromUTF8(script), ScriptValueCallback::create([task](bool /*error*/, WebSerializedScriptValue* serializedScriptValue) {
+        webkitWebViewRunJavaScriptCallback(serializedScriptValue, adoptGRef(task).get());
+    }));
 }
 
 /**
@@ -2738,7 +2735,9 @@ static void resourcesStreamReadCallback(GObject* object, GAsyncResult* result, g
     WebKitWebView* webView = WEBKIT_WEB_VIEW(g_task_get_source_object(task.get()));
     gpointer outputStreamData = g_memory_output_stream_get_data(G_MEMORY_OUTPUT_STREAM(object));
     getPage(webView)->runJavaScriptInMainFrame(String::fromUTF8(reinterpret_cast<const gchar*>(outputStreamData)),
-        ScriptValueCallback::create(task.leakRef(), webkitWebViewRunJavaScriptCallback));
+        ScriptValueCallback::create([task](bool /*error*/, WebSerializedScriptValue* serializedScriptValue) {
+        webkitWebViewRunJavaScriptCallback(serializedScriptValue, task.get());
+    }));
 }
 
 /**
@@ -2865,16 +2864,16 @@ static void fileReplaceContentsCallback(GObject* object, GAsyncResult* result, g
     g_task_return_boolean(task.get(), TRUE);
 }
 
-static void getContentsAsMHTMLDataCallback(WKDataRef wkData, WKErrorRef, void* context)
+static void getContentsAsMHTMLDataCallback(API::Data* wkData, GTask* taskPtr)
 {
-    GRefPtr<GTask> task = adoptGRef(G_TASK(context));
+    GRefPtr<GTask> task = adoptGRef(taskPtr);
     if (g_task_return_error_if_cancelled(task.get()))
         return;
 
     ViewSaveAsyncData* data = static_cast<ViewSaveAsyncData*>(g_task_get_task_data(task.get()));
     // We need to retain the data until the asyncronous process
     // initiated by the user has finished completely.
-    data->webData = toImpl(wkData);
+    data->webData = wkData;
 
     // If we are saving to a file we need to write the data on disk before finishing.
     if (g_task_get_source_tag(task.get()) == webkit_web_view_save_to_file) {
@@ -2914,7 +2913,9 @@ void webkit_web_view_save(WebKitWebView* webView, WebKitSaveMode saveMode, GCanc
     GTask* task = g_task_new(webView, cancellable, callback, userData);
     g_task_set_source_tag(task, reinterpret_cast<gpointer>(webkit_web_view_save));
     g_task_set_task_data(task, createViewSaveAsyncData(), reinterpret_cast<GDestroyNotify>(destroyViewSaveAsyncData));
-    getPage(webView)->getContentsAsMHTMLData(DataCallback::create(task, getContentsAsMHTMLDataCallback), false);
+    getPage(webView)->getContentsAsMHTMLData(DataCallback::create([task](bool /*error*/, API::Data* data) {
+        getContentsAsMHTMLDataCallback(data, task);
+    }), false);
 }
 
 /**
@@ -2977,7 +2978,9 @@ void webkit_web_view_save_to_file(WebKitWebView* webView, GFile* file, WebKitSav
     data->file = file;
     g_task_set_task_data(task, data, reinterpret_cast<GDestroyNotify>(destroyViewSaveAsyncData));
 
-    getPage(webView)->getContentsAsMHTMLData(DataCallback::create(task, getContentsAsMHTMLDataCallback), false);
+    getPage(webView)->getContentsAsMHTMLData(DataCallback::create([task](bool /*error*/, API::Data* data) {
+        getContentsAsMHTMLDataCallback(data, task);
+    }), false);
 }
 
 /**
index cfd133e..14d4441 100644 (file)
@@ -907,22 +907,17 @@ static inline bool isSamePair(UIGestureRecognizer *a, UIGestureRecognizer *b, UI
         [_webSelectionAssistant showDictionaryFor:text fromRect:presentationRect];
 }
 
-static void selectedString(WKStringRef string, WKErrorRef error, void* context)
-{
-    if (error)
-        return;
-    if (!string)
-        return;
-
-    NSString *convertedString = toImpl(string)->string();
-    WKInteractionView* view = static_cast<WKInteractionView*>(context);
-    ASSERT(view);
-    [view _showDictionary:convertedString];
-}
-
 - (void)_define:(id)sender
 {
-    _page->getSelectionOrContentsAsString(StringCallback::create(self, selectedString));
+    _page->getSelectionOrContentsAsString(StringCallback::create([self](bool error, StringImpl* string) {
+        if (error)
+            return;
+        if (!string)
+            return;
+
+        NSString *convertedString = *string;
+        [self _showDictionary:convertedString];
+    }));
 }
 
 // UIWKInteractionViewProtocol
@@ -1083,28 +1078,24 @@ static inline UIWKSelectionFlags toUIWKSelectionFlags(WKSelectionFlags flag)
     }
 }
 
-static void selectionChangedWithGesture(const WebCore::IntPoint& point, uint32_t gestureType, uint32_t gestureState, uint32_t flags, WKErrorRef error, void* context)
+static void selectionChangedWithGesture(bool error, WKInteractionView *view, const WebCore::IntPoint& point, uint32_t gestureType, uint32_t gestureState, uint32_t flags)
 {
     if (error) {
         ASSERT_NOT_REACHED();
         return;
     }
-    WKInteractionView *view = static_cast<WKInteractionView*>(context);
-    ASSERT(view);
     if ([view webSelectionAssistant])
         [(UIWKSelectionAssistant *)[view webSelectionAssistant] selectionChangedWithGestureAt:(CGPoint)point withGesture:toUIWKGestureType((WKGestureType)gestureType) withState:toUIGestureRecognizerState(static_cast<WKGestureRecognizerState>(gestureState)) withFlags:(toUIWKSelectionFlags((WKSelectionFlags)flags))];
     else
         [(UIWKTextInteractionAssistant *)[view interactionAssistant] selectionChangedWithGestureAt:(CGPoint)point withGesture:toUIWKGestureType((WKGestureType)gestureType) withState:toUIGestureRecognizerState(static_cast<WKGestureRecognizerState>(gestureState)) withFlags:(toUIWKSelectionFlags((WKSelectionFlags)flags))];
 }
 
-static void selectionChangedWithTouch(const WebCore::IntPoint& point, uint32_t touch, WKErrorRef error, void* context)
+static void selectionChangedWithTouch(bool error, WKInteractionView *view, const WebCore::IntPoint& point, uint32_t touch)
 {
     if (error) {
         ASSERT_NOT_REACHED();
         return;
     }
-    WKInteractionView *view = static_cast<WKInteractionView*>(context);
-    ASSERT(view);
     if ([view webSelectionAssistant])
         [(UIWKSelectionAssistant *)[view webSelectionAssistant] selectionChangedWithTouchAt:(CGPoint)point withSelectionTouch:toUIWKSelectionTouch((WKSelectionTouch)touch)];
     else
@@ -1113,17 +1104,23 @@ static void selectionChangedWithTouch(const WebCore::IntPoint& point, uint32_t t
 
 - (void)changeSelectionWithGestureAt:(CGPoint)point withGesture:(UIWKGestureType)gestureType withState:(UIGestureRecognizerState)state
 {
-    _page->selectWithGesture(WebCore::IntPoint(point), CharacterGranularity, toWKGestureType(gestureType), toWKGestureRecognizerState(state), GestureCallback::create(self, selectionChangedWithGesture));
+    _page->selectWithGesture(WebCore::IntPoint(point), CharacterGranularity, toWKGestureType(gestureType), toWKGestureRecognizerState(state), GestureCallback::create([self](bool error, const WebCore::IntPoint& point, uint32_t gestureType, uint32_t gestureState, uint32_t flags) {
+        selectionChangedWithGesture(error, self, point, gestureType, gestureState, flags);
+    }));
 }
 
 - (void)changeSelectionWithTouchAt:(CGPoint)point withSelectionTouch:(UIWKSelectionTouch)touch baseIsStart:(BOOL)baseIsStart
 {
-    _page->updateSelectionWithTouches(WebCore::IntPoint(point), toWKSelectionTouch(touch), baseIsStart, TouchesCallback::create(self, selectionChangedWithTouch));
+    _page->updateSelectionWithTouches(WebCore::IntPoint(point), toWKSelectionTouch(touch), baseIsStart, TouchesCallback::create([self](bool error, const WebCore::IntPoint& point, uint32_t touch) {
+        selectionChangedWithTouch(error, self, point, touch);
+    }));
 }
 
 - (void)changeSelectionWithTouchesFrom:(CGPoint)from to:(CGPoint)to withGesture:(UIWKGestureType)gestureType withState:(UIGestureRecognizerState)gestureState
 {
-    _page->selectWithTwoTouches(WebCore::IntPoint(from), WebCore::IntPoint(to), toWKGestureType(gestureType), toWKGestureRecognizerState(gestureState), GestureCallback::create(self, selectionChangedWithGesture));
+    _page->selectWithTwoTouches(WebCore::IntPoint(from), WebCore::IntPoint(to), toWKGestureType(gestureType), toWKGestureRecognizerState(gestureState), GestureCallback::create([self](bool error, const WebCore::IntPoint& point, uint32_t gestureType, uint32_t gestureState, uint32_t flags) {
+        selectionChangedWithGesture(error, self, point, gestureType, gestureState, flags);
+    }));
 }
 
 - (WKAutoCorrectionData *)autocorrectionData
@@ -1131,29 +1128,6 @@ static void selectionChangedWithTouch(const WebCore::IntPoint& point, uint32_t t
     return &_autocorrectionData;
 }
 
-static void autocorrectionData(const Vector<FloatRect>& rects, const String& fontName, double fontSize, uint64_t traits, WKErrorRef error, void* context)
-{
-    WKInteractionView* view = static_cast<WKInteractionView*>(context);
-    ASSERT(view);
-    CGRect firstRect = CGRectZero;
-    CGRect lastRect = CGRectZero;
-    if (rects.size()) {
-        firstRect = rects[0];
-        lastRect = rects[rects.size() - 1];
-    }
-
-    WKAutoCorrectionData *autocorrectionData = view.autocorrectionData;
-    autocorrectionData->fontName = fontName;
-    autocorrectionData->fontSize = fontSize;
-    autocorrectionData->fontTraits = traits;
-    autocorrectionData->textFirstRect = firstRect;
-    autocorrectionData->textLastRect = lastRect;
-
-    autocorrectionData->autocorrectionHandler(rects.size() ? [WKAutocorrectionRects autocorrectionRectsWithRects:firstRect lastRect:lastRect] : nil);
-    [autocorrectionData->autocorrectionHandler release];
-    autocorrectionData->autocorrectionHandler = nil;
-}
-
 // The completion handler can pass nil if input does not match the actual text preceding the insertion point.
 - (void)requestAutocorrectionRectsForString:(NSString *)input withCompletionHandler:(void (^)(UIWKAutocorrectionRects *rectsForInput))completionHandler
 {
@@ -1162,7 +1136,25 @@ static void autocorrectionData(const Vector<FloatRect>& rects, const String& fon
         return;
     }
     _autocorrectionData.autocorrectionHandler = [completionHandler copy];
-    _page->requestAutocorrectionData(input, AutocorrectionDataCallback::create(self, autocorrectionData));
+    _page->requestAutocorrectionData(input, AutocorrectionDataCallback::create([self, completionHandler](bool, const Vector<FloatRect>& rects, const String& fontName, double fontSize, uint64_t traits) {
+        CGRect firstRect = CGRectZero;
+        CGRect lastRect = CGRectZero;
+        if (rects.size()) {
+            firstRect = rects[0];
+            lastRect = rects[rects.size() - 1];
+        }
+
+        WKAutoCorrectionData *autocorrectionData = self.autocorrectionData;
+        autocorrectionData->fontName = fontName;
+        autocorrectionData->fontSize = fontSize;
+        autocorrectionData->fontTraits = traits;
+        autocorrectionData->textFirstRect = firstRect;
+        autocorrectionData->textLastRect = lastRect;
+
+        autocorrectionData->autocorrectionHandler(rects.size() ? [WKAutocorrectionRects autocorrectionRectsWithRects:firstRect lastRect:lastRect] : nil);
+        [autocorrectionData->autocorrectionHandler release];
+        autocorrectionData->autocorrectionHandler = nil;
+    }));
 }
 
 - (CGRect)textFirstRect
@@ -1175,30 +1167,17 @@ static void autocorrectionData(const Vector<FloatRect>& rects, const String& fon
     return (_page->editorState().hasComposition) ? _page->editorState().lastMarkedRect : _autocorrectionData.textLastRect;
 }
 
-static void autocorrectionResult(WKStringRef correction, WKErrorRef error, void* context)
-{
-    WKInteractionView* view = static_cast<WKInteractionView*>(context);
-    ASSERT(view);
-    WKAutoCorrectionData *autocorrectionData = view.autocorrectionData;
-
-    autocorrectionData->autocorrectionHandler(correction ? [WKAutocorrectionRects autocorrectionRectsWithRects:autocorrectionData->textFirstRect lastRect:autocorrectionData->textLastRect] : nil);
-    [autocorrectionData->autocorrectionHandler release];
-    autocorrectionData->autocorrectionHandler = nil;
-}
-
 // The completion handler should pass the rect of the correction text after replacing the input text, or nil if the replacement could not be performed.
 - (void)applyAutocorrection:(NSString *)correction toString:(NSString *)input withCompletionHandler:(void (^)(UIWKAutocorrectionRects *rectsForCorrection))completionHandler
 {
     _autocorrectionData.autocorrectionHandler = [completionHandler copy];
-    _page->applyAutocorrection(correction, input, StringCallback::create(self, autocorrectionResult));
-}
+    _page->applyAutocorrection(correction, input, StringCallback::create([self](bool /*error*/, StringImpl* string) {
+        WKAutoCorrectionData *autocorrectionData = self.autocorrectionData;
 
-static void autocorrectionContext(const String& beforeText, const String& markedText, const String& selectedText, const String& afterText, uint64_t location, uint64_t length, WKErrorRef error, void* context)
-{
-    WKInteractionView* view = static_cast<WKInteractionView*>(context);
-    ASSERT(view);
-    WKAutoCorrectionData *autocorrectionData = view.autocorrectionData;
-    autocorrectionData->autocorrectionContextHandler([WKAutocorrectionContext autocorrectionContextWithData:beforeText markedText:markedText selectedText:selectedText afterText:afterText selectedRangeInMarkedText:NSMakeRange(location, length)]);
+        autocorrectionData->autocorrectionHandler(string ? [WKAutocorrectionRects autocorrectionRectsWithRects:autocorrectionData->textFirstRect lastRect:autocorrectionData->textLastRect] : nil);
+        [autocorrectionData->autocorrectionHandler release];
+        autocorrectionData->autocorrectionHandler = nil;
+    }));
 }
 
 - (void)requestAutocorrectionContextWithCompletionHandler:(void (^)(UIWKAutocorrectionContext *autocorrectionContext))completionHandler
@@ -1217,7 +1196,10 @@ static void autocorrectionContext(const String& beforeText, const String& marked
         completionHandler([WKAutocorrectionContext autocorrectionContextWithData:beforeText markedText:markedText selectedText:selectedText afterText:afterText selectedRangeInMarkedText:NSMakeRange(location, length)]);
     } else {
         _autocorrectionData.autocorrectionContextHandler = [completionHandler copy];
-        _page->requestAutocorrectionContext(AutocorrectionContextCallback::create(self, autocorrectionContext));
+        _page->requestAutocorrectionContext(AutocorrectionContextCallback::create([self, completionHandler](bool /*error*/, const String& beforeText, const String& markedText, const String& selectedText, const String& afterText, uint64_t location, uint64_t length) {
+            WKAutoCorrectionData *autocorrectionData = self.autocorrectionData;
+            autocorrectionData->autocorrectionContextHandler([WKAutocorrectionContext autocorrectionContextWithData:beforeText markedText:markedText selectedText:selectedText afterText:afterText selectedRangeInMarkedText:NSMakeRange(location, length)]);
+        }));
     }
 }
 
index a381a87..6ca7088 100644 (file)
@@ -207,11 +207,10 @@ struct IPCCallbackContext {
     uint64_t callbackID;
 };
 
-static void pageDidDrawToImage(const ShareableBitmap::Handle& imageHandle, WKErrorRef, void* untypedContext)
+static void pageDidDrawToImage(const ShareableBitmap::Handle& imageHandle, IPCCallbackContext* context)
 {
     ASSERT(RunLoop::isMain());
 
-    OwnPtr<IPCCallbackContext> context = adoptPtr(static_cast<IPCCallbackContext*>(untypedContext));
     WKPrintingView *view = context->view.get();
 
     // If the user has already changed print setup, then this response is obsolete. And if this callback is not in response to the latest request,
@@ -236,25 +235,6 @@ static void pageDidDrawToImage(const ShareableBitmap::Handle& imageHandle, WKErr
     }
 }
 
-static void pageDidDrawToPDF(WKDataRef dataRef, WKErrorRef, void* untypedContext)
-{
-    ASSERT(RunLoop::isMain());
-
-    OwnPtr<IPCCallbackContext> context = adoptPtr(static_cast<IPCCallbackContext*>(untypedContext));
-    WKPrintingView *view = context->view.get();
-    API::Data* data = toImpl(dataRef);
-
-    if (context->callbackID == view->_expectedPrintCallback) {
-        ASSERT(![view _isPrintingPreview]);
-        ASSERT(view->_printedPagesData.isEmpty());
-        ASSERT(!view->_printedPagesPDFDocument);
-        if (data)
-            view->_printedPagesData.append(data->bytes(), data->size());
-        view->_expectedPrintCallback = 0;
-        view->_printingCallbackCondition.notify_one();
-    }
-}
-
 - (void)_preparePDFDataForPrintingOnSecondaryThread
 {
     ASSERT(RunLoop::isMain());
@@ -283,7 +263,22 @@ static void pageDidDrawToPDF(WKDataRef dataRef, WKErrorRef, void* untypedContext
     _webFrame->page()->beginPrinting(_webFrame.get(), printInfo);
 
     IPCCallbackContext* context = new IPCCallbackContext;
-    RefPtr<DataCallback> callback = DataCallback::create(context, pageDidDrawToPDF);
+    RefPtr<DataCallback> callback = DataCallback::create([context](bool, API::Data* data) {
+        ASSERT(RunLoop::isMain());
+
+        OwnPtr<IPCCallbackContext> contextDeleter = adoptPtr(context);
+        WKPrintingView *view = context->view.get();
+
+        if (context->callbackID == view->_expectedPrintCallback) {
+            ASSERT(![view _isPrintingPreview]);
+            ASSERT(view->_printedPagesData.isEmpty());
+            ASSERT(!view->_printedPagesPDFDocument);
+            if (data)
+                view->_printedPagesData.append(data->bytes(), data->size());
+            view->_expectedPrintCallback = 0;
+            view->_printingCallbackCondition.notify_one();
+        }
+    });
     _expectedPrintCallback = callback->callbackID();
 
     context->view = self;
@@ -292,11 +287,10 @@ static void pageDidDrawToPDF(WKDataRef dataRef, WKErrorRef, void* untypedContext
     _webFrame->page()->drawPagesToPDF(_webFrame.get(), printInfo, firstPage - 1, lastPage - firstPage + 1, callback.get());
 }
 
-static void pageDidComputePageRects(const Vector<WebCore::IntRect>& pageRects, double totalScaleFactorForPrinting, WKErrorRef, void* untypedContext)
+static void pageDidComputePageRects(const Vector<WebCore::IntRect>& pageRects, double totalScaleFactorForPrinting, IPCCallbackContext* context)
 {
     ASSERT(RunLoop::isMain());
 
-    OwnPtr<IPCCallbackContext> context = adoptPtr(static_cast<IPCCallbackContext*>(untypedContext));
     WKPrintingView *view = context->view.get();
 
     // If the user has already changed print setup, then this response is obsolete.
@@ -344,7 +338,10 @@ static void pageDidComputePageRects(const Vector<WebCore::IntRect>& pageRects, d
     ASSERT(!_expectedComputedPagesCallback);
 
     IPCCallbackContext* context = new IPCCallbackContext;
-    RefPtr<ComputedPagesCallback> callback = ComputedPagesCallback::create(context, pageDidComputePageRects);
+    RefPtr<ComputedPagesCallback> callback = ComputedPagesCallback::create([context](bool, const Vector<WebCore::IntRect>& pageRects, double totalScaleFactorForPrinting) {
+        OwnPtr<IPCCallbackContext> contextDeleter = adoptPtr(context);
+        pageDidComputePageRects(pageRects, totalScaleFactorForPrinting, context);
+    });
     _expectedComputedPagesCallback = callback->callbackID();
     context->view = self;
     context->callbackID = _expectedComputedPagesCallback;
@@ -493,7 +490,10 @@ static void prepareDataForPrintingOnSecondaryThread(void* untypedContext)
                 _webFrame->page()->beginPrinting(_webFrame.get(), PrintInfo([_printOperation printInfo]));
 
                 IPCCallbackContext* context = new IPCCallbackContext;
-                RefPtr<ImageCallback> callback = ImageCallback::create(context, pageDidDrawToImage);
+                RefPtr<ImageCallback> callback = ImageCallback::create([context](bool, const ShareableBitmap::Handle& imageHandle) {
+                    OwnPtr<IPCCallbackContext> contextDeleter = adoptPtr(context);
+                    pageDidDrawToImage(imageHandle, context);
+                });
                 _latestExpectedPreviewCallback = callback->callbackID();
                 _expectedPreviewCallbacks.add(_latestExpectedPreviewCallback, scaledPrintingRect);
 
index de28421..09cdc8f 100644 (file)
@@ -728,18 +728,6 @@ static NSToolbarItem *toolbarItem(id <NSValidatedUserInterfaceItem> item)
     return (NSToolbarItem *)item;
 }
 
-static void validateCommandCallback(WKStringRef commandName, bool isEnabled, int32_t state, WKErrorRef error, void* context)
-{
-    // If the process exits before the command can be validated, we'll be called back with an error.
-    if (error)
-        return;
-    
-    WKView* wkView = static_cast<WKView*>(context);
-    ASSERT(wkView);
-    
-    [wkView _setUserInterfaceItemState:nsStringFromWebCoreString(toImpl(commandName)->string()) enabled:isEnabled state:state];
-}
-
 - (BOOL)validateUserInterfaceItem:(id <NSValidatedUserInterfaceItem>)item
 {
     SEL action = [item action];
@@ -831,7 +819,13 @@ static void validateCommandCallback(WKStringRef commandName, bool isEnabled, int
         // If we are not already awaiting validation for this command, start the asynchronous validation process.
         // FIXME: Theoretically, there is a race here; when we get the answer it might be old, from a previous time
         // we asked for the same command; there is no guarantee the answer is still valid.
-        _data->_page->validateCommand(commandName, ValidateCommandCallback::create(self, validateCommandCallback));
+        _data->_page->validateCommand(commandName, ValidateCommandCallback::create([self](bool error, StringImpl* commandName, bool isEnabled, int32_t state) {
+            // If the process exits before the command can be validated, we'll be called back with an error.
+            if (error)
+                return;
+            
+            [self _setUserInterfaceItemState:nsStringFromWebCoreString(commandName) enabled:isEnabled state:state];
+        }));
     }
 
     // Treat as enabled until we get the result back from the web process and _setUserInterfaceItemState is called.
@@ -840,20 +834,16 @@ static void validateCommandCallback(WKStringRef commandName, bool isEnabled, int
     return YES;
 }
 
-static void speakString(WKStringRef string, WKErrorRef error, void*)
-{
-    if (error)
-        return;
-    if (!string)
-        return;
-
-    NSString *convertedString = toImpl(string)->string();
-    [NSApp speakString:convertedString];
-}
-
 - (IBAction)startSpeaking:(id)sender
 {
-    _data->_page->getSelectionOrContentsAsString(StringCallback::create(0, speakString));
+    _data->_page->getSelectionOrContentsAsString(StringCallback::create([self](bool error, StringImpl* string) {
+        if (error)
+            return;
+        if (!string)
+            return;
+
+        [NSApp speakString:*string];
+    }));
 }
 
 - (IBAction)stopSpeaking:(id)sender
index 90cf928..3ea1e1a 100644 (file)
@@ -37,11 +37,11 @@ namespace WebKit {
 
 class AutocorrectionDataCallback : public CallbackBase {
 public:
-    typedef void (*CallbackFunction)(const Vector<WebCore::FloatRect>&, const String&, double, uint64_t, WKErrorRef, void*);
+    typedef std::function<void (bool, const Vector<WebCore::FloatRect>&, const String&, double, uint64_t)> CallbackFunction;
 
-    static PassRefPtr<AutocorrectionDataCallback> create(void* context, CallbackFunction callback)
+    static PassRefPtr<AutocorrectionDataCallback> create(CallbackFunction callback)
     {
-        return adoptRef(new AutocorrectionDataCallback(context, callback));
+        return adoptRef(new AutocorrectionDataCallback(callback));
     }
 
     virtual ~AutocorrectionDataCallback()
@@ -53,7 +53,7 @@ public:
     {
         ASSERT(m_callback);
 
-        m_callback(returnValue1, returnValue2, returnValue3, returnValue4, 0, context());
+        m_callback(false, returnValue1, returnValue2, returnValue3, returnValue4);
 
         m_callback = 0;
     }
@@ -62,16 +62,14 @@ public:
     {
         ASSERT(m_callback);
 
-        RefPtr<API::Error> error = API::Error::create();
-        m_callback(Vector<WebCore::FloatRect>(), String(), 0, 0, toAPI(error.get()), context());
+        m_callback(true, Vector<WebCore::FloatRect>(), String(), 0, 0);
 
         m_callback = 0;
     }
 
 private:
-    AutocorrectionDataCallback(void* context, CallbackFunction callback)
-        : CallbackBase(context)
-        , m_callback(callback)
+    AutocorrectionDataCallback(CallbackFunction callback)
+        : m_callback(callback)
     {
         ASSERT(m_callback);
     }
@@ -81,11 +79,11 @@ private:
 
 class AutocorrectionContextCallback : public CallbackBase {
 public:
-    typedef void (*CallbackFunction)(const String&, const String&, const String&, const String&, uint64_t, uint64_t, WKErrorRef, void*);
+    typedef std::function<void (bool, const String&, const String&, const String&, const String&, uint64_t, uint64_t)> CallbackFunction;
 
-    static PassRefPtr<AutocorrectionContextCallback> create(void* context, CallbackFunction callback)
+    static PassRefPtr<AutocorrectionContextCallback> create(CallbackFunction callback)
     {
-        return adoptRef(new AutocorrectionContextCallback(context, callback));
+        return adoptRef(new AutocorrectionContextCallback(callback));
     }
 
     virtual ~AutocorrectionContextCallback()
@@ -97,7 +95,7 @@ public:
     {
         ASSERT(m_callback);
 
-        m_callback(returnValue1, returnValue2, returnValue3, returnValue4, returnValue5, returnValue6, 0, context());
+        m_callback(false, returnValue1, returnValue2, returnValue3, returnValue4, returnValue5, returnValue6);
 
         m_callback = 0;
     }
@@ -106,16 +104,14 @@ public:
     {
         ASSERT(m_callback);
 
-        RefPtr<API::Error> error = API::Error::create();
-        m_callback(String(), String(), String(), String(), 0, 0, toAPI(error.get()), context());
+        m_callback(true, String(), String(), String(), String(), 0, 0);
 
         m_callback = 0;
     }
 
 private:
-    AutocorrectionContextCallback(void* context, CallbackFunction callback)
-        : CallbackBase(context)
-        , m_callback(callback)
+    AutocorrectionContextCallback(CallbackFunction callback)
+        : m_callback(callback)
     {
         ASSERT(m_callback);
     }
index 907e615..5797a9d 100644 (file)
@@ -29,7 +29,9 @@
 #include "APIError.h"
 #include "ShareableBitmap.h"
 #include "WKAPICast.h"
+#include <functional>
 #include <wtf/HashMap.h>
+#include <wtf/MainThread.h>
 #include <wtf/PassRefPtr.h>
 #include <wtf/RefCounted.h>
 
@@ -44,32 +46,29 @@ public:
     uint64_t callbackID() const { return m_callbackID; }
 
 protected:
-    explicit CallbackBase(void* context)
-        : m_context(context)
-        , m_callbackID(generateCallbackID())
+    explicit CallbackBase()
+        : m_callbackID(generateCallbackID())
     {
     }
 
-    void* context() const { return m_context; }
-
 private:
     static uint64_t generateCallbackID()
     {
+        ASSERT(isMainThread());
         static uint64_t uniqueCallbackID = 1;
         return uniqueCallbackID++;
     }
 
-    void* m_context;
     uint64_t m_callbackID;
 };
 
 class VoidCallback : public CallbackBase {
 public:
-    typedef void (*CallbackFunction)(WKErrorRef, void*);
+    typedef std::function<void (bool)> CallbackFunction;
 
-    static PassRefPtr<VoidCallback> create(void* context, CallbackFunction callback)
+    static PassRefPtr<VoidCallback> create(CallbackFunction callback)
     {
-        return adoptRef(new VoidCallback(context, callback));
+        return adoptRef(new VoidCallback(callback));
     }
 
     virtual ~VoidCallback()
@@ -82,9 +81,9 @@ public:
         if (!m_callback)
             return;
 
-        m_callback(0, context());
+        m_callback(false);
 
-        m_callback = 0;
+        m_callback = nullptr;
     }
     
     void invalidate()
@@ -92,30 +91,40 @@ public:
         if (!m_callback)
             return;
 
-        RefPtr<API::Error> error = API::Error::create();
-        m_callback(toAPI(error.get()), context());
-        
-        m_callback = 0;
+        m_callback(true);
+
+        m_callback = nullptr;
     }
 
 private:
-    VoidCallback(void* context, CallbackFunction callback)
-        : CallbackBase(context)
-        , m_callback(callback)
+    VoidCallback(CallbackFunction callback)
+        : m_callback(callback)
     {
     }
 
     CallbackFunction m_callback;
 };
 
-template<typename APIReturnValueType, typename InternalReturnValueType = typename APITypeInfo<APIReturnValueType>::ImplType>
+class VoidAPICallback : public CallbackBase {
+public:
+    typedef void (*CallbackFunction)(WKErrorRef, void*);
+
+    static PassRefPtr<VoidCallback> create(void* context, CallbackFunction callback)
+    {
+        return VoidCallback::create([context, callback](bool error) {
+            callback(error ? toAPI(API::Error::create().get()) : 0, context);
+        });
+    }
+};
+
+template<typename T>
 class GenericCallback : public CallbackBase {
 public:
-    typedef void (*CallbackFunction)(APIReturnValueType, WKErrorRef, void*);
+    typedef std::function<void (bool, T)> CallbackFunction;
 
-    static PassRefPtr<GenericCallback> create(void* context, CallbackFunction callback)
+    static PassRefPtr<GenericCallback> create(CallbackFunction callback)
     {
-        return adoptRef(new GenericCallback(context, callback));
+        return adoptRef(new GenericCallback(callback));
     }
 
     virtual ~GenericCallback()
@@ -123,43 +132,56 @@ public:
         ASSERT(!m_callback);
     }
 
-    void performCallbackWithReturnValue(InternalReturnValueType returnValue)
+    void performCallbackWithReturnValue(T returnValue)
     {
-        ASSERT(m_callback);
+        if (!m_callback)
+            return;
 
-        m_callback(toAPI(returnValue), 0, context());
+        m_callback(false, returnValue);
 
-        m_callback = 0;
+        m_callback = nullptr;
     }
     
     void invalidate()
     {
-        ASSERT(m_callback);
+        if (!m_callback)
+            return;
 
-        RefPtr<API::Error> error = API::Error::create();
-        m_callback(0, toAPI(error.get()), context());
-        
-        m_callback = 0;
+        m_callback(true, T());
+
+        m_callback = nullptr;
     }
 
 private:
-    GenericCallback(void* context, CallbackFunction callback)
-        : CallbackBase(context)
-        , m_callback(callback)
+    GenericCallback(CallbackFunction callback)
+        : m_callback(callback)
     {
     }
 
     CallbackFunction m_callback;
 };
 
-// FIXME: Make a version of CallbackBase with two arguments, and define ComputedPagesCallback as a specialization.
+template<typename APIReturnValueType, typename InternalReturnValueType = typename APITypeInfo<APIReturnValueType>::ImplType>
+class GenericAPICallback : public CallbackBase {
+public:
+    typedef void (*CallbackFunction)(APIReturnValueType, WKErrorRef, void*);
+
+    static PassRefPtr<GenericCallback<InternalReturnValueType>> create(void* context, CallbackFunction callback)
+    {
+        return GenericCallback<InternalReturnValueType>::create([context, callback](bool error, InternalReturnValueType returnValue) {
+            callback(toAPI(returnValue), error ? toAPI(API::Error::create().get()) : 0, context);
+        });
+    }
+};
+
+// FIXME: Make a version of GenericCallback with two arguments, and define ComputedPagesCallback as a specialization.
 class ComputedPagesCallback : public CallbackBase {
 public:
-    typedef void (*CallbackFunction)(const Vector<WebCore::IntRect>&, double, WKErrorRef, void*);
+    typedef std::function<void (bool, const Vector<WebCore::IntRect>&, double)> CallbackFunction;
 
-    static PassRefPtr<ComputedPagesCallback> create(void* context, CallbackFunction callback)
+    static PassRefPtr<ComputedPagesCallback> create(CallbackFunction callback)
     {
-        return adoptRef(new ComputedPagesCallback(context, callback));
+        return adoptRef(new ComputedPagesCallback(callback));
     }
 
     virtual ~ComputedPagesCallback()
@@ -171,7 +193,7 @@ public:
     {
         ASSERT(m_callback);
 
-        m_callback(returnValue1, returnValue2, 0, context());
+        m_callback(false, returnValue1, returnValue2);
 
         m_callback = 0;
     }
@@ -180,17 +202,15 @@ public:
     {
         ASSERT(m_callback);
 
-        RefPtr<API::Error> error = API::Error::create();
-        m_callback(Vector<WebCore::IntRect>(), 0, toAPI(error.get()), context());
+        m_callback(true, Vector<WebCore::IntRect>(), 0);
         
         m_callback = 0;
     }
 
 private:
 
-    ComputedPagesCallback(void* context, CallbackFunction callback)
-        : CallbackBase(context)
-        , m_callback(callback)
+    ComputedPagesCallback(CallbackFunction callback)
+        : m_callback(callback)
     {
     }
 
@@ -199,11 +219,11 @@ private:
 
 class ImageCallback : public CallbackBase {
 public:
-    typedef void (*CallbackFunction)(const ShareableBitmap::Handle&, WKErrorRef, void*);
+    typedef std::function<void (bool, const ShareableBitmap::Handle&)> CallbackFunction;
 
-    static PassRefPtr<ImageCallback> create(void* context, CallbackFunction callback)
+    static PassRefPtr<ImageCallback> create(CallbackFunction callback)
     {
-        return adoptRef(new ImageCallback(context, callback));
+        return adoptRef(new ImageCallback(callback));
     }
 
     virtual ~ImageCallback()
@@ -215,7 +235,7 @@ public:
     {
         ASSERT(m_callback);
 
-        m_callback(returnValue1, 0, context());
+        m_callback(true, returnValue1);
 
         m_callback = 0;
     }
@@ -226,16 +246,15 @@ public:
 
         RefPtr<API::Error> error = API::Error::create();
         ShareableBitmap::Handle handle;
-        m_callback(handle, toAPI(error.get()), context());
+        m_callback(false, handle);
 
         m_callback = 0;
     }
 
 private:
 
-    ImageCallback(void* context, CallbackFunction callback)
-        : CallbackBase(context)
-        , m_callback(callback)
+    ImageCallback(CallbackFunction callback)
+        : m_callback(callback)
     {
     }
     
index f6918f9..2fb0ab6 100644 (file)
@@ -39,7 +39,7 @@ namespace WebKit {
 class WebContext;
 class WebProcessProxy;
 
-typedef GenericCallback<WKArrayRef> ArrayCallback;
+typedef GenericCallback<API::Array*> ArrayCallback;
 
 class WebPluginSiteDataManager : public API::ObjectImpl<API::Object::Type::PluginSiteDataManager> {
 public:
index bf9c37b..02498e3 100644 (file)
@@ -35,7 +35,7 @@ namespace WebKit {
 
 struct StatisticsData;
 
-typedef GenericCallback<WKDictionaryRef> DictionaryCallback;
+typedef GenericCallback<ImmutableDictionary*> DictionaryCallback;
 
 enum StatisticsRequestType {
     StatisticsRequestTypeWebContent = 0x00000001,
index 824c211..8ecfb67 100644 (file)
@@ -43,7 +43,7 @@ namespace WebKit {
 class WebSecurityOrigin;
 struct SecurityOriginData;
 
-typedef GenericCallback<WKArrayRef> ArrayCallback;
+typedef GenericCallback<API::Array*> ArrayCallback;
 
 class WebApplicationCacheManagerProxy : public API::ObjectImpl<API::Object::Type::ApplicationCacheManager>, public WebContextSupplement, private IPC::MessageReceiver {
 public:
index 5f03c7f..86dd2d8 100644 (file)
@@ -80,7 +80,7 @@ struct StatisticsData;
 struct WebPageConfiguration;
 struct WebProcessCreationParameters;
     
-typedef GenericCallback<WKDictionaryRef> DictionaryCallback;
+typedef GenericCallback<ImmutableDictionary*> DictionaryCallback;
 
 #if ENABLE(NETWORK_INFO)
 class WebNetworkInfoManagerProxy;
index bc861b9..796c004 100644 (file)
@@ -48,8 +48,8 @@ namespace WebKit {
 class WebContext;
 class WebProcessProxy;
 
-typedef GenericCallback<WKArrayRef> ArrayCallback;
-typedef GenericCallback<WKHTTPCookieAcceptPolicy, HTTPCookieAcceptPolicy> HTTPCookieAcceptPolicyCallback;
+typedef GenericCallback<API::Array*> ArrayCallback;
+typedef GenericCallback<HTTPCookieAcceptPolicy> HTTPCookieAcceptPolicyCallback;
 
 class WebCookieManagerProxy : public API::ObjectImpl<API::Object::Type::CookieManager>, public WebContextSupplement, private IPC::MessageReceiver {
 public:
index b32f2ab..681630e 100644 (file)
@@ -44,7 +44,7 @@ class WebContext;
 class WebProcessProxy;
 class WebSecurityOrigin;
 
-typedef GenericCallback<WKArrayRef> ArrayCallback;
+typedef GenericCallback<API::Array*> ArrayCallback;
 
 class WebDatabaseManagerProxy : public API::ObjectImpl<API::Object::Type::DatabaseManager>, public WebContextSupplement, private IPC::MessageReceiver {
 public:
index d82decb..de16954 100644 (file)
@@ -50,7 +50,7 @@ class WebFormSubmissionListenerProxy;
 class WebFramePolicyListenerProxy;
 class WebPageProxy;
 
-typedef GenericCallback<WKDataRef> DataCallback;
+typedef GenericCallback<API::Data*> DataCallback;
 
 class WebFrameProxy : public API::ObjectImpl<API::Object::Type::Frame> {
 public:
index 4780470..8faf211 100644 (file)
@@ -36,7 +36,7 @@
 
 namespace WebKit {
 
-typedef GenericCallback<WKArrayRef> ArrayCallback;
+typedef GenericCallback<API::Array*> ArrayCallback;
 
 class WebKeyValueStorageManager : public API::ObjectImpl<API::Object::Type::KeyValueStorageManager>, public WebContextSupplement {
 public:
index 44f583b..7eba053 100644 (file)
@@ -39,7 +39,7 @@ namespace WebKit {
 class WebContext;
 class WebProcessProxy;
 
-typedef GenericCallback<WKArrayRef> ArrayCallback;
+typedef GenericCallback<API::Array*> ArrayCallback;
 
 class WebMediaCacheManagerProxy : public API::ObjectImpl<API::Object::Type::MediaCacheManager>, public WebContextSupplement, private IPC::MessageReceiver {
 public:
index c5709c8..9719a21 100644 (file)
@@ -45,7 +45,7 @@ namespace WebKit {
 class WebSecurityOrigin;
 struct SecurityOriginData;
 
-typedef GenericCallback<WKArrayRef> ArrayCallback;
+typedef GenericCallback<API::Array*> ArrayCallback;
 
 class WebOriginDataManagerProxy : public API::ObjectImpl<API::Object::Type::OriginDataManager>, public WebContextSupplement, private IPC::MessageReceiver {
 public:
index 9945b62..e25eef6 100644 (file)
@@ -166,11 +166,11 @@ struct WebPopupItem;
 class WebVibrationProxy;
 #endif
 
-typedef GenericCallback<WKStringRef, StringImpl*> StringCallback;
-typedef GenericCallback<WKSerializedScriptValueRef, WebSerializedScriptValue*> ScriptValueCallback;
+typedef GenericCallback<StringImpl*> StringCallback;
+typedef GenericCallback<WebSerializedScriptValue*> ScriptValueCallback;
 
 #if PLATFORM(GTK)
-typedef GenericCallback<WKErrorRef> PrintFinishedCallback;
+typedef GenericCallback<API::Error*> PrintFinishedCallback;
 #endif
 
 #if ENABLE(TOUCH_EVENTS)
@@ -187,11 +187,11 @@ struct QueuedTouchEvents {
 // FIXME: Make a version of CallbackBase with three arguments, and define ValidateCommandCallback as a specialization.
 class ValidateCommandCallback : public CallbackBase {
 public:
-    typedef void (*CallbackFunction)(WKStringRef, bool, int32_t, WKErrorRef, void*);
+    typedef std::function<void (bool, StringImpl*, bool, int32_t)> CallbackFunction;
 
-    static PassRefPtr<ValidateCommandCallback> create(void* context, CallbackFunction callback)
+    static PassRefPtr<ValidateCommandCallback> create(CallbackFunction callback)
     {
-        return adoptRef(new ValidateCommandCallback(context, callback));
+        return adoptRef(new ValidateCommandCallback(callback));
     }
 
     virtual ~ValidateCommandCallback()
@@ -203,7 +203,7 @@ public:
     {
         ASSERT(m_callback);
 
-        m_callback(toAPI(returnValue1), returnValue2, returnValue3, 0, context());
+        m_callback(false, returnValue1, returnValue2, returnValue3);
 
         m_callback = 0;
     }
@@ -212,17 +212,15 @@ public:
     {
         ASSERT(m_callback);
 
-        RefPtr<API::Error> error = API::Error::create();
-        m_callback(0, 0, 0, toAPI(error.get()), context());
+        m_callback(true, 0, 0, 0);
         
         m_callback = 0;
     }
 
 private:
 
-    ValidateCommandCallback(void* context, CallbackFunction callback)
-        : CallbackBase(context)
-        , m_callback(callback)
+    ValidateCommandCallback(CallbackFunction callback)
+        : m_callback(callback)
     {
     }
 
@@ -232,11 +230,11 @@ private:
 #if PLATFORM(IOS)
 class GestureCallback : public CallbackBase {
 public:
-    typedef void (*CallbackFunction)(const WebCore::IntPoint&, uint32_t, uint32_t, uint32_t, WKErrorRef, void*);
+    typedef std::function<void (bool, const WebCore::IntPoint&, uint32_t, uint32_t, uint32_t)> CallbackFunction;
 
-    static PassRefPtr<GestureCallback> create(void* context, CallbackFunction callback)
+    static PassRefPtr<GestureCallback> create(CallbackFunction callback)
     {
-        return adoptRef(new GestureCallback(context, callback));
+        return adoptRef(new GestureCallback(callback));
     }
 
     virtual ~GestureCallback()
@@ -248,7 +246,7 @@ public:
     {
         ASSERT(m_callback);
 
-        m_callback(returnValue1, returnValue2, returnValue3, returnValue4, 0, context());
+        m_callback(false, returnValue1, returnValue2, returnValue3, returnValue4);
 
         m_callback = 0;
     }
@@ -257,17 +255,15 @@ public:
     {
         ASSERT(m_callback);
 
-        RefPtr<API::Error> error = API::Error::create();
-        m_callback(WebCore::IntPoint(), 0, 0, 0, toAPI(error.get()), context());
+        m_callback(true, WebCore::IntPoint(), 0, 0, 0);
 
         m_callback = 0;
     }
 
 private:
 
-    GestureCallback(void* context, CallbackFunction callback)
-        : CallbackBase(context)
-        , m_callback(callback)
+    GestureCallback(CallbackFunction callback)
+        : m_callback(callback)
     {
         ASSERT(m_callback);
     }
@@ -277,11 +273,11 @@ private:
 
 class TouchesCallback : public CallbackBase {
 public:
-    typedef void (*CallbackFunction)(const WebCore::IntPoint&, uint32_t, WKErrorRef, void*);
+    typedef std::function<void(bool, const WebCore::IntPoint&, uint32_t)> CallbackFunction;
 
-    static PassRefPtr<TouchesCallback> create(void* context, CallbackFunction callback)
+    static PassRefPtr<TouchesCallback> create(CallbackFunction callback)
     {
-        return adoptRef(new TouchesCallback(context, callback));
+        return adoptRef(new TouchesCallback(callback));
     }
 
     virtual ~TouchesCallback()
@@ -293,7 +289,7 @@ public:
     {
         ASSERT(m_callback);
 
-        m_callback(returnValue1, returnValue2, 0, context());
+        m_callback(true, returnValue1, returnValue2);
 
         m_callback = 0;
     }
@@ -303,16 +299,15 @@ public:
         ASSERT(m_callback);
 
         RefPtr<API::Error> error = API::Error::create();
-        m_callback(WebCore::IntPoint(), 0, toAPI(error.get()), context());
+        m_callback(false, WebCore::IntPoint(), 0);
         
         m_callback = 0;
     }
     
 private:
     
-    TouchesCallback(void* context, CallbackFunction callback)
-        : CallbackBase(context)
-        , m_callback(callback)
+    TouchesCallback(CallbackFunction callback)
+        : m_callback(callback)
     {
         ASSERT(m_callback);
     }
index e3f520a..fa4335d 100644 (file)
@@ -42,7 +42,7 @@ class WebContext;
 class WebProcessProxy;
 class WebSecurityOrigin;
 
-typedef GenericCallback<WKArrayRef> ArrayCallback;
+typedef GenericCallback<API::Array*> ArrayCallback;
 
 class WebResourceCacheManagerProxy : public API::ObjectImpl<API::Object::Type::CacheManager>, public WebContextSupplement, private IPC::MessageReceiver {
 public:
index 5d3103b..ea22274 100644 (file)
@@ -367,8 +367,6 @@ static RetainPtr<CGImageRef> createImageWithCopiedData(CGImageRef sourceImage)
     [[self window] exitFullScreenMode:self];
 }
 
-static void completeFinishExitFullScreenAnimationAfterRepaint(WKErrorRef, void*);
-
 - (void)finishedExitFullScreenAnimation:(bool)completed
 {
     if (_fullScreenState != ExitingFullScreen)
@@ -411,7 +409,9 @@ static void completeFinishExitFullScreenAnimationAfterRepaint(WKErrorRef, void*)
         // clears _repaintCallback.
         ASSERT(!_repaintCallback);
     }
-    _repaintCallback = VoidCallback::create(self, completeFinishExitFullScreenAnimationAfterRepaint);
+    _repaintCallback = VoidCallback::create([self](bool) {
+        [self completeFinishExitFullScreenAnimationAfterRepaint];
+    });
     [self _page]->forceRepaint(_repaintCallback);
 }
 
@@ -423,11 +423,6 @@ static void completeFinishExitFullScreenAnimationAfterRepaint(WKErrorRef, void*)
     NSEnableScreenUpdates();
 }
 
-static void completeFinishExitFullScreenAnimationAfterRepaint(WKErrorRef, void* _self)
-{
-    [(WKFullScreenWindowController*)_self completeFinishExitFullScreenAnimationAfterRepaint];
-}
-
 - (void)performClose:(id)sender
 {
     if ([self isFullScreen])