Skip to content

Commit

Permalink
jni: Remove no-longer-needed calls to NewLocalRef.
Browse files Browse the repository at this point in the history
We no longer need to explicitly create new local references to put into
ScopedJavaLocalRef to avoid JNI warnings; we can just pass JavaParamRefs
around safely now. Remove temporary fixes added in
https://codereview.chromium.org/1278823006 and do that instead.

BUG=506850

Review URL: https://codereview.chromium.org/1324453006

Cr-Commit-Position: refs/heads/master@{#347396}
  • Loading branch information
tornewuff authored and Commit bot committed Sep 4, 2015
1 parent 753ecf6 commit 9d46f6b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 13 deletions.
10 changes: 3 additions & 7 deletions content/app/android/child_process_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class SurfaceTextureManagerImpl : public SurfaceTextureManager,
// |service| is the instance of
// org.chromium.content.app.ChildProcessService.
explicit SurfaceTextureManagerImpl(
const base::android::ScopedJavaLocalRef<jobject>& service)
const base::android::JavaRef<jobject>& service)
: service_(service) {
SurfaceTexturePeer::InitInstance(this);
GpuSurfaceLookup::InitInstance(this);
Expand Down Expand Up @@ -132,13 +132,9 @@ class SurfaceTextureManagerImpl : public SurfaceTextureManager,
// Chrome actually uses the renderer code path for all of its child
// processes such as renderers, plugins, etc.
void InternalInitChildProcess(JNIEnv* env,
jclass clazz,
jobject service_in,
const JavaParamRef<jobject>& service,
jint cpu_count,
jlong cpu_features) {
base::android::ScopedJavaLocalRef<jobject> service(
env, env->NewLocalRef(service_in));

// Set the CPU properties.
android_setCpu(cpu_count, cpu_features);
SurfaceTextureManager::SetInstance(new SurfaceTextureManagerImpl(service));
Expand All @@ -163,7 +159,7 @@ void InitChildProcess(JNIEnv* env,
const JavaParamRef<jobject>& service,
jint cpu_count,
jlong cpu_features) {
InternalInitChildProcess(env, clazz, service, cpu_count, cpu_features);
InternalInitChildProcess(env, service, cpu_count, cpu_features);
}

void ExitChildProcess(JNIEnv* env, const JavaParamRef<jclass>& clazz) {
Expand Down
4 changes: 1 addition & 3 deletions content/app/android/content_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ LazyInstance<scoped_ptr<ContentMainDelegate> > g_content_main_delegate =
static void InitApplicationContext(JNIEnv* env,
const JavaParamRef<jclass>& clazz,
const JavaParamRef<jobject>& context) {
base::android::ScopedJavaLocalRef<jobject> scoped_context(
env, env->NewLocalRef(context));
base::android::InitApplicationContext(env, scoped_context);
base::android::InitApplicationContext(env, context);
}

static jint Start(JNIEnv* env, const JavaParamRef<jclass>& clazz) {
Expand Down
4 changes: 1 addition & 3 deletions testing/android/native_test/native_test_launcher.cc
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,7 @@ static void RunTests(JNIEnv* env,
base::CommandLine::Init(arraysize(kInitialArgv), kInitialArgv);

// Set the application context in base.
base::android::ScopedJavaLocalRef<jobject> scoped_context(
env, env->NewLocalRef(app_context));
base::android::InitApplicationContext(env, scoped_context);
base::android::InitApplicationContext(env, app_context);
base::android::RegisterJni(env);

std::vector<std::string> args;
Expand Down

0 comments on commit 9d46f6b

Please sign in to comment.