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

Unified Diff: base/android/jni_registrar.cc

Issue 10591005: Add a way for JNI registrars to specify methods to be registered for tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 6 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_registrar.h ('k') | content/app/android/content_jni_registrar.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/android/jni_registrar.cc
diff --git a/base/android/jni_registrar.cc b/base/android/jni_registrar.cc
index 696924a09d03ef4a768f0ec06614c05bd5f8972f..637e27a8c4b46529ea31038aacb867a1f6c97ffd 100644
--- a/base/android/jni_registrar.cc
+++ b/base/android/jni_registrar.cc
@@ -4,12 +4,44 @@
#include "base/android/jni_registrar.h"
+#include <vector>
#include "base/logging.h"
#include "base/android/jni_android.h"
namespace base {
namespace android {
+typedef std::vector<RegistrationMethod> RegistrationMethodList;
+
+// Retrieve a reference to the global RegistrationMethods list.
+RegistrationMethodList &GetRegistrationMethodList() {
+ static RegistrationMethodList test_registration_method_list;
+ return test_registration_method_list;
+}
+
+AppendRegistrationMethods::AppendRegistrationMethods(
+ const RegistrationMethod* methods, size_t count) {
+ const RegistrationMethod* end = methods + count;
+ while (methods != end) {
+ GetRegistrationMethodList().push_back(*methods);
+ LOG(ERROR) << "Adding method:" << methods->name;
+ methods++;
+ }
+}
+
+bool RegisterAllNativeMethodsForTest(JNIEnv* env) {
+ RegistrationMethodList& native_methods = GetRegistrationMethodList();
+ for (RegistrationMethodList::iterator it = native_methods.begin();
+ it != native_methods.end(); ++it) {
+ if (!it->func(env) < 0) {
+ DLOG(ERROR) << it->name << " failed registration!";
+ return false;
+ }
+ LOG(ERROR) << "Registering method:" << it->name;
+ }
+ return true;
+}
+
bool RegisterNativeMethods(JNIEnv* env,
const RegistrationMethod* method,
size_t count) {
« no previous file with comments | « base/android/jni_registrar.h ('k') | content/app/android/content_jni_registrar.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698