org.chromium.chrome.browser.ntp.snippets.SnippetsLauncher Java Examples

The following examples show how to use org.chromium.chrome.browser.ntp.snippets.SnippetsLauncher. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ChromeBackgroundService.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
private void rescheduleSnippetsTasksOnUpgrade() {
    if (SnippetsLauncher.shouldRescheduleTasksOnUpgrade()) {
        if (!SnippetsLauncher.hasInstance()) {
            launchBrowser(this, /*tag=*/""); // The |tag| doesn't matter here.
        }
        rescheduleFetching();
    }
}
 
Example #2
Source File: ChromeBackgroundService.java    From 365browser with Apache License 2.0 5 votes vote down vote up
private void rescheduleSnippetsTasksOnUpgrade() {
    if (SnippetsLauncher.shouldRescheduleTasksOnUpgrade()) {
        if (!SnippetsLauncher.hasInstance()) {
            launchBrowser(this, /*tag=*/""); // The |tag| doesn't matter here.
        }
        rescheduleFetching();
    }
}
 
Example #3
Source File: ChromeBackgroundService.java    From delion with Apache License 2.0 4 votes vote down vote up
@Override
@VisibleForTesting
public int onRunTask(final TaskParams params) {
    final String taskTag = params.getTag();
    Log.i(TAG, "[" + taskTag + "] Woken up at " + new java.util.Date().toString());
    final ChromeBackgroundServiceWaiter waiter = getWaiterIfNeeded(params.getExtras());
    final Context context = this;
    ThreadUtils.runOnUiThread(new Runnable() {
        @Override
        public void run() {
            switch (taskTag) {
                case BackgroundSyncLauncher.TASK_TAG:
                    handleBackgroundSyncEvent(context, taskTag);
                    break;

                case OfflinePageUtils.TASK_TAG:
                    handleOfflinePageBackgroundLoad(
                            context, params.getExtras(), waiter, taskTag);
                    break;

                case SnippetsLauncher.TASK_TAG_WIFI_CHARGING:
                case SnippetsLauncher.TASK_TAG_WIFI:
                case SnippetsLauncher.TASK_TAG_FALLBACK:
                    handleFetchSnippets(context, taskTag);
                    break;

                case SnippetsLauncher.TASK_TAG_RESCHEDULE:
                    handleRescheduleSnippets(context, taskTag);
                    break;

                case PrecacheController.PERIODIC_TASK_TAG:
                case PrecacheController.CONTINUATION_TASK_TAG:
                    handlePrecache(context, taskTag);
                    break;

                case DownloadResumptionScheduler.TASK_TAG:
                    DownloadResumptionScheduler.getDownloadResumptionScheduler(
                            context.getApplicationContext()).handleDownloadResumption();
                    break;

                default:
                    Log.i(TAG, "Unknown task tag " + taskTag);
                    break;
            }
        }
    });
    // If needed, block the GcmNetworkManager thread until the UI thread has finished its work.
    waitForTaskIfNeeded(waiter);

    return GcmNetworkManager.RESULT_SUCCESS;
}
 
Example #4
Source File: ChromeBackgroundService.java    From delion with Apache License 2.0 4 votes vote down vote up
private void handleFetchSnippets(Context context, String tag) {
    if (!SnippetsLauncher.hasInstance()) {
        launchBrowser(context, tag);
    }
    fetchSnippets();
}
 
Example #5
Source File: ChromeBackgroundService.java    From delion with Apache License 2.0 4 votes vote down vote up
private void handleRescheduleSnippets(Context context, String tag) {
    if (!SnippetsLauncher.hasInstance()) {
        launchBrowser(context, tag);
    }
    rescheduleSnippets();
}
 
Example #6
Source File: ChromeBackgroundService.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
@Override
@VisibleForTesting
public int onRunTask(final TaskParams params) {
    final String taskTag = params.getTag();
    Log.i(TAG, "[" + taskTag + "] Woken up at " + new java.util.Date().toString());
    final ChromeBackgroundServiceWaiter waiter = getWaiterIfNeeded(params.getExtras());
    final Context context = this;
    ThreadUtils.runOnUiThread(new Runnable() {
        @Override
        public void run() {
            switch (taskTag) {
                case BackgroundSyncLauncher.TASK_TAG:
                    handleBackgroundSyncEvent(context, taskTag);
                    break;

                case OfflinePageUtils.TASK_TAG:
                    handleOfflinePageBackgroundLoad(
                            context, params.getExtras(), waiter, taskTag);
                    break;

                case SnippetsLauncher.TASK_TAG_WIFI:
                case SnippetsLauncher.TASK_TAG_FALLBACK:
                    handleFetchSnippets(context, taskTag);
                    break;

                case PrecacheController.PERIODIC_TASK_TAG:
                case PrecacheController.CONTINUATION_TASK_TAG:
                    handlePrecache(context, taskTag);
                    break;

                case DownloadResumptionScheduler.TASK_TAG:
                    DownloadResumptionScheduler.getDownloadResumptionScheduler(
                            context.getApplicationContext()).handleDownloadResumption();
                    break;

                default:
                    Log.i(TAG, "Unknown task tag " + taskTag);
                    break;
            }
        }
    });
    // If needed, block the GcmNetworkManager thread until the UI thread has finished its work.
    waitForTaskIfNeeded(waiter);

    return GcmNetworkManager.RESULT_SUCCESS;
}
 
Example #7
Source File: ChromeBackgroundService.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
private void handleFetchSnippets(Context context, String tag) {
    if (!SnippetsLauncher.hasInstance()) {
        launchBrowser(context, tag);
    }
    fetchSnippets();
}
 
Example #8
Source File: ChromeBackgroundService.java    From 365browser with Apache License 2.0 4 votes vote down vote up
@Override
@VisibleForTesting
public int onRunTask(final TaskParams params) {
    final String taskTag = params.getTag();
    Log.i(TAG, "[" + taskTag + "] Woken up at " + new java.util.Date().toString());
    final ChromeBackgroundServiceWaiter waiter = getWaiterIfNeeded(params.getExtras());
    final Context context = this;
    ThreadUtils.runOnUiThread(new Runnable() {
        @Override
        public void run() {
            switch (taskTag) {
                case BackgroundSyncLauncher.TASK_TAG:
                    handleBackgroundSyncEvent(context, taskTag);
                    break;

                case OfflinePageUtils.TASK_TAG:
                    handleOfflinePageBackgroundLoad(
                            context, params.getExtras(), waiter, taskTag);
                    break;

                case SnippetsLauncher.TASK_TAG_WIFI:
                case SnippetsLauncher.TASK_TAG_FALLBACK:
                    handleFetchSnippets(context, taskTag);
                    break;

                case PrecacheController.PERIODIC_TASK_TAG:
                case PrecacheController.CONTINUATION_TASK_TAG:
                    handlePrecache(context, taskTag);
                    break;

                case DownloadResumptionScheduler.TASK_TAG:
                    DownloadResumptionScheduler.getDownloadResumptionScheduler(
                            context.getApplicationContext()).handleDownloadResumption();
                    break;

                default:
                    Log.i(TAG, "Unknown task tag " + taskTag);
                    break;
            }
        }
    });
    // If needed, block the GcmNetworkManager thread until the UI thread has finished its work.
    waitForTaskIfNeeded(waiter);

    return GcmNetworkManager.RESULT_SUCCESS;
}
 
Example #9
Source File: ChromeBackgroundService.java    From 365browser with Apache License 2.0 4 votes vote down vote up
private void handleFetchSnippets(Context context, String tag) {
    if (!SnippetsLauncher.hasInstance()) {
        launchBrowser(context, tag);
    }
    fetchSnippets();
}