| 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..d0d38a998dd2f1dbb9f5f84216279e2753eda4b8
|
| --- /dev/null
|
| +++ b/content/public/android/java/src/org/chromium/content/app/DownloadProcessService.java
|
| @@ -0,0 +1,57 @@
|
| +// 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
|
| + public int onStartCommand(Intent intent, int flags, int startId) {
|
| + initializeParams(intent);
|
| + getServiceInfo(intent.getExtras());
|
| + 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;
|
| + }
|
| +}
|
|
|