class_reference_holder.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. /*
  2. * Copyright 2015 The WebRTC project authors. All Rights Reserved.
  3. *
  4. * Use of this source code is governed by a BSD-style license
  5. * that can be found in the LICENSE file in the root of the source
  6. * tree. An additional intellectual property rights grant can be found
  7. * in the file PATENTS. All contributing project authors may
  8. * be found in the AUTHORS file in the root of the source tree.
  9. */
  10. // This is a supplement of webrtc::jni::ClassReferenceHolder.
  11. // The purpose of this ClassReferenceHolder is to load the example
  12. // specific java class into JNI c++ side, so that our c++ code can
  13. // call those java functions.
  14. #ifndef EXAMPLES_UNITYPLUGIN_CLASS_REFERENCE_HOLDER_H_
  15. #define EXAMPLES_UNITYPLUGIN_CLASS_REFERENCE_HOLDER_H_
  16. #include <jni.h>
  17. #include <map>
  18. #include <string>
  19. #include <vector>
  20. namespace unity_plugin {
  21. // LoadGlobalClassReferenceHolder must be called in JNI_OnLoad.
  22. void LoadGlobalClassReferenceHolder();
  23. // FreeGlobalClassReferenceHolder must be called in JNI_UnLoad.
  24. void FreeGlobalClassReferenceHolder();
  25. // Returns a global reference guaranteed to be valid for the lifetime of the
  26. // process.
  27. jclass FindClass(JNIEnv* jni, const char* name);
  28. } // namespace unity_plugin
  29. #endif // EXAMPLES_UNITYPLUGIN_CLASS_REFERENCE_HOLDER_H_