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

Unified Diff: content/browser/android/child_process_launcher_android.cc

Issue 1622743005: Introduce background Download process to android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addressing siever's comments Created 4 years, 11 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
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 a3965809a825c13e29fd0fc16aa71e9aec976b60..cf11e2c106171327ede944566df33e126f9e8907 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"
@@ -84,6 +88,21 @@ static void SetSurfacePeer(
}
}
+void LaunchDownloadProcess(base::CommandLine* cmd_line) {
+ scoped_ptr<base::CommandLine> cmd_line_deleter(cmd_line);
+
+ JNIEnv* env = AttachCurrentThread();
+ DCHECK(env);
+
+ // Create the Command line String[]
+ ScopedJavaLocalRef<jobjectArray> j_argv =
+ ToJavaArrayOfStrings(env, cmd_line->argv());
+
+ // TODO(qinmin): pass download parameters here.
+ Java_ChildProcessLauncher_startDownloadProcess(
+ env, base::android::GetApplicationContext(), j_argv.obj());
+}
+
} // anonymous namespace
// Called from ChildProcessLauncher.java when the ChildProcess was
@@ -103,6 +122,35 @@ 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();
no sievers 2016/02/03 22:46:51 This is not needed right? It's not a normal ChildP
qinmin 2016/02/03 23:37:36 removed. I was just not sure whether we need any f
+ 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));
+}
+
void StartChildProcess(
const base::CommandLine::StringVector& argv,
int child_process_id,
@@ -116,7 +164,6 @@ void StartChildProcess(
ScopedJavaLocalRef<jobjectArray> j_argv = ToJavaArrayOfStrings(env, argv);
size_t file_count = files_to_register->GetMappingSize();
- DCHECK(file_count > 0);
no sievers 2016/02/03 22:46:51 This DCHECK() can stay now, right?
qinmin 2016/02/03 23:37:36 Done.
ScopedJavaLocalRef<jclass> j_file_info_class = base::android::GetClass(
env, "org/chromium/content/browser/FileDescriptorInfo");

Powered by Google App Engine
This is Rietveld 408576698