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

Unified Diff: content/public/android/java/src/org/chromium/content/app/ChildProcessService.java

Issue 1622743005: Introduce background Download process to android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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/public/android/java/src/org/chromium/content/app/ChildProcessService.java
diff --git a/content/public/android/java/src/org/chromium/content/app/ChildProcessService.java b/content/public/android/java/src/org/chromium/content/app/ChildProcessService.java
index 849f9c753402e4a393219a229bacde645bc97429..2d6352b4e895447e96092a452ac6691f98da62fa 100644
--- a/content/public/android/java/src/org/chromium/content/app/ChildProcessService.java
+++ b/content/public/android/java/src/org/chromium/content/app/ChildProcessService.java
@@ -51,6 +51,7 @@ import java.util.concurrent.atomic.AtomicReference;
public class ChildProcessService extends Service {
private static final String MAIN_THREAD_NAME = "ChildProcessMain";
private static final String TAG = "ChildProcessService";
+ protected static final FileDescriptorInfo[] EMPTY_FILE_DESCRIPTOR_INFO = {};
private IChildProcessCallback mCallback;
// This is the native "Main" thread for the renderer / utility process.
@@ -89,6 +90,7 @@ public class ChildProcessService extends Service {
// NOTE: Implement any IChildProcessService methods here.
@Override
public int setupConnection(Bundle args, IChildProcessCallback callback) {
+ assert isBoundService();
mCallback = callback;
getServiceInfo(args);
return Process.myPid();
@@ -237,6 +239,7 @@ public class ChildProcessService extends Service {
@Override
public IBinder onBind(Intent intent) {
+ assert isBoundService();
// We call stopSelf() to request that this service be stopped as soon as the client
// unbinds. Otherwise the system may keep it around and available for a reconnect. The
// child processes do not currently support reconnect; they must be initialized from
@@ -289,10 +292,7 @@ public class ChildProcessService extends Service {
mFdInfos = new FileDescriptorInfo[fdInfosAsParcelable.length];
System.arraycopy(fdInfosAsParcelable, 0, mFdInfos, 0, fdInfosAsParcelable.length);
} else {
- // TODO(qinmin): On earlier androird versions, a started service running in another
- // process can get killed after Chrome is killed. To work around this issue, client
- // will never bind to the service. As a result, the file descriptors needs to be
- // passed through an intent when starting the service.
+ mFdInfos = getFileDescriptorInfo(bundle);
svaldez 2016/01/25 15:33:43 Move to DownloadServiceProcess, so that ChildServi
qinmin 2016/01/25 22:48:23 Let the DownloadServiceProcess override getService
}
Bundle sharedRelros = bundle.getBundle(Linker.EXTRA_LINKER_SHARED_RELROS);
if (sharedRelros != null) {
@@ -412,6 +412,23 @@ public class ChildProcessService extends Service {
}
/**
+ * Retrive an array of FileDescriptorInfo from a bundle.
+ * @param bundle The bundle through the intent to launch the service.
+ * @return an array of FileDescriptorInfo.
+ */
+ protected FileDescriptorInfo[] getFileDescriptorInfo(Bundle bundle) {
+ return EMPTY_FILE_DESCRIPTOR_INFO;
+ }
+
+ /**
+ * Check whether the service is a bound service or a started service.
+ * @return true if the service is bound, or false otherwise.
+ */
+ protected boolean isBoundService() {
+ return true;
+ }
+
+ /**
* Helper for registering FileDescriptorInfo objects with GlobalFileDescriptors.
* This includes the IPC channel, the crash dump signals and resource related
* files.

Powered by Google App Engine
This is Rietveld 408576698