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

Unified Diff: content/public/android/java/src/org/chromium/content/app/DownloadProcessService.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/DownloadProcessService.java
diff --git a/content/public/android/java/src/org/chromium/content/app/DownloadProcessService.java b/content/public/android/java/src/org/chromium/content/app/DownloadProcessService.java
new file mode 100644
index 0000000000000000000000000000000000000000..906f32a207d1d437841575c5526d79a2e5320f84
--- /dev/null
+++ b/content/public/android/java/src/org/chromium/content/app/DownloadProcessService.java
@@ -0,0 +1,63 @@
+// Copyright 2015 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.browser.ChildProcessConstants;
+import org.chromium.content.browser.FileDescriptorInfo;
+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";
+ @Override
+ public void onCreate() {
+ super.onCreate();
+ // TODO(qinmin): Use the first pending download as notification, or
+ // get a more proper notification for this.
+ startForeground(ChildProcessConstants.DOWNLOAD_PROCESS_NOTIFICATION_ID, new Notification());
+ }
+
+ @Override
+ protected boolean isBoundService() {
+ return false;
+ }
+
+ @Override
+ public int onStartCommand(Intent intent, int flags, int startId) {
+ assert !isBoundService();
svaldez 2016/01/25 15:33:43 Remove isBoundsService. (Seems to only state wheth
qinmin 2016/01/25 22:48:23 Done.
+ initializeParams(intent);
+ getServiceInfo(intent.getExtras());
svaldez 2016/01/25 15:33:43 Locally override getServiceInfo instead of modifyi
qinmin 2016/01/25 22:48:23 hmm... That's a lot of duplicated code. And i need
+ return START_STICKY;
+ }
+
+ @Override
+ @SuppressLint("NewApi")
+ protected FileDescriptorInfo[] getFileDescriptorInfo(Bundle bundle) {
+ assert Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2;
+ IBinder binder = bundle.getBinder(ChildProcessConstants.EXTRA_CHILD_PROCESS_CALLBACK);
+ IChildProcessCallback callback = IChildProcessCallback.Stub.asInterface(binder);
+ String channel = bundle.getString(ChildProcessConstants.EXTRA_CHANNEL_ID);
+ try {
+ return callback.getFileDescriptorInfo(channel);
+ } catch (RemoteException e) {
+ Log.e(TAG, "Unable to get file descriptors.");
+ stopSelf();
+ }
+ return EMPTY_FILE_DESCRIPTOR_INFO;
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698