Commit de2fded6 authored by qinmin's avatar qinmin Committed by Commit bot

Remove DownloadProcessService code path

Chrome now uses the browser process for background download resumption.
We don't need a separate process for this, remove the code.

TBR=palmer@chromium.org

Review-Url: https://codereview.chromium.org/2365093002
Cr-Commit-Position: refs/heads/master@{#423737}
parent c302c1e3
...@@ -797,17 +797,6 @@ android:value="true" /> ...@@ -797,17 +797,6 @@ android:value="true" />
android:exported="false" /> android:exported="false" />
{% endfor %} {% endfor %}
<!-- Background download process, it may outlive chrome if download does not finish
when user kills chrome. Once created, the process will manage its own lifecycle.
To work around an issue in earlier android versions that a bound service will
get killed when chrome goes away, this service will only communicate with the
browser process through callbacks. -->
<service android:name="org.chromium.content.app.DownloadProcessService"
android:process=":download"
android:permission="{{ manifest_package }}.permission.CHILD_SERVICE"
android:isolatedProcess="false"
android:exported="false"/>
<receiver android:name="org.chromium.chrome.browser.download.DownloadBroadcastReceiver" <receiver android:name="org.chromium.chrome.browser.download.DownloadBroadcastReceiver"
android:exported="false"> android:exported="false">
<intent-filter> <intent-filter>
......
...@@ -115,7 +115,6 @@ template("implement_content_app") { ...@@ -115,7 +115,6 @@ template("implement_content_app") {
"android/content_jni_onload.cc", "android/content_jni_onload.cc",
"android/content_main.cc", "android/content_main.cc",
"android/content_main.h", "android/content_main.h",
"android/download_main.cc",
"android/library_loader_hooks.cc", "android/library_loader_hooks.cc",
"android/library_loader_hooks.h", "android/library_loader_hooks.h",
] ]
......
// Copyright 2016 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 "base/message_loop/message_loop.h"
#include "base/run_loop.h"
#include "base/threading/platform_thread.h"
#include "content/public/common/main_function_params.h"
namespace content {
// Mainline routine for running as the download process.
int DownloadMain(const MainFunctionParams& parameters) {
// The main message loop of the utility process.
base::MessageLoop main_message_loop;
base::PlatformThread::SetName("CrDownloadMain");
base::RunLoop().Run();
return 0;
}
} // namespace content
...@@ -120,9 +120,6 @@ extern int PpapiBrokerMain(const MainFunctionParams&); ...@@ -120,9 +120,6 @@ extern int PpapiBrokerMain(const MainFunctionParams&);
#endif #endif
extern int RendererMain(const content::MainFunctionParams&); extern int RendererMain(const content::MainFunctionParams&);
extern int UtilityMain(const MainFunctionParams&); extern int UtilityMain(const MainFunctionParams&);
#if defined(OS_ANDROID)
extern int DownloadMain(const MainFunctionParams&);
#endif
} // namespace content } // namespace content
namespace content { namespace content {
...@@ -390,9 +387,6 @@ int RunNamedProcessTypeMain( ...@@ -390,9 +387,6 @@ int RunNamedProcessTypeMain(
{ switches::kUtilityProcess, UtilityMain }, { switches::kUtilityProcess, UtilityMain },
{ switches::kRendererProcess, RendererMain }, { switches::kRendererProcess, RendererMain },
{ switches::kGpuProcess, GpuMain }, { switches::kGpuProcess, GpuMain },
#if defined(OS_ANDROID)
{ switches::kDownloadProcess, DownloadMain},
#endif
#endif // !CHROME_MULTIPLE_DLL_BROWSER #endif // !CHROME_MULTIPLE_DLL_BROWSER
}; };
......
...@@ -15,16 +15,12 @@ ...@@ -15,16 +15,12 @@
#include "base/android/jni_array.h" #include "base/android/jni_array.h"
#include "base/logging.h" #include "base/logging.h"
#include "content/browser/android/scoped_surface_request_manager.h" #include "content/browser/android/scoped_surface_request_manager.h"
#include "content/browser/file_descriptor_info_impl.h"
#include "content/browser/frame_host/render_frame_host_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/browser_media_player_manager.h"
#include "content/browser/media/android/media_web_contents_observer_android.h" #include "content/browser/media/android/media_web_contents_observer_android.h"
#include "content/browser/web_contents/web_contents_impl.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/browser_thread.h"
#include "content/public/browser/content_browser_client.h"
#include "content/public/browser/render_process_host.h" #include "content/public/browser/render_process_host.h"
#include "content/public/common/content_client.h"
#include "content/public/common/content_switches.h" #include "content/public/common/content_switches.h"
#include "jni/ChildProcessLauncher_jni.h" #include "jni/ChildProcessLauncher_jni.h"
#include "media/base/android/media_player_android.h" #include "media/base/android/media_player_android.h"
...@@ -92,21 +88,6 @@ static void SetSurfacePeer( ...@@ -92,21 +88,6 @@ static void SetSurfacePeer(
} }
} }
void LaunchDownloadProcess(base::CommandLine* cmd_line) {
std::unique_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_startDownloadProcessIfNecessary(
env, base::android::GetApplicationContext(), j_argv);
}
} // anonymous namespace } // anonymous namespace
// Called from ChildProcessLauncher.java when the ChildProcess was // Called from ChildProcessLauncher.java when the ChildProcess was
...@@ -126,32 +107,6 @@ static void OnChildProcessStarted(JNIEnv*, ...@@ -126,32 +107,6 @@ static void OnChildProcessStarted(JNIEnv*,
delete callback; delete callback;
} }
void StartDownloadProcessIfNecessary() {
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);
const base::CommandLine browser_command_line =
*base::CommandLine::ForCurrentProcess();
static const char* const 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( void StartChildProcess(
const base::CommandLine::StringVector& argv, const base::CommandLine::StringVector& argv,
int child_process_id, int child_process_id,
......
...@@ -32,10 +32,6 @@ void StartChildProcess( ...@@ -32,10 +32,6 @@ void StartChildProcess(
const std::map<int, base::MemoryMappedFile::Region>& regions, const std::map<int, base::MemoryMappedFile::Region>& regions,
const StartChildProcessCallback& callback); const StartChildProcessCallback& callback);
// Starts the background download process if it hasn't been started.
// TODO(qinmin): pass the download parameters here and pass it to java side.
void StartDownloadProcessIfNecessary();
// Stops a child process based on the handle returned form // Stops a child process based on the handle returned form
// StartChildProcess. // StartChildProcess.
void StopChildProcess(base::ProcessHandle handle); void StopChildProcess(base::ProcessHandle handle);
......
...@@ -74,7 +74,6 @@ android_library("content_java") { ...@@ -74,7 +74,6 @@ android_library("content_java") {
"java/src/org/chromium/content/app/ChromiumLinkerParams.java", "java/src/org/chromium/content/app/ChromiumLinkerParams.java",
"java/src/org/chromium/content/app/ContentApplication.java", "java/src/org/chromium/content/app/ContentApplication.java",
"java/src/org/chromium/content/app/ContentMain.java", "java/src/org/chromium/content/app/ContentMain.java",
"java/src/org/chromium/content/app/DownloadProcessService.java",
"java/src/org/chromium/content/app/PrivilegedProcessService.java", "java/src/org/chromium/content/app/PrivilegedProcessService.java",
"java/src/org/chromium/content/app/PrivilegedProcessService0.java", "java/src/org/chromium/content/app/PrivilegedProcessService0.java",
"java/src/org/chromium/content/app/PrivilegedProcessService1.java", "java/src/org/chromium/content/app/PrivilegedProcessService1.java",
......
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2016 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.
-->
<resources>
<!-- Download service notification -->
<item type="id" name="download_service_notification" />
</resources>
...@@ -28,7 +28,6 @@ import org.chromium.base.library_loader.Linker; ...@@ -28,7 +28,6 @@ import org.chromium.base.library_loader.Linker;
import org.chromium.base.library_loader.ProcessInitException; import org.chromium.base.library_loader.ProcessInitException;
import org.chromium.content.browser.ChildProcessConstants; import org.chromium.content.browser.ChildProcessConstants;
import org.chromium.content.browser.ChildProcessCreationParams; import org.chromium.content.browser.ChildProcessCreationParams;
import org.chromium.content.common.ContentSwitches;
import org.chromium.content.common.FileDescriptorInfo; import org.chromium.content.common.FileDescriptorInfo;
import org.chromium.content.common.IChildProcessCallback; import org.chromium.content.common.IChildProcessCallback;
import org.chromium.content.common.IChildProcessService; import org.chromium.content.common.IChildProcessService;
...@@ -49,7 +48,6 @@ import java.util.concurrent.atomic.AtomicReference; ...@@ -49,7 +48,6 @@ import java.util.concurrent.atomic.AtomicReference;
public class ChildProcessServiceImpl { public class ChildProcessServiceImpl {
private static final String MAIN_THREAD_NAME = "ChildProcessMain"; private static final String MAIN_THREAD_NAME = "ChildProcessMain";
private static final String TAG = "ChildProcessService"; private static final String TAG = "ChildProcessService";
protected static final FileDescriptorInfo[] EMPTY_FILE_DESCRIPTOR_INFO = {};
private IChildProcessCallback mCallback; private IChildProcessCallback mCallback;
// This is the native "Main" thread for the renderer / utility process. // This is the native "Main" thread for the renderer / utility process.
...@@ -312,11 +310,6 @@ public class ChildProcessServiceImpl { ...@@ -312,11 +310,6 @@ public class ChildProcessServiceImpl {
// http://stackoverflow.com/questions/8745893/i-dont-get-why-this-classcastexception-occurs // http://stackoverflow.com/questions/8745893/i-dont-get-why-this-classcastexception-occurs
mFdInfos = new FileDescriptorInfo[fdInfosAsParcelable.length]; mFdInfos = new FileDescriptorInfo[fdInfosAsParcelable.length];
System.arraycopy(fdInfosAsParcelable, 0, mFdInfos, 0, fdInfosAsParcelable.length); System.arraycopy(fdInfosAsParcelable, 0, mFdInfos, 0, fdInfosAsParcelable.length);
} else {
String processType = ContentSwitches.getSwitchValue(
mCommandLineParams, ContentSwitches.SWITCH_PROCESS_TYPE);
assert ContentSwitches.SWITCH_DOWNLOAD_PROCESS.equals(processType);
mFdInfos = EMPTY_FILE_DESCRIPTOR_INFO;
} }
Bundle sharedRelros = bundle.getBundle(Linker.EXTRA_LINKER_SHARED_RELROS); Bundle sharedRelros = bundle.getBundle(Linker.EXTRA_LINKER_SHARED_RELROS);
if (sharedRelros != null) { if (sharedRelros != null) {
......
// Copyright 2016 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.
package org.chromium.content.app;
import android.annotation.SuppressLint;
import android.app.Notification;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.os.IBinder;
import android.os.RemoteException;
import org.chromium.base.Log;
import org.chromium.base.annotations.JNINamespace;
import org.chromium.content.R;
import org.chromium.content.browser.ChildProcessConstants;
import org.chromium.content.common.IChildProcessCallback;
/**
* Background download process for handling all transferable downloads.
*/
@JNINamespace("content")
public class DownloadProcessService extends ChildProcessService {
private static final String TAG = "DownloadProcess";
private long mClientContext;
private IChildProcessCallback mCallback;
private int mDownloadCount;
@Override
public void onCreate() {
super.onCreate();
// TODO(qinmin): Use the first pending download as notification, or
// get a more proper notification for this.
startForeground(R.id.download_service_notification, new Notification());
}
@Override
@SuppressLint("NewApi")
public int onStartCommand(Intent intent, int flags, int startId) {
assert Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2;
initializeParams(intent);
Bundle bundle = intent.getExtras();
if (bundle != null) {
IBinder binder = bundle.getBinder(ChildProcessConstants.EXTRA_CHILD_PROCESS_CALLBACK);
mCallback = IChildProcessCallback.Stub.asInterface(binder);
getServiceInfo(bundle);
}
return START_STICKY;
}
/**
* Will be called by the native side when a download starts or is rejected.
*
* @CalledByNative
*/
private void onDownloadStarted(boolean started, int downloadId) {
if (mCallback != null) {
try {
mCallback.onDownloadStarted(started, downloadId);
} catch (RemoteException e) {
Log.e(TAG, "Unable to callback the browser process.", e);
}
}
if (started) mDownloadCount++;
}
/**
* Will be called by the native side when a download completes.
*
* @CalledByNative
*/
private void onDownloadCompleted(boolean success) {
mDownloadCount--;
if (mDownloadCount == 0) stopSelf();
}
}
\ No newline at end of file
...@@ -19,11 +19,4 @@ public class ChildProcessConstants { ...@@ -19,11 +19,4 @@ public class ChildProcessConstants {
// Used to pass the CPU features mask to child processes. // Used to pass the CPU features mask to child processes.
public static final String EXTRA_CPU_FEATURES = public static final String EXTRA_CPU_FEATURES =
"com.google.android.apps.chrome.extra.cpu_features"; "com.google.android.apps.chrome.extra.cpu_features";
// Used to pass the IChildProcessCallback to a child process. For a started service,
// file descriptors cannot be passed in the intent that starts the service. As a result,
// a Binder object needs to be passed through which the child process can retrieve the file
// descriptors.
public static final String EXTRA_CHILD_PROCESS_CALLBACK =
"com.google.android.apps.chrome.extra.child_process_callback";
} }
...@@ -4,14 +4,11 @@ ...@@ -4,14 +4,11 @@
package org.chromium.content.browser; package org.chromium.content.browser;
import android.annotation.SuppressLint;
import android.content.ComponentName; import android.content.ComponentName;
import android.content.Context; import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo; import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.graphics.SurfaceTexture; import android.graphics.SurfaceTexture;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.os.ParcelFileDescriptor; import android.os.ParcelFileDescriptor;
import android.os.RemoteException; import android.os.RemoteException;
...@@ -29,7 +26,6 @@ import org.chromium.base.annotations.CalledByNative; ...@@ -29,7 +26,6 @@ import org.chromium.base.annotations.CalledByNative;
import org.chromium.base.annotations.JNINamespace; import org.chromium.base.annotations.JNINamespace;
import org.chromium.base.library_loader.Linker; import org.chromium.base.library_loader.Linker;
import org.chromium.content.app.ChromiumLinkerParams; import org.chromium.content.app.ChromiumLinkerParams;
import org.chromium.content.app.DownloadProcessService;
import org.chromium.content.app.PrivilegedProcessService; import org.chromium.content.app.PrivilegedProcessService;
import org.chromium.content.app.SandboxedProcessService; import org.chromium.content.app.SandboxedProcessService;
import org.chromium.content.common.ContentSwitches; import org.chromium.content.common.ContentSwitches;
...@@ -55,7 +51,6 @@ public class ChildProcessLauncher { ...@@ -55,7 +51,6 @@ public class ChildProcessLauncher {
static final int CALLBACK_FOR_GPU_PROCESS = 1; static final int CALLBACK_FOR_GPU_PROCESS = 1;
static final int CALLBACK_FOR_RENDERER_PROCESS = 2; static final int CALLBACK_FOR_RENDERER_PROCESS = 2;
static final int CALLBACK_FOR_UTILITY_PROCESS = 3; static final int CALLBACK_FOR_UTILITY_PROCESS = 3;
static final int CALLBACK_FOR_DOWNLOAD_PROCESS = 4;
private static class ChildConnectionAllocator { private static class ChildConnectionAllocator {
// Connections to services. Indices of the array correspond to the service numbers. // Connections to services. Indices of the array correspond to the service numbers.
...@@ -735,39 +730,6 @@ public class ChildProcessLauncher { ...@@ -735,39 +730,6 @@ public class ChildProcessLauncher {
callbackType, inSandbox, params); callbackType, inSandbox, params);
} }
/**
* Spawns a background download process if it hasn't been started. The download process will
* manage its own lifecyle and can outlive chrome.
*
* @param context Context used to obtain the application context.
* @param commandLine The child process command line argv.
*/
@SuppressLint("NewApi")
@CalledByNative
private static void startDownloadProcessIfNecessary(
Context context, final String[] commandLine) {
assert Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2;
String processType =
ContentSwitches.getSwitchValue(commandLine, ContentSwitches.SWITCH_PROCESS_TYPE);
assert ContentSwitches.SWITCH_DOWNLOAD_PROCESS.equals(processType);
Intent intent = new Intent();
intent.setClass(context, DownloadProcessService.class);
intent.setPackage(context.getPackageName());
intent.putExtra(ChildProcessConstants.EXTRA_COMMAND_LINE, commandLine);
Bundle bundle =
createsServiceBundle(commandLine, null, Linker.getInstance().getSharedRelros());
// Pid doesn't matter for download process.
bundle.putBinder(ChildProcessConstants.EXTRA_CHILD_PROCESS_CALLBACK,
createCallback(0, CALLBACK_FOR_DOWNLOAD_PROCESS).asBinder());
intent.putExtras(bundle);
ChromiumLinkerParams linkerParams = getLinkerParamsForNewConnection();
if (linkerParams != null) {
linkerParams.addIntentExtras(intent);
}
context.startService(intent);
}
private static void startInternal( private static void startInternal(
Context context, Context context,
final String[] commandLine, final String[] commandLine,
...@@ -972,15 +934,6 @@ public class ChildProcessLauncher { ...@@ -972,15 +934,6 @@ public class ChildProcessLauncher {
return ChildProcessLauncher.getSurfaceTextureSurface(surfaceTextureId, return ChildProcessLauncher.getSurfaceTextureSurface(surfaceTextureId,
childProcessId); childProcessId);
} }
@Override
public void onDownloadStarted(boolean started, int downloadId) {
// TODO(qinmin): call native to cancel or proceed with the download.
if (callbackType != CALLBACK_FOR_DOWNLOAD_PROCESS) {
Log.e(TAG, "Illegal callback for non-download process.");
return;
}
}
}; };
} }
......
...@@ -81,9 +81,6 @@ public abstract class ContentSwitches { ...@@ -81,9 +81,6 @@ public abstract class ContentSwitches {
// Native switch kGPUProcess // Native switch kGPUProcess
public static final String SWITCH_GPU_PROCESS = "gpu-process"; public static final String SWITCH_GPU_PROCESS = "gpu-process";
// Native switch kDownloadProcess
public static final String SWITCH_DOWNLOAD_PROCESS = "download";
// Prevent instantiation. // Prevent instantiation.
private ContentSwitches() {} private ContentSwitches() {}
......
...@@ -24,8 +24,4 @@ interface IChildProcessCallback { ...@@ -24,8 +24,4 @@ interface IChildProcessCallback {
void unregisterSurfaceTextureSurface(int surfaceTextureId, int clientId); void unregisterSurfaceTextureSurface(int surfaceTextureId, int clientId);
SurfaceWrapper getSurfaceTextureSurface(int surfaceTextureId); SurfaceWrapper getSurfaceTextureSurface(int surfaceTextureId);
// Callback to inform native that the download service has accepted or
// rejected the download.
void onDownloadStarted(boolean started, int downloadId);
} }
...@@ -320,9 +320,6 @@ const char kDisableZeroCopyDxgiVideo[] = "disable-zero-copy-dxgi-video"; ...@@ -320,9 +320,6 @@ const char kDisableZeroCopyDxgiVideo[] = "disable-zero-copy-dxgi-video";
// based tests. // based tests.
const char kDomAutomationController[] = "dom-automation"; const char kDomAutomationController[] = "dom-automation";
// Causes the process to run as a download subprocess.
const char kDownloadProcess[] = "download";
// Disable antialiasing on 2d canvas clips // Disable antialiasing on 2d canvas clips
const char kDisable2dCanvasClipAntialiasing[] = "disable-2d-canvas-clip-aa"; const char kDisable2dCanvasClipAntialiasing[] = "disable-2d-canvas-clip-aa";
......
...@@ -103,7 +103,6 @@ extern const char kDisableXSSAuditor[]; ...@@ -103,7 +103,6 @@ extern const char kDisableXSSAuditor[];
CONTENT_EXPORT extern const char kDisableZeroCopy[]; CONTENT_EXPORT extern const char kDisableZeroCopy[];
CONTENT_EXPORT extern const char kDisableZeroCopyDxgiVideo[]; CONTENT_EXPORT extern const char kDisableZeroCopyDxgiVideo[];
CONTENT_EXPORT extern const char kDomAutomationController[]; CONTENT_EXPORT extern const char kDomAutomationController[];
CONTENT_EXPORT extern const char kDownloadProcess[];
extern const char kDisable2dCanvasClipAntialiasing[]; extern const char kDisable2dCanvasClipAntialiasing[];
CONTENT_EXPORT extern const char kEnableAggressiveDOMStorageFlushing[]; CONTENT_EXPORT extern const char kEnableAggressiveDOMStorageFlushing[];
CONTENT_EXPORT extern const char kEnablePreferCompositingToLCDText[]; CONTENT_EXPORT extern const char kEnablePreferCompositingToLCDText[];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment