org.chromium.chrome.browser.precache.PrecacheController Java Examples

The following examples show how to use org.chromium.chrome.browser.precache.PrecacheController. 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 delion with Apache License 2.0 6 votes vote down vote up
@VisibleForTesting
@SuppressFBWarnings("DM_EXIT")
protected void launchBrowser(Context context, String tag) {
    Log.i(TAG, "Launching browser");
    try {
        ChromeBrowserInitializer.getInstance(this).handleSynchronousStartup();
    } catch (ProcessInitException e) {
        Log.e(TAG, "ProcessInitException while starting the browser process");
        switch (tag) {
            case PrecacheController.PERIODIC_TASK_TAG:
            case PrecacheController.CONTINUATION_TASK_TAG:
                // Record the failure persistently, and upload to UMA when the library
                // successfully loads next time.
                PrecacheUMA.record(PrecacheUMA.Event.PRECACHE_TASK_LOAD_LIBRARY_FAIL);
                break;
            default:
                break;
        }
        // Since the library failed to initialize nothing in the application
        // can work, so kill the whole application not just the activity.
        System.exit(-1);
    }
}
 
Example #2
Source File: ChromeBackgroundService.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
@VisibleForTesting
@SuppressFBWarnings("DM_EXIT")
protected void launchBrowser(Context context, String tag) {
    Log.i(TAG, "Launching browser");
    try {
        ChromeBrowserInitializer.getInstance(this).handleSynchronousStartup();
    } catch (ProcessInitException e) {
        Log.e(TAG, "ProcessInitException while starting the browser process");
        switch (tag) {
            case PrecacheController.PERIODIC_TASK_TAG:
            case PrecacheController.CONTINUATION_TASK_TAG:
                // Record the failure persistently, and upload to UMA when the library
                // successfully loads next time.
                PrecacheUMA.record(PrecacheUMA.Event.PRECACHE_TASK_LOAD_LIBRARY_FAIL);
                break;
            default:
                break;
        }
        // Since the library failed to initialize nothing in the application
        // can work, so kill the whole application not just the activity.
        System.exit(-1);
    }
}
 
Example #3
Source File: ChromeBackgroundService.java    From 365browser with Apache License 2.0 6 votes vote down vote up
@VisibleForTesting
@SuppressFBWarnings("DM_EXIT")
protected void launchBrowser(Context context, String tag) {
    Log.i(TAG, "Launching browser");
    try {
        ChromeBrowserInitializer.getInstance(this).handleSynchronousStartup();
    } catch (ProcessInitException e) {
        Log.e(TAG, "ProcessInitException while starting the browser process");
        switch (tag) {
            case PrecacheController.PERIODIC_TASK_TAG:
            case PrecacheController.CONTINUATION_TASK_TAG:
                // Record the failure persistently, and upload to UMA when the library
                // successfully loads next time.
                PrecacheUMA.record(PrecacheUMA.Event.PRECACHE_TASK_LOAD_LIBRARY_FAIL);
                break;
            default:
                break;
        }
        // Since the library failed to initialize nothing in the application
        // can work, so kill the whole application not just the activity.
        System.exit(-1);
    }
}
 
Example #4
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 #5
Source File: ChromeBackgroundService.java    From delion with Apache License 2.0 4 votes vote down vote up
@VisibleForTesting
protected boolean hasPrecacheInstance() {
    return PrecacheController.hasInstance();
}
 
Example #6
Source File: ChromeBackgroundService.java    From delion with Apache License 2.0 4 votes vote down vote up
@VisibleForTesting
protected void precache(Context context, String tag) {
    PrecacheController.get(context).precache(tag);
}
 
Example #7
Source File: ChromeBackgroundService.java    From delion with Apache License 2.0 4 votes vote down vote up
@Override
public void onInitializeTasks() {
    BackgroundSyncLauncher.rescheduleTasksOnUpgrade(this);
    PrecacheController.rescheduleTasksOnUpgrade(this);
}
 
Example #8
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 #9
Source File: ChromeBackgroundService.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
@VisibleForTesting
protected boolean hasPrecacheInstance() {
    return PrecacheController.hasInstance();
}
 
Example #10
Source File: ChromeBackgroundService.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
@VisibleForTesting
protected void precache(Context context, String tag) {
    PrecacheController.get(context).precache(tag);
}
 
Example #11
Source File: ChromeBackgroundService.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
@VisibleForTesting
protected void reschedulePrecacheTasksOnUpgrade() {
    PrecacheController.rescheduleTasksOnUpgrade(this);
}
 
Example #12
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 #13
Source File: ChromeBackgroundService.java    From 365browser with Apache License 2.0 4 votes vote down vote up
@VisibleForTesting
protected boolean hasPrecacheInstance() {
    return PrecacheController.hasInstance();
}
 
Example #14
Source File: ChromeBackgroundService.java    From 365browser with Apache License 2.0 4 votes vote down vote up
@VisibleForTesting
protected void precache(Context context, String tag) {
    PrecacheController.get(context).precache(tag);
}
 
Example #15
Source File: ChromeBackgroundService.java    From 365browser with Apache License 2.0 4 votes vote down vote up
@VisibleForTesting
protected void reschedulePrecacheTasksOnUpgrade() {
    PrecacheController.rescheduleTasksOnUpgrade(this);
}