OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # | 2 # |
3 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 3 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 | 6 |
7 """Tests for jni_generator.py. | 7 """Tests for jni_generator.py. |
8 | 8 |
9 This test suite contains various tests for the JNI generator. | 9 This test suite contains various tests for the JNI generator. |
10 It exercises the low-level parser all the way up to the | 10 It exercises the low-level parser all the way up to the |
(...skipping 29 matching lines...) Expand all Loading... |
40 else: | 40 else: |
41 self.assertEquals(first[i], second[i]) | 41 self.assertEquals(first[i], second[i]) |
42 | 42 |
43 def assertTextEquals(self, golden_text, generated_text): | 43 def assertTextEquals(self, golden_text, generated_text): |
44 stripped_golden = [l.strip() for l in golden_text.split('\n')] | 44 stripped_golden = [l.strip() for l in golden_text.split('\n')] |
45 stripped_generated = [l.strip() for l in generated_text.split('\n')] | 45 stripped_generated = [l.strip() for l in generated_text.split('\n')] |
46 if stripped_golden != stripped_generated: | 46 if stripped_golden != stripped_generated: |
47 print self.id() | 47 print self.id() |
48 for line in difflib.context_diff(stripped_golden, stripped_generated): | 48 for line in difflib.context_diff(stripped_golden, stripped_generated): |
49 print line | 49 print line |
| 50 print '\n\nGenerated' |
| 51 print '=' * 80 |
| 52 print generated_text |
| 53 print '=' * 80 |
50 self.fail('Golden text mismatch') | 54 self.fail('Golden text mismatch') |
51 | 55 |
52 def testNatives(self): | 56 def testNatives(self): |
53 test_data = """" | 57 test_data = """" |
54 private native int nativeInit(); | 58 private native int nativeInit(); |
55 private native void nativeDestroy(int nativeChromeBrowserProvider); | 59 private native void nativeDestroy(int nativeChromeBrowserProvider); |
56 private native long nativeAddBookmark( | 60 private native long nativeAddBookmark( |
57 int nativeChromeBrowserProvider, | 61 int nativeChromeBrowserProvider, |
58 String url, String title, boolean isFolder, long parentId); | 62 String url, String title, boolean isFolder, long parentId); |
59 private static native String nativeGetDomainAndRegistry(String url); | 63 private static native String nativeGetDomainAndRegistry(String url); |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 | 224 |
221 #include "base/android/jni_android.h" | 225 #include "base/android/jni_android.h" |
222 #include "base/android/scoped_java_ref.h" | 226 #include "base/android/scoped_java_ref.h" |
223 #include "base/basictypes.h" | 227 #include "base/basictypes.h" |
224 #include "base/logging.h" | 228 #include "base/logging.h" |
225 | 229 |
226 using base::android::ScopedJavaLocalRef; | 230 using base::android::ScopedJavaLocalRef; |
227 | 231 |
228 // Step 1: forward declarations. | 232 // Step 1: forward declarations. |
229 namespace { | 233 namespace { |
230 const char* const kTestJniClassPath = "org/chromium/TestJni"; | 234 static const char kTestJniClassPath[] = "org/chromium/TestJni"; |
231 // Leaking this JavaRef as we cannot use LazyInstance from some threads. | 235 // Leaking this jclass as we cannot use LazyInstance from some threads. |
232 base::android::ScopedJavaGlobalRef<jclass>& | 236 jclass g_TestJni_clazz = NULL; |
233 g_TestJni_clazz = | |
234 *(new base::android::ScopedJavaGlobalRef<jclass>()); | |
235 } // namespace | 237 } // namespace |
236 | 238 |
237 static jint Init(JNIEnv* env, jobject obj); | 239 static jint Init(JNIEnv* env, jobject obj); |
238 | 240 |
239 | 241 |
240 static jstring GetDomainAndRegistry(JNIEnv* env, jclass clazz, | 242 static jstring GetDomainAndRegistry(JNIEnv* env, jclass clazz, |
241 jstring url); | 243 jstring url); |
242 | 244 |
243 | 245 |
244 static void CreateHistoricalTabFromState(JNIEnv* env, jclass clazz, | 246 static void CreateHistoricalTabFromState(JNIEnv* env, jclass clazz, |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 device_orientation::DeviceOrientationAndroid* native = | 326 device_orientation::DeviceOrientationAndroid* native = |
325 reinterpret_cast<device_orientation::DeviceOrientationAndroid*>(nativePtr); | 327 reinterpret_cast<device_orientation::DeviceOrientationAndroid*>(nativePtr); |
326 return native->GotOrientation(env, obj, alpha, beta, gamma); | 328 return native->GotOrientation(env, obj, alpha, beta, gamma); |
327 } | 329 } |
328 | 330 |
329 | 331 |
330 // Step 3: GetMethodIDs and RegisterNatives. | 332 // Step 3: GetMethodIDs and RegisterNatives. |
331 | 333 |
332 | 334 |
333 static void GetMethodIDsImpl(JNIEnv* env) { | 335 static void GetMethodIDsImpl(JNIEnv* env) { |
334 g_TestJni_clazz.Reset( | 336 g_TestJni_clazz = reinterpret_cast<jclass>(env->NewGlobalRef( |
335 base::android::GetClass(env, kTestJniClassPath)); | 337 base::android::GetUnscopedClass(env, kTestJniClassPath))); |
336 } | 338 } |
337 | 339 |
338 static bool RegisterNativesImpl(JNIEnv* env) { | 340 static bool RegisterNativesImpl(JNIEnv* env) { |
339 GetMethodIDsImpl(env); | 341 GetMethodIDsImpl(env); |
340 | 342 |
341 static const JNINativeMethod kMethodsTestJni[] = { | 343 static const JNINativeMethod kMethodsTestJni[] = { |
342 { "nativeInit", | 344 { "nativeInit", |
343 "(" | 345 "(" |
344 ")" | 346 ")" |
345 "I", reinterpret_cast<void*>(Init) }, | 347 "I", reinterpret_cast<void*>(Init) }, |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 "(" | 421 "(" |
420 "I" | 422 "I" |
421 "D" | 423 "D" |
422 "D" | 424 "D" |
423 "D" | 425 "D" |
424 ")" | 426 ")" |
425 "V", reinterpret_cast<void*>(GotOrientation) }, | 427 "V", reinterpret_cast<void*>(GotOrientation) }, |
426 }; | 428 }; |
427 const int kMethodsTestJniSize = arraysize(kMethodsTestJni); | 429 const int kMethodsTestJniSize = arraysize(kMethodsTestJni); |
428 | 430 |
429 if (env->RegisterNatives(g_TestJni_clazz.obj(), | 431 if (env->RegisterNatives(g_TestJni_clazz, |
430 kMethodsTestJni, | 432 kMethodsTestJni, |
431 kMethodsTestJniSize) < 0) { | 433 kMethodsTestJniSize) < 0) { |
432 LOG(ERROR) << "RegisterNatives failed in " << __FILE__; | 434 LOG(ERROR) << "RegisterNatives failed in " << __FILE__; |
433 return false; | 435 return false; |
434 } | 436 } |
435 | 437 |
436 return true; | 438 return true; |
437 } | 439 } |
438 | 440 |
439 #endif // org_chromium_TestJni_JNI | 441 #endif // org_chromium_TestJni_JNI |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
475 | 477 |
476 #include "base/android/jni_android.h" | 478 #include "base/android/jni_android.h" |
477 #include "base/android/scoped_java_ref.h" | 479 #include "base/android/scoped_java_ref.h" |
478 #include "base/basictypes.h" | 480 #include "base/basictypes.h" |
479 #include "base/logging.h" | 481 #include "base/logging.h" |
480 | 482 |
481 using base::android::ScopedJavaLocalRef; | 483 using base::android::ScopedJavaLocalRef; |
482 | 484 |
483 // Step 1: forward declarations. | 485 // Step 1: forward declarations. |
484 namespace { | 486 namespace { |
485 const char* const kTestJniClassPath = "org/chromium/TestJni"; | 487 static const char kTestJniClassPath[] = "org/chromium/TestJni"; |
486 const char* const kMyInnerClassClassPath = "org/chromium/TestJni$MyInnerClass"; | 488 static const char kMyInnerClassClassPath[] = |
487 // Leaking this JavaRef as we cannot use LazyInstance from some threads. | 489 "org/chromium/TestJni$MyInnerClass"; |
488 base::android::ScopedJavaGlobalRef<jclass>& | 490 // Leaking this jclass as we cannot use LazyInstance from some threads. |
489 g_TestJni_clazz = | 491 jclass g_TestJni_clazz = NULL; |
490 *(new base::android::ScopedJavaGlobalRef<jclass>()); | |
491 } // namespace | 492 } // namespace |
492 | 493 |
493 static jint Init(JNIEnv* env, jobject obj); | 494 static jint Init(JNIEnv* env, jobject obj); |
494 | 495 |
495 | 496 |
496 // Step 2: method stubs. | 497 // Step 2: method stubs. |
497 | 498 |
498 | 499 |
499 // Step 3: GetMethodIDs and RegisterNatives. | 500 // Step 3: GetMethodIDs and RegisterNatives. |
500 | 501 |
501 | 502 |
502 static void GetMethodIDsImpl(JNIEnv* env) { | 503 static void GetMethodIDsImpl(JNIEnv* env) { |
503 g_TestJni_clazz.Reset( | 504 g_TestJni_clazz = reinterpret_cast<jclass>(env->NewGlobalRef( |
504 base::android::GetClass(env, kTestJniClassPath)); | 505 base::android::GetUnscopedClass(env, kTestJniClassPath))); |
505 } | 506 } |
506 | 507 |
507 static bool RegisterNativesImpl(JNIEnv* env) { | 508 static bool RegisterNativesImpl(JNIEnv* env) { |
508 GetMethodIDsImpl(env); | 509 GetMethodIDsImpl(env); |
509 | 510 |
510 static const JNINativeMethod kMethodsMyInnerClass[] = { | 511 static const JNINativeMethod kMethodsMyInnerClass[] = { |
511 { "nativeInit", | 512 { "nativeInit", |
512 "(" | 513 "(" |
513 ")" | 514 ")" |
514 "I", reinterpret_cast<void*>(Init) }, | 515 "I", reinterpret_cast<void*>(Init) }, |
515 }; | 516 }; |
516 const int kMethodsMyInnerClassSize = arraysize(kMethodsMyInnerClass); | 517 const int kMethodsMyInnerClassSize = arraysize(kMethodsMyInnerClass); |
517 | 518 |
518 if (env->RegisterNatives(g_MyInnerClass_clazz.obj(), | 519 if (env->RegisterNatives(g_MyInnerClass_clazz, |
519 kMethodsMyInnerClass, | 520 kMethodsMyInnerClass, |
520 kMethodsMyInnerClassSize) < 0) { | 521 kMethodsMyInnerClassSize) < 0) { |
521 LOG(ERROR) << "RegisterNatives failed in " << __FILE__; | 522 LOG(ERROR) << "RegisterNatives failed in " << __FILE__; |
522 return false; | 523 return false; |
523 } | 524 } |
524 | 525 |
525 return true; | 526 return true; |
526 } | 527 } |
527 | 528 |
528 #endif // org_chromium_TestJni_JNI | 529 #endif // org_chromium_TestJni_JNI |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
572 | 573 |
573 #include "base/android/jni_android.h" | 574 #include "base/android/jni_android.h" |
574 #include "base/android/scoped_java_ref.h" | 575 #include "base/android/scoped_java_ref.h" |
575 #include "base/basictypes.h" | 576 #include "base/basictypes.h" |
576 #include "base/logging.h" | 577 #include "base/logging.h" |
577 | 578 |
578 using base::android::ScopedJavaLocalRef; | 579 using base::android::ScopedJavaLocalRef; |
579 | 580 |
580 // Step 1: forward declarations. | 581 // Step 1: forward declarations. |
581 namespace { | 582 namespace { |
582 const char* const kMyOtherInnerClassClassPath = | 583 static const char kMyOtherInnerClassClassPath[] = |
583 "org/chromium/TestJni$MyOtherInnerClass"; | 584 "org/chromium/TestJni$MyOtherInnerClass"; |
584 const char* const kTestJniClassPath = "org/chromium/TestJni"; | 585 static const char kTestJniClassPath[] = "org/chromium/TestJni"; |
585 const char* const kMyInnerClassClassPath = "org/chromium/TestJni$MyInnerClass"; | 586 static const char kMyInnerClassClassPath[] = |
586 // Leaking this JavaRef as we cannot use LazyInstance from some threads. | 587 "org/chromium/TestJni$MyInnerClass"; |
587 base::android::ScopedJavaGlobalRef<jclass>& | 588 // Leaking this jclass as we cannot use LazyInstance from some threads. |
588 g_TestJni_clazz = | 589 jclass g_TestJni_clazz = NULL; |
589 *(new base::android::ScopedJavaGlobalRef<jclass>()); | |
590 } // namespace | 590 } // namespace |
591 | 591 |
592 static jint Init(JNIEnv* env, jobject obj); | 592 static jint Init(JNIEnv* env, jobject obj); |
593 | 593 |
594 | 594 |
595 static jint Init(JNIEnv* env, jobject obj); | 595 static jint Init(JNIEnv* env, jobject obj); |
596 | 596 |
597 | 597 |
598 // Step 2: method stubs. | 598 // Step 2: method stubs. |
599 | 599 |
600 | 600 |
601 // Step 3: GetMethodIDs and RegisterNatives. | 601 // Step 3: GetMethodIDs and RegisterNatives. |
602 | 602 |
603 | 603 |
604 static void GetMethodIDsImpl(JNIEnv* env) { | 604 static void GetMethodIDsImpl(JNIEnv* env) { |
605 g_TestJni_clazz.Reset( | 605 g_TestJni_clazz = reinterpret_cast<jclass>(env->NewGlobalRef( |
606 base::android::GetClass(env, kTestJniClassPath)); | 606 base::android::GetUnscopedClass(env, kTestJniClassPath))); |
607 } | 607 } |
608 | 608 |
609 static bool RegisterNativesImpl(JNIEnv* env) { | 609 static bool RegisterNativesImpl(JNIEnv* env) { |
610 GetMethodIDsImpl(env); | 610 GetMethodIDsImpl(env); |
611 | 611 |
612 static const JNINativeMethod kMethodsMyOtherInnerClass[] = { | 612 static const JNINativeMethod kMethodsMyOtherInnerClass[] = { |
613 { "nativeInit", | 613 { "nativeInit", |
614 "(" | 614 "(" |
615 ")" | 615 ")" |
616 "I", reinterpret_cast<void*>(Init) }, | 616 "I", reinterpret_cast<void*>(Init) }, |
617 }; | 617 }; |
618 const int kMethodsMyOtherInnerClassSize = | 618 const int kMethodsMyOtherInnerClassSize = |
619 arraysize(kMethodsMyOtherInnerClass); | 619 arraysize(kMethodsMyOtherInnerClass); |
620 | 620 |
621 if (env->RegisterNatives(g_MyOtherInnerClass_clazz.obj(), | 621 if (env->RegisterNatives(g_MyOtherInnerClass_clazz, |
622 kMethodsMyOtherInnerClass, | 622 kMethodsMyOtherInnerClass, |
623 kMethodsMyOtherInnerClassSize) < 0) { | 623 kMethodsMyOtherInnerClassSize) < 0) { |
624 LOG(ERROR) << "RegisterNatives failed in " << __FILE__; | 624 LOG(ERROR) << "RegisterNatives failed in " << __FILE__; |
625 return false; | 625 return false; |
626 } | 626 } |
627 | 627 |
628 static const JNINativeMethod kMethodsMyInnerClass[] = { | 628 static const JNINativeMethod kMethodsMyInnerClass[] = { |
629 { "nativeInit", | 629 { "nativeInit", |
630 "(" | 630 "(" |
631 ")" | 631 ")" |
632 "I", reinterpret_cast<void*>(Init) }, | 632 "I", reinterpret_cast<void*>(Init) }, |
633 }; | 633 }; |
634 const int kMethodsMyInnerClassSize = arraysize(kMethodsMyInnerClass); | 634 const int kMethodsMyInnerClassSize = arraysize(kMethodsMyInnerClass); |
635 | 635 |
636 if (env->RegisterNatives(g_MyInnerClass_clazz.obj(), | 636 if (env->RegisterNatives(g_MyInnerClass_clazz, |
637 kMethodsMyInnerClass, | 637 kMethodsMyInnerClass, |
638 kMethodsMyInnerClassSize) < 0) { | 638 kMethodsMyInnerClassSize) < 0) { |
639 LOG(ERROR) << "RegisterNatives failed in " << __FILE__; | 639 LOG(ERROR) << "RegisterNatives failed in " << __FILE__; |
640 return false; | 640 return false; |
641 } | 641 } |
642 | 642 |
643 return true; | 643 return true; |
644 } | 644 } |
645 | 645 |
646 #endif // org_chromium_TestJni_JNI | 646 #endif // org_chromium_TestJni_JNI |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
689 | 689 |
690 #include "base/android/jni_android.h" | 690 #include "base/android/jni_android.h" |
691 #include "base/android/scoped_java_ref.h" | 691 #include "base/android/scoped_java_ref.h" |
692 #include "base/basictypes.h" | 692 #include "base/basictypes.h" |
693 #include "base/logging.h" | 693 #include "base/logging.h" |
694 | 694 |
695 using base::android::ScopedJavaLocalRef; | 695 using base::android::ScopedJavaLocalRef; |
696 | 696 |
697 // Step 1: forward declarations. | 697 // Step 1: forward declarations. |
698 namespace { | 698 namespace { |
699 const char* const kMyOtherInnerClassClassPath = | 699 static const char kMyOtherInnerClassClassPath[] = |
700 "org/chromium/TestJni$MyOtherInnerClass"; | 700 "org/chromium/TestJni$MyOtherInnerClass"; |
701 const char* const kTestJniClassPath = "org/chromium/TestJni"; | 701 static const char kTestJniClassPath[] = "org/chromium/TestJni"; |
702 // Leaking this JavaRef as we cannot use LazyInstance from some threads. | 702 // Leaking this jclass as we cannot use LazyInstance from some threads. |
703 base::android::ScopedJavaGlobalRef<jclass>& | 703 jclass g_TestJni_clazz = NULL; |
704 g_TestJni_clazz = | |
705 *(new base::android::ScopedJavaGlobalRef<jclass>()); | |
706 } // namespace | 704 } // namespace |
707 | 705 |
708 static jint Init(JNIEnv* env, jobject obj); | 706 static jint Init(JNIEnv* env, jobject obj); |
709 | 707 |
710 | 708 |
711 static jint Init(JNIEnv* env, jobject obj); | 709 static jint Init(JNIEnv* env, jobject obj); |
712 | 710 |
713 | 711 |
714 // Step 2: method stubs. | 712 // Step 2: method stubs. |
715 | 713 |
716 | 714 |
717 // Step 3: GetMethodIDs and RegisterNatives. | 715 // Step 3: GetMethodIDs and RegisterNatives. |
718 | 716 |
719 | 717 |
720 static void GetMethodIDsImpl(JNIEnv* env) { | 718 static void GetMethodIDsImpl(JNIEnv* env) { |
721 g_TestJni_clazz.Reset( | 719 g_TestJni_clazz = reinterpret_cast<jclass>(env->NewGlobalRef( |
722 base::android::GetClass(env, kTestJniClassPath)); | 720 base::android::GetUnscopedClass(env, kTestJniClassPath))); |
723 } | 721 } |
724 | 722 |
725 static bool RegisterNativesImpl(JNIEnv* env) { | 723 static bool RegisterNativesImpl(JNIEnv* env) { |
726 GetMethodIDsImpl(env); | 724 GetMethodIDsImpl(env); |
727 | 725 |
728 static const JNINativeMethod kMethodsMyOtherInnerClass[] = { | 726 static const JNINativeMethod kMethodsMyOtherInnerClass[] = { |
729 { "nativeInit", | 727 { "nativeInit", |
730 "(" | 728 "(" |
731 ")" | 729 ")" |
732 "I", reinterpret_cast<void*>(Init) }, | 730 "I", reinterpret_cast<void*>(Init) }, |
733 }; | 731 }; |
734 const int kMethodsMyOtherInnerClassSize = | 732 const int kMethodsMyOtherInnerClassSize = |
735 arraysize(kMethodsMyOtherInnerClass); | 733 arraysize(kMethodsMyOtherInnerClass); |
736 | 734 |
737 if (env->RegisterNatives(g_MyOtherInnerClass_clazz.obj(), | 735 if (env->RegisterNatives(g_MyOtherInnerClass_clazz, |
738 kMethodsMyOtherInnerClass, | 736 kMethodsMyOtherInnerClass, |
739 kMethodsMyOtherInnerClassSize) < 0) { | 737 kMethodsMyOtherInnerClassSize) < 0) { |
740 LOG(ERROR) << "RegisterNatives failed in " << __FILE__; | 738 LOG(ERROR) << "RegisterNatives failed in " << __FILE__; |
741 return false; | 739 return false; |
742 } | 740 } |
743 | 741 |
744 static const JNINativeMethod kMethodsTestJni[] = { | 742 static const JNINativeMethod kMethodsTestJni[] = { |
745 { "nativeInit", | 743 { "nativeInit", |
746 "(" | 744 "(" |
747 ")" | 745 ")" |
748 "I", reinterpret_cast<void*>(Init) }, | 746 "I", reinterpret_cast<void*>(Init) }, |
749 }; | 747 }; |
750 const int kMethodsTestJniSize = arraysize(kMethodsTestJni); | 748 const int kMethodsTestJniSize = arraysize(kMethodsTestJni); |
751 | 749 |
752 if (env->RegisterNatives(g_TestJni_clazz.obj(), | 750 if (env->RegisterNatives(g_TestJni_clazz, |
753 kMethodsTestJni, | 751 kMethodsTestJni, |
754 kMethodsTestJniSize) < 0) { | 752 kMethodsTestJniSize) < 0) { |
755 LOG(ERROR) << "RegisterNatives failed in " << __FILE__; | 753 LOG(ERROR) << "RegisterNatives failed in " << __FILE__; |
756 return false; | 754 return false; |
757 } | 755 } |
758 | 756 |
759 return true; | 757 return true; |
760 } | 758 } |
761 | 759 |
762 #endif // org_chromium_TestJni_JNI | 760 #endif // org_chromium_TestJni_JNI |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
927 | 925 |
928 #include "base/android/jni_android.h" | 926 #include "base/android/jni_android.h" |
929 #include "base/android/scoped_java_ref.h" | 927 #include "base/android/scoped_java_ref.h" |
930 #include "base/basictypes.h" | 928 #include "base/basictypes.h" |
931 #include "base/logging.h" | 929 #include "base/logging.h" |
932 | 930 |
933 using base::android::ScopedJavaLocalRef; | 931 using base::android::ScopedJavaLocalRef; |
934 | 932 |
935 // Step 1: forward declarations. | 933 // Step 1: forward declarations. |
936 namespace { | 934 namespace { |
937 const char* const kTestJniClassPath = "org/chromium/TestJni"; | 935 static const char kTestJniClassPath[] = "org/chromium/TestJni"; |
938 const char* const kInfoBarClassPath = "org/chromium/TestJni$InfoBar"; | 936 static const char kInfoBarClassPath[] = "org/chromium/TestJni$InfoBar"; |
939 // Leaking this JavaRef as we cannot use LazyInstance from some threads. | 937 // Leaking this jclass as we cannot use LazyInstance from some threads. |
940 base::android::ScopedJavaGlobalRef<jclass>& | 938 jclass g_TestJni_clazz = NULL; |
941 g_TestJni_clazz = | 939 // Leaking this jclass as we cannot use LazyInstance from some threads. |
942 *(new base::android::ScopedJavaGlobalRef<jclass>()); | 940 jclass g_InfoBar_clazz = NULL; |
943 // Leaking this JavaRef as we cannot use LazyInstance from some threads. | |
944 base::android::ScopedJavaGlobalRef<jclass>& | |
945 g_InfoBar_clazz = | |
946 *(new base::android::ScopedJavaGlobalRef<jclass>()); | |
947 } // namespace | 941 } // namespace |
948 | 942 |
949 | 943 |
950 // Step 2: method stubs. | 944 // Step 2: method stubs. |
951 | 945 |
952 static jmethodID g_TestJni_showConfirmInfoBar = 0; | 946 static jmethodID g_TestJni_showConfirmInfoBar = 0; |
953 static ScopedJavaLocalRef<jobject> Java_TestJni_showConfirmInfoBar(JNIEnv* env, | 947 static ScopedJavaLocalRef<jobject> Java_TestJni_showConfirmInfoBar(JNIEnv* env, |
954 jobject obj, jint nativeInfoBar, | 948 jobject obj, jint nativeInfoBar, |
955 jstring buttonOk, | 949 jstring buttonOk, |
956 jstring buttonCancel, | 950 jstring buttonCancel, |
957 jstring title, | 951 jstring title, |
958 jobject icon) { | 952 jobject icon) { |
959 /* Must call RegisterNativesImpl() */ | 953 /* Must call RegisterNativesImpl() */ |
960 DCHECK(!g_TestJni_clazz.is_null()); | 954 DCHECK(g_TestJni_clazz); |
961 DCHECK(g_TestJni_showConfirmInfoBar); | 955 DCHECK(g_TestJni_showConfirmInfoBar); |
962 jobject ret = | 956 jobject ret = |
963 env->CallObjectMethod(obj, | 957 env->CallObjectMethod(obj, |
964 g_TestJni_showConfirmInfoBar, nativeInfoBar, buttonOk, buttonCancel, | 958 g_TestJni_showConfirmInfoBar, nativeInfoBar, buttonOk, buttonCancel, |
965 title, icon); | 959 title, icon); |
966 base::android::CheckException(env); | 960 base::android::CheckException(env); |
967 return ScopedJavaLocalRef<jobject>(env, ret); | 961 return ScopedJavaLocalRef<jobject>(env, ret); |
968 } | 962 } |
969 | 963 |
970 static jmethodID g_TestJni_showAutoLoginInfoBar = 0; | 964 static jmethodID g_TestJni_showAutoLoginInfoBar = 0; |
971 static ScopedJavaLocalRef<jobject> Java_TestJni_showAutoLoginInfoBar(JNIEnv* | 965 static ScopedJavaLocalRef<jobject> Java_TestJni_showAutoLoginInfoBar(JNIEnv* |
972 env, jobject obj, jint nativeInfoBar, | 966 env, jobject obj, jint nativeInfoBar, |
973 jstring realm, | 967 jstring realm, |
974 jstring account, | 968 jstring account, |
975 jstring args) { | 969 jstring args) { |
976 /* Must call RegisterNativesImpl() */ | 970 /* Must call RegisterNativesImpl() */ |
977 DCHECK(!g_TestJni_clazz.is_null()); | 971 DCHECK(g_TestJni_clazz); |
978 DCHECK(g_TestJni_showAutoLoginInfoBar); | 972 DCHECK(g_TestJni_showAutoLoginInfoBar); |
979 jobject ret = | 973 jobject ret = |
980 env->CallObjectMethod(obj, | 974 env->CallObjectMethod(obj, |
981 g_TestJni_showAutoLoginInfoBar, nativeInfoBar, realm, account, args); | 975 g_TestJni_showAutoLoginInfoBar, nativeInfoBar, realm, account, args); |
982 base::android::CheckException(env); | 976 base::android::CheckException(env); |
983 return ScopedJavaLocalRef<jobject>(env, ret); | 977 return ScopedJavaLocalRef<jobject>(env, ret); |
984 } | 978 } |
985 | 979 |
986 static jmethodID g_InfoBar_dismiss = 0; | 980 static jmethodID g_InfoBar_dismiss = 0; |
987 static void Java_InfoBar_dismiss(JNIEnv* env, jobject obj) { | 981 static void Java_InfoBar_dismiss(JNIEnv* env, jobject obj) { |
988 /* Must call RegisterNativesImpl() */ | 982 /* Must call RegisterNativesImpl() */ |
989 DCHECK(!g_InfoBar_clazz.is_null()); | 983 DCHECK(g_InfoBar_clazz); |
990 DCHECK(g_InfoBar_dismiss); | 984 DCHECK(g_InfoBar_dismiss); |
991 | 985 |
992 env->CallVoidMethod(obj, | 986 env->CallVoidMethod(obj, |
993 g_InfoBar_dismiss); | 987 g_InfoBar_dismiss); |
994 base::android::CheckException(env); | 988 base::android::CheckException(env); |
995 | 989 |
996 } | 990 } |
997 | 991 |
998 static jmethodID g_TestJni_shouldShowAutoLogin = 0; | 992 static jmethodID g_TestJni_shouldShowAutoLogin = 0; |
999 static jboolean Java_TestJni_shouldShowAutoLogin(JNIEnv* env, jobject | 993 static jboolean Java_TestJni_shouldShowAutoLogin(JNIEnv* env, jobject |
1000 chromeView, | 994 chromeView, |
1001 jstring realm, | 995 jstring realm, |
1002 jstring account, | 996 jstring account, |
1003 jstring args) { | 997 jstring args) { |
1004 /* Must call RegisterNativesImpl() */ | 998 /* Must call RegisterNativesImpl() */ |
1005 DCHECK(!g_TestJni_clazz.is_null()); | 999 DCHECK(g_TestJni_clazz); |
1006 DCHECK(g_TestJni_shouldShowAutoLogin); | 1000 DCHECK(g_TestJni_shouldShowAutoLogin); |
1007 jboolean ret = | 1001 jboolean ret = |
1008 env->CallStaticBooleanMethod(g_TestJni_clazz.obj(), | 1002 env->CallStaticBooleanMethod(g_TestJni_clazz, |
1009 g_TestJni_shouldShowAutoLogin, chromeView, realm, account, args); | 1003 g_TestJni_shouldShowAutoLogin, chromeView, realm, account, args); |
1010 base::android::CheckException(env); | 1004 base::android::CheckException(env); |
1011 return ret; | 1005 return ret; |
1012 } | 1006 } |
1013 | 1007 |
1014 static jmethodID g_TestJni_openUrl = 0; | 1008 static jmethodID g_TestJni_openUrl = 0; |
1015 static ScopedJavaLocalRef<jobject> Java_TestJni_openUrl(JNIEnv* env, jstring | 1009 static ScopedJavaLocalRef<jobject> Java_TestJni_openUrl(JNIEnv* env, jstring |
1016 url) { | 1010 url) { |
1017 /* Must call RegisterNativesImpl() */ | 1011 /* Must call RegisterNativesImpl() */ |
1018 DCHECK(!g_TestJni_clazz.is_null()); | 1012 DCHECK(g_TestJni_clazz); |
1019 DCHECK(g_TestJni_openUrl); | 1013 DCHECK(g_TestJni_openUrl); |
1020 jobject ret = | 1014 jobject ret = |
1021 env->CallStaticObjectMethod(g_TestJni_clazz.obj(), | 1015 env->CallStaticObjectMethod(g_TestJni_clazz, |
1022 g_TestJni_openUrl, url); | 1016 g_TestJni_openUrl, url); |
1023 base::android::CheckException(env); | 1017 base::android::CheckException(env); |
1024 return ScopedJavaLocalRef<jobject>(env, ret); | 1018 return ScopedJavaLocalRef<jobject>(env, ret); |
1025 } | 1019 } |
1026 | 1020 |
1027 static jmethodID g_TestJni_activateHardwareAcceleration = 0; | 1021 static jmethodID g_TestJni_activateHardwareAcceleration = 0; |
1028 static void Java_TestJni_activateHardwareAcceleration(JNIEnv* env, jobject obj, | 1022 static void Java_TestJni_activateHardwareAcceleration(JNIEnv* env, jobject obj, |
1029 jboolean activated, | 1023 jboolean activated, |
1030 jint iPid, | 1024 jint iPid, |
1031 jint iType, | 1025 jint iType, |
1032 jint iPrimaryID, | 1026 jint iPrimaryID, |
1033 jint iSecondaryID) { | 1027 jint iSecondaryID) { |
1034 /* Must call RegisterNativesImpl() */ | 1028 /* Must call RegisterNativesImpl() */ |
1035 DCHECK(!g_TestJni_clazz.is_null()); | 1029 DCHECK(g_TestJni_clazz); |
1036 DCHECK(g_TestJni_activateHardwareAcceleration); | 1030 DCHECK(g_TestJni_activateHardwareAcceleration); |
1037 | 1031 |
1038 env->CallVoidMethod(obj, | 1032 env->CallVoidMethod(obj, |
1039 g_TestJni_activateHardwareAcceleration, activated, iPid, iType, | 1033 g_TestJni_activateHardwareAcceleration, activated, iPid, iType, |
1040 iPrimaryID, iSecondaryID); | 1034 iPrimaryID, iSecondaryID); |
1041 base::android::CheckException(env); | 1035 base::android::CheckException(env); |
1042 | 1036 |
1043 } | 1037 } |
1044 | 1038 |
1045 static jmethodID g_TestJni_uncheckedCall = 0; | 1039 static jmethodID g_TestJni_uncheckedCall = 0; |
1046 static void Java_TestJni_uncheckedCall(JNIEnv* env, jobject obj, jint iParam) { | 1040 static void Java_TestJni_uncheckedCall(JNIEnv* env, jobject obj, jint iParam) { |
1047 /* Must call RegisterNativesImpl() */ | 1041 /* Must call RegisterNativesImpl() */ |
1048 DCHECK(!g_TestJni_clazz.is_null()); | 1042 DCHECK(g_TestJni_clazz); |
1049 DCHECK(g_TestJni_uncheckedCall); | 1043 DCHECK(g_TestJni_uncheckedCall); |
1050 | 1044 |
1051 env->CallVoidMethod(obj, | 1045 env->CallVoidMethod(obj, |
1052 g_TestJni_uncheckedCall, iParam); | 1046 g_TestJni_uncheckedCall, iParam); |
1053 | 1047 |
1054 | 1048 |
1055 } | 1049 } |
1056 | 1050 |
1057 // Step 3: GetMethodIDs and RegisterNatives. | 1051 // Step 3: GetMethodIDs and RegisterNatives. |
1058 | 1052 |
1059 | 1053 |
1060 static void GetMethodIDsImpl(JNIEnv* env) { | 1054 static void GetMethodIDsImpl(JNIEnv* env) { |
1061 g_TestJni_clazz.Reset( | 1055 g_TestJni_clazz = reinterpret_cast<jclass>(env->NewGlobalRef( |
1062 base::android::GetClass(env, kTestJniClassPath)); | 1056 base::android::GetUnscopedClass(env, kTestJniClassPath))); |
1063 g_InfoBar_clazz.Reset( | 1057 g_InfoBar_clazz = reinterpret_cast<jclass>(env->NewGlobalRef( |
1064 base::android::GetClass(env, kInfoBarClassPath)); | 1058 base::android::GetUnscopedClass(env, kInfoBarClassPath))); |
1065 g_TestJni_showConfirmInfoBar = base::android::GetMethodID( | 1059 g_TestJni_showConfirmInfoBar = |
1066 env, g_TestJni_clazz, | 1060 base::android::GetMethodID( |
1067 "showConfirmInfoBar", | 1061 env, g_TestJni_clazz, |
| 1062 "showConfirmInfoBar", |
1068 | 1063 |
1069 "(" | 1064 "(" |
1070 "I" | 1065 "I" |
1071 "Ljava/lang/String;" | 1066 "Ljava/lang/String;" |
1072 "Ljava/lang/String;" | 1067 "Ljava/lang/String;" |
1073 "Ljava/lang/String;" | 1068 "Ljava/lang/String;" |
1074 "Landroid/graphics/Bitmap;" | 1069 "Landroid/graphics/Bitmap;" |
1075 ")" | 1070 ")" |
1076 "Lcom/android/chrome/infobar/InfoBarContainer$NativeInfoBar;"); | 1071 "Lcom/android/chrome/infobar/InfoBarContainer$NativeInfoBar;"); |
1077 | 1072 |
1078 g_TestJni_showAutoLoginInfoBar = base::android::GetMethodID( | 1073 g_TestJni_showAutoLoginInfoBar = |
1079 env, g_TestJni_clazz, | 1074 base::android::GetMethodID( |
1080 "showAutoLoginInfoBar", | 1075 env, g_TestJni_clazz, |
| 1076 "showAutoLoginInfoBar", |
1081 | 1077 |
1082 "(" | 1078 "(" |
1083 "I" | 1079 "I" |
1084 "Ljava/lang/String;" | 1080 "Ljava/lang/String;" |
1085 "Ljava/lang/String;" | 1081 "Ljava/lang/String;" |
1086 "Ljava/lang/String;" | 1082 "Ljava/lang/String;" |
1087 ")" | 1083 ")" |
1088 "Lcom/android/chrome/infobar/InfoBarContainer$NativeInfoBar;"); | 1084 "Lcom/android/chrome/infobar/InfoBarContainer$NativeInfoBar;"); |
1089 | 1085 |
1090 g_InfoBar_dismiss = base::android::GetMethodID( | 1086 g_InfoBar_dismiss = |
1091 env, g_InfoBar_clazz, | 1087 base::android::GetMethodID( |
1092 "dismiss", | 1088 env, g_InfoBar_clazz, |
| 1089 "dismiss", |
1093 | 1090 |
1094 "(" | 1091 "(" |
1095 ")" | 1092 ")" |
1096 "V"); | 1093 "V"); |
1097 | 1094 |
1098 g_TestJni_shouldShowAutoLogin = base::android::GetStaticMethodID( | 1095 g_TestJni_shouldShowAutoLogin = |
1099 env, g_TestJni_clazz, | 1096 base::android::GetStaticMethodID( |
1100 "shouldShowAutoLogin", | 1097 env, g_TestJni_clazz, |
| 1098 "shouldShowAutoLogin", |
1101 | 1099 |
1102 "(" | 1100 "(" |
1103 "Lorg/chromium/chromeview/ChromeView;" | 1101 "Lorg/chromium/chromeview/ChromeView;" |
1104 "Ljava/lang/String;" | 1102 "Ljava/lang/String;" |
1105 "Ljava/lang/String;" | 1103 "Ljava/lang/String;" |
1106 "Ljava/lang/String;" | 1104 "Ljava/lang/String;" |
1107 ")" | 1105 ")" |
1108 "Z"); | 1106 "Z"); |
1109 | 1107 |
1110 g_TestJni_openUrl = base::android::GetStaticMethodID( | 1108 g_TestJni_openUrl = |
1111 env, g_TestJni_clazz, | 1109 base::android::GetStaticMethodID( |
1112 "openUrl", | 1110 env, g_TestJni_clazz, |
| 1111 "openUrl", |
1113 | 1112 |
1114 "(" | 1113 "(" |
1115 "Ljava/lang/String;" | 1114 "Ljava/lang/String;" |
1116 ")" | 1115 ")" |
1117 "Ljava/io/InputStream;"); | 1116 "Ljava/io/InputStream;"); |
1118 | 1117 |
1119 g_TestJni_activateHardwareAcceleration = base::android::GetMethodID( | 1118 g_TestJni_activateHardwareAcceleration = |
1120 env, g_TestJni_clazz, | 1119 base::android::GetMethodID( |
1121 "activateHardwareAcceleration", | 1120 env, g_TestJni_clazz, |
| 1121 "activateHardwareAcceleration", |
1122 | 1122 |
1123 "(" | 1123 "(" |
1124 "Z" | 1124 "Z" |
1125 "I" | 1125 "I" |
1126 "I" | 1126 "I" |
1127 "I" | 1127 "I" |
1128 "I" | 1128 "I" |
1129 ")" | 1129 ")" |
1130 "V"); | 1130 "V"); |
1131 | 1131 |
1132 g_TestJni_uncheckedCall = base::android::GetMethodID( | 1132 g_TestJni_uncheckedCall = |
1133 env, g_TestJni_clazz, | 1133 base::android::GetMethodID( |
1134 "uncheckedCall", | 1134 env, g_TestJni_clazz, |
| 1135 "uncheckedCall", |
1135 | 1136 |
1136 "(" | 1137 "(" |
1137 "I" | 1138 "I" |
1138 ")" | 1139 ")" |
1139 "V"); | 1140 "V"); |
1140 | 1141 |
1141 } | 1142 } |
1142 | 1143 |
1143 static bool RegisterNativesImpl(JNIEnv* env) { | 1144 static bool RegisterNativesImpl(JNIEnv* env) { |
1144 GetMethodIDsImpl(env); | 1145 GetMethodIDsImpl(env); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1229 | 1230 |
1230 #include "base/android/jni_android.h" | 1231 #include "base/android/jni_android.h" |
1231 #include "base/android/scoped_java_ref.h" | 1232 #include "base/android/scoped_java_ref.h" |
1232 #include "base/basictypes.h" | 1233 #include "base/basictypes.h" |
1233 #include "base/logging.h" | 1234 #include "base/logging.h" |
1234 | 1235 |
1235 using base::android::ScopedJavaLocalRef; | 1236 using base::android::ScopedJavaLocalRef; |
1236 | 1237 |
1237 // Step 1: forward declarations. | 1238 // Step 1: forward declarations. |
1238 namespace { | 1239 namespace { |
1239 const char* const kInputStreamClassPath = "java/io/InputStream"; | 1240 static const char kInputStreamClassPath[] = "java/io/InputStream"; |
1240 // Leaking this JavaRef as we cannot use LazyInstance from some threads. | 1241 // Leaking this jclass as we cannot use LazyInstance from some threads. |
1241 base::android::ScopedJavaGlobalRef<jclass>& | 1242 jclass g_InputStream_clazz = NULL; |
1242 g_InputStream_clazz = | |
1243 *(new base::android::ScopedJavaGlobalRef<jclass>()); | |
1244 } // namespace | 1243 } // namespace |
1245 | 1244 |
1246 | 1245 |
1247 // Step 2: method stubs. | 1246 // Step 2: method stubs. |
1248 | 1247 |
1249 static jmethodID g_InputStream_available = 0; | 1248 static jmethodID g_InputStream_available = 0; |
1250 static jint Java_InputStream_available(JNIEnv* env, jobject obj) __attribute__ | 1249 static jint Java_InputStream_available(JNIEnv* env, jobject obj) __attribute__ |
1251 ((unused)); | 1250 ((unused)); |
1252 static jint Java_InputStream_available(JNIEnv* env, jobject obj) { | 1251 static jint Java_InputStream_available(JNIEnv* env, jobject obj) { |
1253 /* Must call RegisterNativesImpl() */ | 1252 /* Must call RegisterNativesImpl() */ |
1254 DCHECK(!g_InputStream_clazz.is_null()); | 1253 DCHECK(g_InputStream_clazz); |
1255 DCHECK(g_InputStream_available); | 1254 DCHECK(g_InputStream_available); |
1256 jint ret = | 1255 jint ret = |
1257 env->CallIntMethod(obj, | 1256 env->CallIntMethod(obj, |
1258 g_InputStream_available); | 1257 g_InputStream_available); |
1259 base::android::CheckException(env); | 1258 base::android::CheckException(env); |
1260 return ret; | 1259 return ret; |
1261 } | 1260 } |
1262 | 1261 |
1263 static jmethodID g_InputStream_close = 0; | 1262 static jmethodID g_InputStream_close = 0; |
1264 static void Java_InputStream_close(JNIEnv* env, jobject obj) __attribute__ | 1263 static void Java_InputStream_close(JNIEnv* env, jobject obj) __attribute__ |
1265 ((unused)); | 1264 ((unused)); |
1266 static void Java_InputStream_close(JNIEnv* env, jobject obj) { | 1265 static void Java_InputStream_close(JNIEnv* env, jobject obj) { |
1267 /* Must call RegisterNativesImpl() */ | 1266 /* Must call RegisterNativesImpl() */ |
1268 DCHECK(!g_InputStream_clazz.is_null()); | 1267 DCHECK(g_InputStream_clazz); |
1269 DCHECK(g_InputStream_close); | 1268 DCHECK(g_InputStream_close); |
1270 | 1269 |
1271 env->CallVoidMethod(obj, | 1270 env->CallVoidMethod(obj, |
1272 g_InputStream_close); | 1271 g_InputStream_close); |
1273 base::android::CheckException(env); | 1272 base::android::CheckException(env); |
1274 | 1273 |
1275 } | 1274 } |
1276 | 1275 |
1277 static jmethodID g_InputStream_mark = 0; | 1276 static jmethodID g_InputStream_mark = 0; |
1278 static void Java_InputStream_mark(JNIEnv* env, jobject obj, jint p0) | 1277 static void Java_InputStream_mark(JNIEnv* env, jobject obj, jint p0) |
1279 __attribute__ ((unused)); | 1278 __attribute__ ((unused)); |
1280 static void Java_InputStream_mark(JNIEnv* env, jobject obj, jint p0) { | 1279 static void Java_InputStream_mark(JNIEnv* env, jobject obj, jint p0) { |
1281 /* Must call RegisterNativesImpl() */ | 1280 /* Must call RegisterNativesImpl() */ |
1282 DCHECK(!g_InputStream_clazz.is_null()); | 1281 DCHECK(g_InputStream_clazz); |
1283 DCHECK(g_InputStream_mark); | 1282 DCHECK(g_InputStream_mark); |
1284 | 1283 |
1285 env->CallVoidMethod(obj, | 1284 env->CallVoidMethod(obj, |
1286 g_InputStream_mark, p0); | 1285 g_InputStream_mark, p0); |
1287 base::android::CheckException(env); | 1286 base::android::CheckException(env); |
1288 | 1287 |
1289 } | 1288 } |
1290 | 1289 |
1291 static jmethodID g_InputStream_markSupported = 0; | 1290 static jmethodID g_InputStream_markSupported = 0; |
1292 static jboolean Java_InputStream_markSupported(JNIEnv* env, jobject obj) | 1291 static jboolean Java_InputStream_markSupported(JNIEnv* env, jobject obj) |
1293 __attribute__ ((unused)); | 1292 __attribute__ ((unused)); |
1294 static jboolean Java_InputStream_markSupported(JNIEnv* env, jobject obj) { | 1293 static jboolean Java_InputStream_markSupported(JNIEnv* env, jobject obj) { |
1295 /* Must call RegisterNativesImpl() */ | 1294 /* Must call RegisterNativesImpl() */ |
1296 DCHECK(!g_InputStream_clazz.is_null()); | 1295 DCHECK(g_InputStream_clazz); |
1297 DCHECK(g_InputStream_markSupported); | 1296 DCHECK(g_InputStream_markSupported); |
1298 jboolean ret = | 1297 jboolean ret = |
1299 env->CallBooleanMethod(obj, | 1298 env->CallBooleanMethod(obj, |
1300 g_InputStream_markSupported); | 1299 g_InputStream_markSupported); |
1301 base::android::CheckException(env); | 1300 base::android::CheckException(env); |
1302 return ret; | 1301 return ret; |
1303 } | 1302 } |
1304 | 1303 |
1305 static jmethodID g_InputStream_read_pqI = 0; | 1304 static jmethodID g_InputStream_read_pqI = 0; |
1306 static jint Java_InputStream_read(JNIEnv* env, jobject obj) __attribute__ | 1305 static jint Java_InputStream_read(JNIEnv* env, jobject obj) __attribute__ |
1307 ((unused)); | 1306 ((unused)); |
1308 static jint Java_InputStream_read(JNIEnv* env, jobject obj) { | 1307 static jint Java_InputStream_read(JNIEnv* env, jobject obj) { |
1309 /* Must call RegisterNativesImpl() */ | 1308 /* Must call RegisterNativesImpl() */ |
1310 DCHECK(!g_InputStream_clazz.is_null()); | 1309 DCHECK(g_InputStream_clazz); |
1311 DCHECK(g_InputStream_read_pqI); | 1310 DCHECK(g_InputStream_read_pqI); |
1312 jint ret = | 1311 jint ret = |
1313 env->CallIntMethod(obj, | 1312 env->CallIntMethod(obj, |
1314 g_InputStream_read_pqI); | 1313 g_InputStream_read_pqI); |
1315 base::android::CheckException(env); | 1314 base::android::CheckException(env); |
1316 return ret; | 1315 return ret; |
1317 } | 1316 } |
1318 | 1317 |
1319 static jmethodID g_InputStream_read_paBqI = 0; | 1318 static jmethodID g_InputStream_read_paBqI = 0; |
1320 static jint Java_InputStream_read(JNIEnv* env, jobject obj, jbyteArray p0) | 1319 static jint Java_InputStream_read(JNIEnv* env, jobject obj, jbyteArray p0) |
1321 __attribute__ ((unused)); | 1320 __attribute__ ((unused)); |
1322 static jint Java_InputStream_read(JNIEnv* env, jobject obj, jbyteArray p0) { | 1321 static jint Java_InputStream_read(JNIEnv* env, jobject obj, jbyteArray p0) { |
1323 /* Must call RegisterNativesImpl() */ | 1322 /* Must call RegisterNativesImpl() */ |
1324 DCHECK(!g_InputStream_clazz.is_null()); | 1323 DCHECK(g_InputStream_clazz); |
1325 DCHECK(g_InputStream_read_paBqI); | 1324 DCHECK(g_InputStream_read_paBqI); |
1326 jint ret = | 1325 jint ret = |
1327 env->CallIntMethod(obj, | 1326 env->CallIntMethod(obj, |
1328 g_InputStream_read_paBqI, p0); | 1327 g_InputStream_read_paBqI, p0); |
1329 base::android::CheckException(env); | 1328 base::android::CheckException(env); |
1330 return ret; | 1329 return ret; |
1331 } | 1330 } |
1332 | 1331 |
1333 static jmethodID g_InputStream_read_paBIIqI = 0; | 1332 static jmethodID g_InputStream_read_paBIIqI = 0; |
1334 static jint Java_InputStream_read(JNIEnv* env, jobject obj, jbyteArray p0, | 1333 static jint Java_InputStream_read(JNIEnv* env, jobject obj, jbyteArray p0, |
1335 jint p1, | 1334 jint p1, |
1336 jint p2) __attribute__ ((unused)); | 1335 jint p2) __attribute__ ((unused)); |
1337 static jint Java_InputStream_read(JNIEnv* env, jobject obj, jbyteArray p0, | 1336 static jint Java_InputStream_read(JNIEnv* env, jobject obj, jbyteArray p0, |
1338 jint p1, | 1337 jint p1, |
1339 jint p2) { | 1338 jint p2) { |
1340 /* Must call RegisterNativesImpl() */ | 1339 /* Must call RegisterNativesImpl() */ |
1341 DCHECK(!g_InputStream_clazz.is_null()); | 1340 DCHECK(g_InputStream_clazz); |
1342 DCHECK(g_InputStream_read_paBIIqI); | 1341 DCHECK(g_InputStream_read_paBIIqI); |
1343 jint ret = | 1342 jint ret = |
1344 env->CallIntMethod(obj, | 1343 env->CallIntMethod(obj, |
1345 g_InputStream_read_paBIIqI, p0, p1, p2); | 1344 g_InputStream_read_paBIIqI, p0, p1, p2); |
1346 base::android::CheckException(env); | 1345 base::android::CheckException(env); |
1347 return ret; | 1346 return ret; |
1348 } | 1347 } |
1349 | 1348 |
1350 static jmethodID g_InputStream_reset = 0; | 1349 static jmethodID g_InputStream_reset = 0; |
1351 static void Java_InputStream_reset(JNIEnv* env, jobject obj) __attribute__ | 1350 static void Java_InputStream_reset(JNIEnv* env, jobject obj) __attribute__ |
1352 ((unused)); | 1351 ((unused)); |
1353 static void Java_InputStream_reset(JNIEnv* env, jobject obj) { | 1352 static void Java_InputStream_reset(JNIEnv* env, jobject obj) { |
1354 /* Must call RegisterNativesImpl() */ | 1353 /* Must call RegisterNativesImpl() */ |
1355 DCHECK(!g_InputStream_clazz.is_null()); | 1354 DCHECK(g_InputStream_clazz); |
1356 DCHECK(g_InputStream_reset); | 1355 DCHECK(g_InputStream_reset); |
1357 | 1356 |
1358 env->CallVoidMethod(obj, | 1357 env->CallVoidMethod(obj, |
1359 g_InputStream_reset); | 1358 g_InputStream_reset); |
1360 base::android::CheckException(env); | 1359 base::android::CheckException(env); |
1361 | 1360 |
1362 } | 1361 } |
1363 | 1362 |
1364 static jmethodID g_InputStream_skip = 0; | 1363 static jmethodID g_InputStream_skip = 0; |
1365 static jlong Java_InputStream_skip(JNIEnv* env, jobject obj, jlong p0) | 1364 static jlong Java_InputStream_skip(JNIEnv* env, jobject obj, jlong p0) |
1366 __attribute__ ((unused)); | 1365 __attribute__ ((unused)); |
1367 static jlong Java_InputStream_skip(JNIEnv* env, jobject obj, jlong p0) { | 1366 static jlong Java_InputStream_skip(JNIEnv* env, jobject obj, jlong p0) { |
1368 /* Must call RegisterNativesImpl() */ | 1367 /* Must call RegisterNativesImpl() */ |
1369 DCHECK(!g_InputStream_clazz.is_null()); | 1368 DCHECK(g_InputStream_clazz); |
1370 DCHECK(g_InputStream_skip); | 1369 DCHECK(g_InputStream_skip); |
1371 jlong ret = | 1370 jlong ret = |
1372 env->CallLongMethod(obj, | 1371 env->CallLongMethod(obj, |
1373 g_InputStream_skip, p0); | 1372 g_InputStream_skip, p0); |
1374 base::android::CheckException(env); | 1373 base::android::CheckException(env); |
1375 return ret; | 1374 return ret; |
1376 } | 1375 } |
1377 | 1376 |
1378 // Step 3: GetMethodIDs and RegisterNatives. | 1377 // Step 3: GetMethodIDs and RegisterNatives. |
1379 namespace JNI_InputStream { | 1378 namespace JNI_InputStream { |
1380 | 1379 |
1381 static void GetMethodIDsImpl(JNIEnv* env) { | 1380 static void GetMethodIDsImpl(JNIEnv* env) { |
1382 g_InputStream_clazz.Reset( | 1381 g_InputStream_clazz = reinterpret_cast<jclass>(env->NewGlobalRef( |
1383 base::android::GetClass(env, kInputStreamClassPath)); | 1382 base::android::GetUnscopedClass(env, kInputStreamClassPath))); |
1384 g_InputStream_available = base::android::GetMethodID( | 1383 g_InputStream_available = |
1385 env, g_InputStream_clazz, | 1384 base::android::GetMethodID( |
1386 "available", | 1385 env, g_InputStream_clazz, |
| 1386 "available", |
1387 | 1387 |
1388 "(" | 1388 "(" |
1389 ")" | 1389 ")" |
1390 "I"); | 1390 "I"); |
1391 | 1391 |
1392 g_InputStream_close = base::android::GetMethodID( | 1392 g_InputStream_close = |
1393 env, g_InputStream_clazz, | 1393 base::android::GetMethodID( |
1394 "close", | 1394 env, g_InputStream_clazz, |
| 1395 "close", |
1395 | 1396 |
1396 "(" | 1397 "(" |
1397 ")" | 1398 ")" |
1398 "V"); | 1399 "V"); |
1399 | 1400 |
1400 g_InputStream_mark = base::android::GetMethodID( | 1401 g_InputStream_mark = |
1401 env, g_InputStream_clazz, | 1402 base::android::GetMethodID( |
1402 "mark", | 1403 env, g_InputStream_clazz, |
| 1404 "mark", |
1403 | 1405 |
1404 "(" | 1406 "(" |
1405 "I" | 1407 "I" |
1406 ")" | 1408 ")" |
1407 "V"); | 1409 "V"); |
1408 | 1410 |
1409 g_InputStream_markSupported = base::android::GetMethodID( | 1411 g_InputStream_markSupported = |
1410 env, g_InputStream_clazz, | 1412 base::android::GetMethodID( |
1411 "markSupported", | 1413 env, g_InputStream_clazz, |
| 1414 "markSupported", |
1412 | 1415 |
1413 "(" | 1416 "(" |
1414 ")" | 1417 ")" |
1415 "Z"); | 1418 "Z"); |
1416 | 1419 |
1417 g_InputStream_read_pqI = base::android::GetMethodID( | 1420 g_InputStream_read_pqI = |
1418 env, g_InputStream_clazz, | 1421 base::android::GetMethodID( |
1419 "read", | 1422 env, g_InputStream_clazz, |
| 1423 "read", |
1420 | 1424 |
1421 "(" | 1425 "(" |
1422 ")" | 1426 ")" |
1423 "I"); | 1427 "I"); |
1424 | 1428 |
1425 g_InputStream_read_paBqI = base::android::GetMethodID( | 1429 g_InputStream_read_paBqI = |
1426 env, g_InputStream_clazz, | 1430 base::android::GetMethodID( |
1427 "read", | 1431 env, g_InputStream_clazz, |
| 1432 "read", |
1428 | 1433 |
1429 "(" | 1434 "(" |
1430 "[B" | 1435 "[B" |
1431 ")" | 1436 ")" |
1432 "I"); | 1437 "I"); |
1433 | 1438 |
1434 g_InputStream_read_paBIIqI = base::android::GetMethodID( | 1439 g_InputStream_read_paBIIqI = |
1435 env, g_InputStream_clazz, | 1440 base::android::GetMethodID( |
1436 "read", | 1441 env, g_InputStream_clazz, |
| 1442 "read", |
1437 | 1443 |
1438 "(" | 1444 "(" |
1439 "[B" | 1445 "[B" |
1440 "I" | 1446 "I" |
1441 "I" | 1447 "I" |
1442 ")" | 1448 ")" |
1443 "I"); | 1449 "I"); |
1444 | 1450 |
1445 g_InputStream_reset = base::android::GetMethodID( | 1451 g_InputStream_reset = |
1446 env, g_InputStream_clazz, | 1452 base::android::GetMethodID( |
1447 "reset", | 1453 env, g_InputStream_clazz, |
| 1454 "reset", |
1448 | 1455 |
1449 "(" | 1456 "(" |
1450 ")" | 1457 ")" |
1451 "V"); | 1458 "V"); |
1452 | 1459 |
1453 g_InputStream_skip = base::android::GetMethodID( | 1460 g_InputStream_skip = |
1454 env, g_InputStream_clazz, | 1461 base::android::GetMethodID( |
1455 "skip", | 1462 env, g_InputStream_clazz, |
| 1463 "skip", |
1456 | 1464 |
1457 "(" | 1465 "(" |
1458 "J" | 1466 "J" |
1459 ")" | 1467 ")" |
1460 "J"); | 1468 "J"); |
1461 | 1469 |
1462 } | 1470 } |
1463 | 1471 |
1464 static bool RegisterNativesImpl(JNIEnv* env) { | 1472 static bool RegisterNativesImpl(JNIEnv* env) { |
1465 JNI_InputStream::GetMethodIDsImpl(env); | 1473 JNI_InputStream::GetMethodIDsImpl(env); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1518 self.assertRaises(SystemExit, jni_generator.CheckFilenames, | 1526 self.assertRaises(SystemExit, jni_generator.CheckFilenames, |
1519 ['NotTheSame.java'], ['not_good.h']) | 1527 ['NotTheSame.java'], ['not_good.h']) |
1520 self.assertRaises(SystemExit, jni_generator.CheckFilenames, | 1528 self.assertRaises(SystemExit, jni_generator.CheckFilenames, |
1521 ['MissingJniSuffix.java'], ['missing_jni_suffix.h']) | 1529 ['MissingJniSuffix.java'], ['missing_jni_suffix.h']) |
1522 jni_generator.CheckFilenames(['ThisIsFine.java'], ['this_is_fine_jni.h']) | 1530 jni_generator.CheckFilenames(['ThisIsFine.java'], ['this_is_fine_jni.h']) |
1523 jni_generator.CheckFilenames([], []) | 1531 jni_generator.CheckFilenames([], []) |
1524 | 1532 |
1525 | 1533 |
1526 if __name__ == '__main__': | 1534 if __name__ == '__main__': |
1527 unittest.main() | 1535 unittest.main() |
OLD | NEW |