Class WebKit.Webkit2AsyncToSync

java.lang.Object
org.eclipse.swt.browser.WebKit.Webkit2AsyncToSync
Enclosing class:
WebKit

private static class WebKit.Webkit2AsyncToSync extends Object
Webkit2 introduces async api. However SWT has sync execution model. This class it to convert async api to sync. Be careful about using these methods in synchronous callbacks from webkit, as those can cause deadlocks. (See inner javadocs). The mechanism generates an ID for each callback and waits for that callback to complete.
  • Field Details

    • cookieBrowser

      private static Browser cookieBrowser
      We need a way to associate a Browser instance with this class for cookie functionality
    • runjavascript_callback

      private static Callback runjavascript_callback
    • getText_callback

      private static Callback getText_callback
    • setCookie_callback

      private static Callback setCookie_callback
    • getCookie_callback

      private static Callback getCookie_callback
  • Constructor Details

    • Webkit2AsyncToSync

      private Webkit2AsyncToSync()
  • Method Details

    • evaluate

      static Object evaluate(String script, Browser browser, long webView)
    • runjavascript

      static Object runjavascript(String script, Browser browser, long webView)
      Run javascript, wait for a return value. Developer note: Be EXTRA careful with this method, it can cause deadlocks in situations where javascript is executed in a callback that provides a return value to webkit. In otherwords, if webkit does a sync callback (one that requires a return value), then running javascript will lead to a deadlock because webkit will not execute the javascript until it's sync callback finished. As a note, SWT's callback mechanism hard-codes 'long' return even when a callback is actually 'void'. So reference webkit callback signature documentation and not SWT implementation. If in doubt, you should use nonBlockingExecute() where possible :-).
    • gtk4_runjavascript_callback

      private static void gtk4_runjavascript_callback(long GObject_source, long GAsyncResult, long user_data)
    • gtk3_runjavascript_callback

      private static void gtk3_runjavascript_callback(long GObject_source, long GAsyncResult, long user_data)
    • getText

      static String getText(Browser browser, long webView)
    • getText_callback

      private static void getText_callback(long WebResource, long GAsyncResult, long user_data)
    • setCookieBrowser

      static void setCookieBrowser(Browser toSet)
      Associates a Browser instance with this class, mainly so we can get its Display and check for disposal.
      Parameters:
      toSet - the Browser instance to set
    • setCookie

      static boolean setCookie(String cookieUrl, String cookieValue)
    • setCookie_callback

      private static void setCookie_callback(long cookieManager, long result, long user_data)
    • getCookie

      static String getCookie(String cookieUrl, String cookieName)
    • getCookie_callback

      private static void getCookie_callback(long cookieManager, long result, long user_data)
    • execAsyncAndWaitForReturn

      private static WebKit.Webkit2AsyncToSync.Webkit2AsyncReturnObj execAsyncAndWaitForReturn(Browser browser, Consumer<Integer> asyncFunc, String additionalErrorInfo)
      You should check 'retObj.swtAsyncTimeout' after making a call to this.