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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/offlinepages/OfflineBackgroundTask.java

Issue 2774193002: [Offline pages] Ensuring native init when OBT run though JobScheduler (Closed)
Patch Set: Created 3 years, 9 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/java/src/org/chromium/chrome/browser/offlinepages/OfflineBackgroundTask.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/offlinepages/OfflineBackgroundTask.java b/chrome/android/java/src/org/chromium/chrome/browser/offlinepages/OfflineBackgroundTask.java
index 4a1c67d7d38aea60bad3bbcc11eb9eb46097b19c..938e6446ebcd58a6bb8aa8b8862497201556d162 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/offlinepages/OfflineBackgroundTask.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/offlinepages/OfflineBackgroundTask.java
@@ -7,6 +7,10 @@ package org.chromium.chrome.browser.offlinepages;
import android.content.Context;
import org.chromium.base.Callback;
+import org.chromium.base.Log;
+import org.chromium.base.library_loader.LibraryLoader;
+import org.chromium.base.library_loader.ProcessInitException;
+import org.chromium.chrome.browser.init.ChromeBrowserInitializer;
import org.chromium.chrome.browser.offlinepages.interfaces.BackgroundSchedulerProcessor;
import org.chromium.components.background_task_scheduler.BackgroundTask;
import org.chromium.components.background_task_scheduler.BackgroundTask.TaskFinishedCallback;
@@ -17,6 +21,8 @@ import org.chromium.components.background_task_scheduler.TaskParameters;
* Handles servicing background offlining requests coming via background_task_scheduler component.
*/
public class OfflineBackgroundTask implements BackgroundTask {
+ private static final String TAG = "OPBackgroundTask";
+
BackgroundSchedulerProcessor mBackgroundProcessor;
public OfflineBackgroundTask() {
@@ -27,6 +33,10 @@ public class OfflineBackgroundTask implements BackgroundTask {
public boolean onStartTask(
Context context, TaskParameters taskParameters, TaskFinishedCallback callback) {
assert taskParameters.getTaskId() == TaskIds.OFFLINE_PAGES_BACKGROUND_JOB_ID;
+
+ // Ensuring that native potion of the browser is launched.
+ launchBrowserIfNecessary(context);
+
return BackgroundOfflinerTask.startBackgroundRequestsImpl(
mBackgroundProcessor, context, taskParameters.getExtras(), wrapCallback(callback));
}
@@ -45,4 +55,19 @@ public class OfflineBackgroundTask implements BackgroundTask {
}
};
}
+
+ private static void launchBrowserIfNecessary(Context context) {
+ if (LibraryLoader.isInitialized()) return;
+
+ // TODO(fgorski): This method is taken from ChromeBackgroundService as a local fix and will
+ // be removed with BackgroundTaskScheduler supporting GcmNetworkManager scheduling.
+ try {
+ ChromeBrowserInitializer.getInstance(context).handleSynchronousStartup();
+ } catch (ProcessInitException e) {
+ Log.e(TAG, "ProcessInitException while starting the browser process.");
+ // Since the library failed to initialize nothing in the application can work, so kill
+ // the whole application not just the activity.
+ System.exit(-1);
+ }
+ }
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698