From 5e44a14c0ab8d14036de5632bfefa53fd251babe Mon Sep 17 00:00:00 2001 From: "yfriedman@chromium.org" Date: Tue, 19 Mar 2013 09:48:39 +0000 Subject: Fix x86 build of Android. After https://chromiumcodereview.appspot.com/12321131/ there are two copies of child_process_launcher.cc content/browser/android and in content/browser. Rename the former to avoid having duplicate basenames which is a problem for some toolchains. This wasn't seen in chromium as there isn't coverage for x86. BUG=178382 TBR=joth,jam Review URL: https://chromiumcodereview.appspot.com/12575010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@188970 0039d316-1c4b-4281-b951-d872f2087c98 --- content/browser/android/browser_jni_registrar.cc | 2 +- content/browser/android/child_process_launcher.cc | 158 --------------------- content/browser/android/child_process_launcher.h | 37 ----- .../android/child_process_launcher_android.cc | 158 +++++++++++++++++++++ .../android/child_process_launcher_android.h | 36 +++++ 5 files changed, 195 insertions(+), 196 deletions(-) delete mode 100644 content/browser/android/child_process_launcher.cc delete mode 100644 content/browser/android/child_process_launcher.h create mode 100644 content/browser/android/child_process_launcher_android.cc create mode 100644 content/browser/android/child_process_launcher_android.h (limited to 'content/browser/android') diff --git a/content/browser/android/browser_jni_registrar.cc b/content/browser/android/browser_jni_registrar.cc index d15391b..1915337 100644 --- a/content/browser/android/browser_jni_registrar.cc +++ b/content/browser/android/browser_jni_registrar.cc @@ -7,7 +7,7 @@ #include "base/android/jni_android.h" #include "base/android/jni_registrar.h" #include "content/browser/android/android_browser_process.h" -#include "content/browser/android/child_process_launcher.h" +#include "content/browser/android/child_process_launcher_android.h" #include "content/browser/android/content_settings.h" #include "content/browser/android/content_video_view.h" #include "content/browser/android/content_view_core_impl.h" diff --git a/content/browser/android/child_process_launcher.cc b/content/browser/android/child_process_launcher.cc deleted file mode 100644 index 32feae6..0000000 --- a/content/browser/android/child_process_launcher.cc +++ /dev/null @@ -1,158 +0,0 @@ -// 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. - -#include "content/browser/android/child_process_launcher.h" - -#include "base/android/jni_android.h" -#include "base/android/jni_array.h" -#include "base/logging.h" -#include "base/memory/scoped_ptr.h" -#include "content/browser/android/media_player_manager_android.h" -#include "content/browser/renderer_host/compositor_impl_android.h" -#include "content/browser/renderer_host/render_view_host_impl.h" -#include "content/common/android/scoped_java_surface.h" -#include "content/public/browser/browser_thread.h" -#include "content/public/browser/render_process_host.h" -#include "jni/ChildProcessLauncher_jni.h" -#include "media/base/android/media_player_bridge.h" - -using base::android::AttachCurrentThread; -using base::android::ToJavaArrayOfStrings; -using base::android::ScopedJavaGlobalRef; -using base::android::ScopedJavaLocalRef; -using content::StartChildProcessCallback; - -namespace content { - -namespace { - -// Pass a java surface object to the MediaPlayerBridge object -// identified by render process handle, render view ID and player ID. -static void SetSurfacePeer( - const base::android::JavaRef& surface, - base::ProcessHandle render_process_handle, - int render_view_id, - int player_id) { - int renderer_id = 0; - RenderProcessHost::iterator it = RenderProcessHost::AllHostsIterator(); - while (!it.IsAtEnd()) { - if (it.GetCurrentValue()->GetHandle() == render_process_handle) { - renderer_id = it.GetCurrentValue()->GetID(); - break; - } - it.Advance(); - } - - if (renderer_id) { - RenderViewHostImpl* host = RenderViewHostImpl::FromID( - renderer_id, render_view_id); - if (host) { - media::MediaPlayerBridge* player = - host->media_player_manager()->GetPlayer(player_id); - if (player && - player != host->media_player_manager()->GetFullscreenPlayer()) { - ScopedJavaSurface scoped_surface(surface); - player->SetVideoSurface(scoped_surface.j_surface().obj()); - } - } - } -} - -} // anonymous namespace - -// Called from ChildProcessLauncher.java when the ChildProcess was -// started. -// |client_context| is the pointer to StartChildProcessCallback which was -// passed in from StartChildProcess. -// |handle| is the processID of the child process as originated in Java, 0 if -// the ChildProcess could not be created. -static void OnChildProcessStarted(JNIEnv*, - jclass, - jint client_context, - jint handle) { - StartChildProcessCallback* callback = - reinterpret_cast(client_context); - if (handle) - callback->Run(static_cast(handle)); - delete callback; -} - -void StartChildProcess( - const CommandLine::StringVector& argv, - const std::vector& files_to_register, - const StartChildProcessCallback& callback) { - JNIEnv* env = AttachCurrentThread(); - DCHECK(env); - - // Create the Command line String[] - ScopedJavaLocalRef j_argv = ToJavaArrayOfStrings(env, argv); - - size_t file_count = files_to_register.size(); - DCHECK(file_count > 0); - - ScopedJavaLocalRef j_file_ids(env, env->NewIntArray(file_count)); - base::android::CheckException(env); - jint* file_ids = env->GetIntArrayElements(j_file_ids.obj(), NULL); - base::android::CheckException(env); - ScopedJavaLocalRef j_file_fds(env, env->NewIntArray(file_count)); - base::android::CheckException(env); - jint* file_fds = env->GetIntArrayElements(j_file_fds.obj(), NULL); - base::android::CheckException(env); - ScopedJavaLocalRef j_file_auto_close( - env, env->NewBooleanArray(file_count)); - base::android::CheckException(env); - jboolean* file_auto_close = - env->GetBooleanArrayElements(j_file_auto_close.obj(), NULL); - base::android::CheckException(env); - for (size_t i = 0; i < file_count; ++i) { - const content::FileDescriptorInfo& fd_info = files_to_register[i]; - file_ids[i] = fd_info.id; - file_fds[i] = fd_info.fd.fd; - file_auto_close[i] = fd_info.fd.auto_close; - } - env->ReleaseIntArrayElements(j_file_ids.obj(), file_ids, 0); - env->ReleaseIntArrayElements(j_file_fds.obj(), file_fds, 0); - env->ReleaseBooleanArrayElements(j_file_auto_close.obj(), file_auto_close, 0); - - Java_ChildProcessLauncher_start(env, - base::android::GetApplicationContext(), - j_argv.obj(), - j_file_ids.obj(), - j_file_fds.obj(), - j_file_auto_close.obj(), - reinterpret_cast(new StartChildProcessCallback(callback))); -} - -void StopChildProcess(base::ProcessHandle handle) { - JNIEnv* env = AttachCurrentThread(); - DCHECK(env); - Java_ChildProcessLauncher_stop(env, static_cast(handle)); -} - -void EstablishSurfacePeer( - JNIEnv* env, jclass clazz, - jint pid, jobject surface, jint primary_id, jint secondary_id) { - ScopedJavaGlobalRef jsurface; - jsurface.Reset(env, surface); - if (jsurface.is_null()) - return; - - DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::UI)); - BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, base::Bind( - &SetSurfacePeer, jsurface, pid, primary_id, secondary_id)); -} - -jobject GetViewSurface(JNIEnv* env, jclass clazz, jint surface_id) { - // This is a synchronous call from the GPU process and is expected to be - // handled on a binder thread. Handling this on the UI thread will lead - // to deadlocks. - DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::UI)); - return CompositorImpl::GetSurface(surface_id); -} - -bool RegisterChildProcessLauncher(JNIEnv* env) { - return RegisterNativesImpl(env); -} - -} // namespace content diff --git a/content/browser/android/child_process_launcher.h b/content/browser/android/child_process_launcher.h deleted file mode 100644 index 4b152c6..0000000 --- a/content/browser/android/child_process_launcher.h +++ /dev/null @@ -1,37 +0,0 @@ -// 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. - -#ifndef CONTENT_BROWSER_ANDROID_CHILD_PROCESS_LAUNCHER_H_ -#define CONTENT_BROWSER_ANDROID_CHILD_PROCESS_LAUNCHER_H_ - -#include - -#include "base/callback.h" -#include "base/command_line.h" -#include "base/platform_file.h" -#include "base/process.h" -#include "content/public/browser/file_descriptor_info.h" - -namespace content { - -typedef base::Callback StartChildProcessCallback; -// Starts a process as a child process spawned by the Android -// ActivityManager. -// The created process handle is returned to the |callback| on success, 0 is -// retuned if the process could not be created. -void StartChildProcess( - const CommandLine::StringVector& argv, - const std::vector& files_to_register, - const StartChildProcessCallback& callback); - -// Stops a child process based on the handle returned form -// StartChildProcess. -void StopChildProcess(base::ProcessHandle handle); - -bool RegisterChildProcessLauncher(JNIEnv* env); - -} // namespace content - -#endif // CONTENT_BROWSER_ANDROID_CHILD_PROCESS_LAUNCHER_H_ - diff --git a/content/browser/android/child_process_launcher_android.cc b/content/browser/android/child_process_launcher_android.cc new file mode 100644 index 0000000..3a954dc --- /dev/null +++ b/content/browser/android/child_process_launcher_android.cc @@ -0,0 +1,158 @@ +// 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. + +#include "content/browser/android/child_process_launcher_android.h" + +#include "base/android/jni_android.h" +#include "base/android/jni_array.h" +#include "base/logging.h" +#include "base/memory/scoped_ptr.h" +#include "content/browser/android/media_player_manager_android.h" +#include "content/browser/renderer_host/compositor_impl_android.h" +#include "content/browser/renderer_host/render_view_host_impl.h" +#include "content/common/android/scoped_java_surface.h" +#include "content/public/browser/browser_thread.h" +#include "content/public/browser/render_process_host.h" +#include "jni/ChildProcessLauncher_jni.h" +#include "media/base/android/media_player_bridge.h" + +using base::android::AttachCurrentThread; +using base::android::ToJavaArrayOfStrings; +using base::android::ScopedJavaGlobalRef; +using base::android::ScopedJavaLocalRef; +using content::StartChildProcessCallback; + +namespace content { + +namespace { + +// Pass a java surface object to the MediaPlayerBridge object +// identified by render process handle, render view ID and player ID. +static void SetSurfacePeer( + const base::android::JavaRef& surface, + base::ProcessHandle render_process_handle, + int render_view_id, + int player_id) { + int renderer_id = 0; + RenderProcessHost::iterator it = RenderProcessHost::AllHostsIterator(); + while (!it.IsAtEnd()) { + if (it.GetCurrentValue()->GetHandle() == render_process_handle) { + renderer_id = it.GetCurrentValue()->GetID(); + break; + } + it.Advance(); + } + + if (renderer_id) { + RenderViewHostImpl* host = RenderViewHostImpl::FromID( + renderer_id, render_view_id); + if (host) { + media::MediaPlayerBridge* player = + host->media_player_manager()->GetPlayer(player_id); + if (player && + player != host->media_player_manager()->GetFullscreenPlayer()) { + ScopedJavaSurface scoped_surface(surface); + player->SetVideoSurface(scoped_surface.j_surface().obj()); + } + } + } +} + +} // anonymous namespace + +// Called from ChildProcessLauncher.java when the ChildProcess was +// started. +// |client_context| is the pointer to StartChildProcessCallback which was +// passed in from StartChildProcess. +// |handle| is the processID of the child process as originated in Java, 0 if +// the ChildProcess could not be created. +static void OnChildProcessStarted(JNIEnv*, + jclass, + jint client_context, + jint handle) { + StartChildProcessCallback* callback = + reinterpret_cast(client_context); + if (handle) + callback->Run(static_cast(handle)); + delete callback; +} + +void StartChildProcess( + const CommandLine::StringVector& argv, + const std::vector& files_to_register, + const StartChildProcessCallback& callback) { + JNIEnv* env = AttachCurrentThread(); + DCHECK(env); + + // Create the Command line String[] + ScopedJavaLocalRef j_argv = ToJavaArrayOfStrings(env, argv); + + size_t file_count = files_to_register.size(); + DCHECK(file_count > 0); + + ScopedJavaLocalRef j_file_ids(env, env->NewIntArray(file_count)); + base::android::CheckException(env); + jint* file_ids = env->GetIntArrayElements(j_file_ids.obj(), NULL); + base::android::CheckException(env); + ScopedJavaLocalRef j_file_fds(env, env->NewIntArray(file_count)); + base::android::CheckException(env); + jint* file_fds = env->GetIntArrayElements(j_file_fds.obj(), NULL); + base::android::CheckException(env); + ScopedJavaLocalRef j_file_auto_close( + env, env->NewBooleanArray(file_count)); + base::android::CheckException(env); + jboolean* file_auto_close = + env->GetBooleanArrayElements(j_file_auto_close.obj(), NULL); + base::android::CheckException(env); + for (size_t i = 0; i < file_count; ++i) { + const content::FileDescriptorInfo& fd_info = files_to_register[i]; + file_ids[i] = fd_info.id; + file_fds[i] = fd_info.fd.fd; + file_auto_close[i] = fd_info.fd.auto_close; + } + env->ReleaseIntArrayElements(j_file_ids.obj(), file_ids, 0); + env->ReleaseIntArrayElements(j_file_fds.obj(), file_fds, 0); + env->ReleaseBooleanArrayElements(j_file_auto_close.obj(), file_auto_close, 0); + + Java_ChildProcessLauncher_start(env, + base::android::GetApplicationContext(), + j_argv.obj(), + j_file_ids.obj(), + j_file_fds.obj(), + j_file_auto_close.obj(), + reinterpret_cast(new StartChildProcessCallback(callback))); +} + +void StopChildProcess(base::ProcessHandle handle) { + JNIEnv* env = AttachCurrentThread(); + DCHECK(env); + Java_ChildProcessLauncher_stop(env, static_cast(handle)); +} + +void EstablishSurfacePeer( + JNIEnv* env, jclass clazz, + jint pid, jobject surface, jint primary_id, jint secondary_id) { + ScopedJavaGlobalRef jsurface; + jsurface.Reset(env, surface); + if (jsurface.is_null()) + return; + + DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::UI)); + BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, base::Bind( + &SetSurfacePeer, jsurface, pid, primary_id, secondary_id)); +} + +jobject GetViewSurface(JNIEnv* env, jclass clazz, jint surface_id) { + // This is a synchronous call from the GPU process and is expected to be + // handled on a binder thread. Handling this on the UI thread will lead + // to deadlocks. + DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::UI)); + return CompositorImpl::GetSurface(surface_id); +} + +bool RegisterChildProcessLauncher(JNIEnv* env) { + return RegisterNativesImpl(env); +} + +} // namespace content diff --git a/content/browser/android/child_process_launcher_android.h b/content/browser/android/child_process_launcher_android.h new file mode 100644 index 0000000..e83e04e --- /dev/null +++ b/content/browser/android/child_process_launcher_android.h @@ -0,0 +1,36 @@ +// 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. + +#ifndef CONTENT_BROWSER_ANDROID_CHILD_PROCESS_LAUNCHER_ANDROID_H_ +#define CONTENT_BROWSER_ANDROID_CHILD_PROCESS_LAUNCHER_ANDROID_H_ + +#include + +#include "base/callback.h" +#include "base/command_line.h" +#include "base/platform_file.h" +#include "base/process.h" +#include "content/public/browser/file_descriptor_info.h" + +namespace content { + +typedef base::Callback StartChildProcessCallback; +// Starts a process as a child process spawned by the Android +// ActivityManager. +// The created process handle is returned to the |callback| on success, 0 is +// retuned if the process could not be created. +void StartChildProcess( + const CommandLine::StringVector& argv, + const std::vector& files_to_register, + const StartChildProcessCallback& callback); + +// Stops a child process based on the handle returned form +// StartChildProcess. +void StopChildProcess(base::ProcessHandle handle); + +bool RegisterChildProcessLauncher(JNIEnv* env); + +} // namespace content + +#endif // CONTENT_BROWSER_ANDROID_CHILD_PROCESS_LAUNCHER_ANDROID_H_ -- cgit v1.1