Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(142)

Unified Diff: base/android/jni_generator/testJNIAdditionalImport.golden

Issue 290403002: Adding JNIAdditionalImport annotation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Follow review Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/android/jni_generator/jni_generator_tests.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/android/jni_generator/testJNIAdditionalImport.golden
diff --git a/base/android/jni_generator/testJNIAdditionalImport.golden b/base/android/jni_generator/testJNIAdditionalImport.golden
new file mode 100644
index 0000000000000000000000000000000000000000..e395657cf79bfc5b48642d54426b2d83a72c33c3
--- /dev/null
+++ b/base/android/jni_generator/testJNIAdditionalImport.golden
@@ -0,0 +1,82 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// This file is autogenerated by
+// base/android/jni_generator/jni_generator.py
+// For
+// org/chromium/foo/Foo
+
+#ifndef org_chromium_foo_Foo_JNI
+#define org_chromium_foo_Foo_JNI
+
+#include <jni.h>
+
+#include "base/android/jni_generator/jni_generator_helper.h"
+
+#include "base/android/jni_int_wrapper.h"
+
+// Step 1: forward declarations.
+namespace {
+const char kFooClassPath[] = "org/chromium/foo/Foo";
+// Leaking this jclass as we cannot use LazyInstance from some threads.
+jclass g_Foo_clazz = NULL;
+
+} // namespace
+
+static void DoSomething(JNIEnv* env, jclass jcaller,
+ jobject callback);
+
+// Step 2: method stubs.
+
+static base::subtle::AtomicWord g_Foo_calledByNative = 0;
+static void Java_Foo_calledByNative(JNIEnv* env, jobject callback) {
+ /* Must call RegisterNativesImpl() */
+ CHECK_CLAZZ(env, g_Foo_clazz,
+ g_Foo_clazz);
+ jmethodID method_id =
+ base::android::MethodID::LazyGet<
+ base::android::MethodID::TYPE_STATIC>(
+ env, g_Foo_clazz,
+ "calledByNative",
+
+"("
+"Lorg/chromium/foo/Bar$Callback;"
+")"
+"V",
+ &g_Foo_calledByNative);
+
+ env->CallStaticVoidMethod(g_Foo_clazz,
+ method_id, callback);
+ jni_generator::CheckException(env);
+
+}
+
+// Step 3: RegisterNatives.
+
+static const JNINativeMethod kMethodsFoo[] = {
+ { "nativeDoSomething",
+"("
+"Lorg/chromium/foo/Bar$Callback;"
+")"
+"V", reinterpret_cast<void*>(DoSomething) },
+};
+
+static bool RegisterNativesImpl(JNIEnv* env) {
+ g_Foo_clazz = reinterpret_cast<jclass>(env->NewGlobalRef(
+ base::android::GetClass(env, kFooClassPath).obj()));
+
+ const int kMethodsFooSize = arraysize(kMethodsFoo);
+
+ if (env->RegisterNatives(g_Foo_clazz,
+ kMethodsFoo,
+ kMethodsFooSize) < 0) {
+ jni_generator::HandleRegistrationError(
+ env, g_Foo_clazz, __FILE__);
+ return false;
+ }
+
+ return true;
+}
+
+#endif // org_chromium_foo_Foo_JNI
« no previous file with comments | « base/android/jni_generator/jni_generator_tests.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698