1 /*
   2  * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
   3  */
   4 #include "config.h"
   5 
   6 #include <wtf/java/JavaEnv.h>
   7 #include <wtf/java/JavaRef.h>
   8 #include <wtf/MainThread.h>
   9 
  10 namespace WTF {
  11 void scheduleDispatchFunctionsOnMainThread()
  12 {
  13     AttachThreadAsNonDaemonToJavaEnv autoAttach;
  14     JNIEnv* env = autoAttach.env();
  15     static JGClass jMainThreadCls(env->FindClass("com/sun/webkit/MainThread"));
  16 
  17     static jmethodID mid = env->GetStaticMethodID(
  18             jMainThreadCls,
  19             "fwkScheduleDispatchFunctions",
  20             "()V");
  21 
  22     ASSERT(mid);
  23 
  24     env->CallStaticVoidMethod(jMainThreadCls, mid);
  25     CheckAndClearException(env);
  26 }
  27 
  28 void initializeMainThreadPlatform()
  29 {
  30 }
  31 
  32 extern "C" {
  33 
  34 /*
  35  * Class:     com_sun_webkit_MainThread
  36  * Method:    twkScheduleDispatchFunctions
  37  * Signature: ()V
  38  */
  39 JNIEXPORT void JNICALL Java_com_sun_webkit_MainThread_twkScheduleDispatchFunctions
  40   (JNIEnv*, jobject)
  41 {
  42     dispatchFunctionsFromMainThread();
  43 }
  44 }
  45 
  46 } // namespace WTF