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

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

Issue 2814653003: [Android] BackgroundTaskScheduler reschedule implementation (Closed)
Patch Set: Rebasing Created 3 years, 7 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 unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.chrome.browser.offlinepages; 5 package org.chromium.chrome.browser.offlinepages;
6 6
7 import android.content.Context; 7 import android.content.Context;
8 8
9 import org.chromium.base.Callback; 9 import org.chromium.base.Callback;
10 import org.chromium.base.Log; 10 import org.chromium.base.Log;
(...skipping 29 matching lines...) Expand all
40 40
41 return BackgroundOfflinerTask.startBackgroundRequestsImpl( 41 return BackgroundOfflinerTask.startBackgroundRequestsImpl(
42 mBackgroundProcessor, context, taskParameters.getExtras(), wrapC allback(callback)); 42 mBackgroundProcessor, context, taskParameters.getExtras(), wrapC allback(callback));
43 } 43 }
44 44
45 @Override 45 @Override
46 public boolean onStopTask(Context context, TaskParameters taskParameters) { 46 public boolean onStopTask(Context context, TaskParameters taskParameters) {
47 return mBackgroundProcessor.stopScheduledProcessing(); 47 return mBackgroundProcessor.stopScheduledProcessing();
48 } 48 }
49 49
50 @Override
51 public void reschedule(Context context) {
52 BackgroundScheduler.getInstance(context).rescheduleOfflinePagesTasksOnUp grade();
53 }
54
50 /** Wraps the callback for code reuse */ 55 /** Wraps the callback for code reuse */
51 private Callback<Boolean> wrapCallback(final TaskFinishedCallback callback) { 56 private Callback<Boolean> wrapCallback(final TaskFinishedCallback callback) {
52 return new Callback<Boolean>() { 57 return new Callback<Boolean>() {
53 @Override 58 @Override
54 public void onResult(Boolean result) { 59 public void onResult(Boolean result) {
55 callback.taskFinished(result); 60 callback.taskFinished(result);
56 } 61 }
57 }; 62 };
58 } 63 }
59 64
60 private static void launchBrowserIfNecessary(Context context) { 65 private static void launchBrowserIfNecessary(Context context) {
61 if (BrowserStartupController.get(LibraryProcessType.PROCESS_BROWSER) 66 if (BrowserStartupController.get(LibraryProcessType.PROCESS_BROWSER)
62 .isStartupSuccessfullyCompleted()) { 67 .isStartupSuccessfullyCompleted()) {
63 return; 68 return;
64 } 69 }
65 70
66 // TODO(fgorski): This method is taken from ChromeBackgroundService as a local fix and will 71 // TODO(fgorski): This method is taken from ChromeBackgroundService as a local fix and will
67 // be removed with BackgroundTaskScheduler supporting GcmNetworkManager scheduling. 72 // be removed with BackgroundTaskScheduler supporting GcmNetworkManager scheduling.
68 try { 73 try {
69 ChromeBrowserInitializer.getInstance(context).handleSynchronousStart up(); 74 ChromeBrowserInitializer.getInstance(context).handleSynchronousStart up();
70 } catch (ProcessInitException e) { 75 } catch (ProcessInitException e) {
71 Log.e(TAG, "ProcessInitException while starting the browser process. "); 76 Log.e(TAG, "ProcessInitException while starting the browser process. ");
72 // Since the library failed to initialize nothing in the application can work, so kill 77 // Since the library failed to initialize nothing in the application can work, so kill
73 // the whole application not just the activity. 78 // the whole application not just the activity.
74 System.exit(-1); 79 System.exit(-1);
75 } 80 }
76 } 81 }
77 } 82 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698