Index: content/browser/android/child_process_launcher_android.cc |
diff --git a/content/browser/android/child_process_launcher_android.cc b/content/browser/android/child_process_launcher_android.cc |
index 471ce31d91c728f70f7430c8ec2827272e183722..f6b04e19f5377c47ab5d837d37ff7ab5044f9dd6 100644 |
--- a/content/browser/android/child_process_launcher_android.cc |
+++ b/content/browser/android/child_process_launcher_android.cc |
@@ -13,12 +13,16 @@ |
#include "base/android/jni_array.h" |
#include "base/logging.h" |
#include "base/memory/scoped_ptr.h" |
+#include "content/browser/file_descriptor_info_impl.h" |
#include "content/browser/frame_host/render_frame_host_impl.h" |
#include "content/browser/media/android/browser_media_player_manager.h" |
#include "content/browser/media/android/media_web_contents_observer_android.h" |
#include "content/browser/web_contents/web_contents_impl.h" |
+#include "content/common/child_process_host_impl.h" |
#include "content/public/browser/browser_thread.h" |
+#include "content/public/browser/content_browser_client.h" |
#include "content/public/browser/render_process_host.h" |
+#include "content/public/common/content_client.h" |
#include "content/public/common/content_switches.h" |
#include "jni/ChildProcessLauncher_jni.h" |
#include "media/base/android/media_player_android.h" |
@@ -88,6 +92,16 @@ static void SetSurfacePeer( |
#endif |
} |
+void EmptyCallback(base::ProcessHandle) {} |
+ |
+void LaunchDownloadProcess(base::CommandLine* cmd_line, int child_process_id) { |
+ scoped_ptr<base::CommandLine> cmd_line_deleter(cmd_line); |
+ StartChildProcess(cmd_line->argv(), child_process_id, |
no sievers
2016/02/02 01:37:38
How about a different Java entry point, if all the
qinmin
2016/02/02 20:51:41
Done. Call startDownloadProcess() in the java clas
|
+ FileDescriptorInfoImpl::Create(), |
+ std::map<int, base::MemoryMappedFile::Region>(), |
+ base::Bind(&EmptyCallback)); |
+} |
+ |
} // anonymous namespace |
// Called from ChildProcessLauncher.java when the ChildProcess was |
@@ -107,6 +121,36 @@ static void OnChildProcessStarted(JNIEnv*, |
delete callback; |
} |
+void StartDownloadProcess() { |
+ base::FilePath exe_path = content::ChildProcessHost::GetChildPath( |
+ content::ChildProcessHost::CHILD_NORMAL); |
+ if (exe_path.empty()) { |
+ NOTREACHED() << "Unable to get download process binary name."; |
+ return; |
+ } |
+ base::CommandLine* cmd_line = new base::CommandLine(exe_path); |
+ cmd_line->AppendSwitchASCII(switches::kProcessType, |
+ switches::kDownloadProcess); |
+ cmd_line->AppendSwitch(switches::kNoSandbox); |
+ int child_process_id = ChildProcessHostImpl::GenerateChildProcessUniqueId(); |
+ GetContentClient()->browser()->AppendExtraCommandLineSwitches( |
+ cmd_line, child_process_id); |
+ |
+ const base::CommandLine browser_command_line = |
+ *base::CommandLine::ForCurrentProcess(); |
+ static const char* kForwardSwitches[] = { |
+ switches::kDisableLogging, |
+ switches::kEnableLogging, |
+ switches::kLoggingLevel, |
+ }; |
+ cmd_line->CopySwitchesFrom(browser_command_line, kForwardSwitches, |
+ arraysize(kForwardSwitches)); |
+ CHECK(!cmd_line->HasSwitch(switches::kSingleProcess)); |
+ BrowserThread::PostTask( |
+ BrowserThread::PROCESS_LAUNCHER, FROM_HERE, |
+ base::Bind(&LaunchDownloadProcess, cmd_line, child_process_id)); |
+} |
+ |
void StartChildProcess( |
const base::CommandLine::StringVector& argv, |
int child_process_id, |
@@ -120,7 +164,6 @@ void StartChildProcess( |
ScopedJavaLocalRef<jobjectArray> j_argv = ToJavaArrayOfStrings(env, argv); |
size_t file_count = files_to_register->GetMappingSize(); |
- DCHECK(file_count > 0); |
ScopedJavaLocalRef<jclass> j_file_info_class = base::android::GetClass( |
env, "org/chromium/content/browser/FileDescriptorInfo"); |