当前位置: 首页>>代码示例>>Java>>正文


Java BrowserParts类代码示例

本文整理汇总了Java中org.chromium.chrome.browser.init.BrowserParts的典型用法代码示例。如果您正苦于以下问题:Java BrowserParts类的具体用法?Java BrowserParts怎么用?Java BrowserParts使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


BrowserParts类属于org.chromium.chrome.browser.init包,在下文中一共展示了BrowserParts类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getBrowserParts

import org.chromium.chrome.browser.init.BrowserParts; //导入依赖的package包/类
private BrowserParts getBrowserParts(final Context context,
        final String account, final PendingInvalidation invalidation,
        final SyncResult syncResult, final Semaphore semaphore) {
    return new EmptyBrowserParts() {
        @Override
        public void finishNativeInitialization() {
            // Startup succeeded, so we can notify the invalidation.
            notifyInvalidation(invalidation.mObjectSource, invalidation.mObjectId,
                    invalidation.mVersion, invalidation.mPayload);
            semaphore.release();
        }

        @Override
        public void onStartupFailure() {
            // The startup failed, so we defer the invalidation.
            DelayedInvalidationsController.getInstance().addPendingInvalidation(
                    context, account, invalidation);
            // Using numIoExceptions so Android will treat this as a soft error.
            syncResult.stats.numIoExceptions++;
            semaphore.release();
        }
    };
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:24,代码来源:ChromeBrowserSyncAdapter.java

示例2: startBrowserIfNeededAndValidateAccounts

import org.chromium.chrome.browser.init.BrowserParts; //导入依赖的package包/类
@SuppressFBWarnings("DM_EXIT")
private static void startBrowserIfNeededAndValidateAccounts(final Context context) {
    BrowserParts parts = new EmptyBrowserParts() {
        @Override
        public void finishNativeInitialization() {
            ThreadUtils.runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    SigninHelper.get(context).validateAccountSettings(true);
                }
            });
        }

        @Override
        public void onStartupFailure() {
            // Startup failed. So notify SigninHelper of changed accounts via
            // shared prefs.
            SigninHelper.markAccountsChangedPref(context);
        }
    };
    try {
        ChromeBrowserInitializer.getInstance(context).handlePreNativeStartup(parts);
        ChromeBrowserInitializer.getInstance(context).handlePostNativeStartup(true, parts);
    } catch (ProcessInitException e) {
        Log.e(TAG, "Unable to load native library.", e);
        ChromeApplication.reportStartupErrorAndExit(e);
    }
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:29,代码来源:AccountsChangedReceiver.java

示例3: runWithNative

import org.chromium.chrome.browser.init.BrowserParts; //导入依赖的package包/类
/**
 * Ensure that native is started before running the task. If native fails to start, the task is
 * going to be rescheduled, by issuing a {@see TaskFinishedCallback} with parameter set to
 * <c>true</c>.
 *
 * @param context the current context
 * @param startWithNativeRunnable A runnable that will execute #onStartTaskWithNative, after the
 *    native is loaded.
 * @param rescheduleRunnable A runnable that will be called to reschedule the task in case
 *    native initialization fails.
 */
protected final void runWithNative(final Context context,
        final Runnable startWithNativeRunnable, final Runnable rescheduleRunnable) {
    if (isNativeLoaded()) {
        ThreadUtils.postOnUiThread(startWithNativeRunnable);
        return;
    }

    final BrowserParts parts = new EmptyBrowserParts() {
        @Override
        public void finishNativeInitialization() {
            ThreadUtils.postOnUiThread(startWithNativeRunnable);
        }
        @Override
        public void onStartupFailure() {
            ThreadUtils.postOnUiThread(rescheduleRunnable);
        }
    };

    ThreadUtils.postOnUiThread(new Runnable() {
        @Override
        public void run() {
            // If task was stopped before we got here, don't start native initialization.
            if (mTaskStopped) return;
            try {
                ChromeBrowserInitializer.getInstance(context).handlePreNativeStartup(parts);

                ChromeBrowserInitializer.getInstance(context).handlePostNativeStartup(
                        true /* isAsync */, parts);
            } catch (ProcessInitException e) {
                Log.e(TAG, "ProcessInitException while starting the browser process.");
                rescheduleRunnable.run();
                return;
            }
        }
    });
}
 
开发者ID:mogoweb,项目名称:365browser,代码行数:48,代码来源:NativeBackgroundTask.java

示例4: onPerformSync

import org.chromium.chrome.browser.init.BrowserParts; //导入依赖的package包/类
@Override
public void onPerformSync(Account account, Bundle extras, String authority,
        ContentProviderClient provider, SyncResult syncResult) {
    if (extras.getBoolean(ContentResolver.SYNC_EXTRAS_INITIALIZE)) {
        Account signedInAccount = ChromeSigninController.get(getContext()).getSignedInUser();
        if (account.equals(signedInAccount)) {
            ContentResolver.setIsSyncable(account, authority, 1);
        } else {
            ContentResolver.setIsSyncable(account, authority, 0);
        }
        return;
    }
    PendingInvalidation invalidation = new PendingInvalidation(extras);

    DelayedInvalidationsController controller = DelayedInvalidationsController.getInstance();
    if (!controller.shouldNotifyInvalidation(extras)) {
        controller.addPendingInvalidation(getContext(), account.name, invalidation);
        return;
    }

    // Browser startup is asynchronous, so we will need to wait for startup to finish.
    Semaphore semaphore = new Semaphore(0);

    // Configure the BrowserParts with all the data it needs.
    BrowserParts parts =
            getBrowserParts(mApplication, account.name, invalidation, syncResult, semaphore);
    startBrowserProcess(parts, syncResult, semaphore);

    try {
        // This code is only synchronously calling a single native method
        // to trigger and asynchronous sync cycle, so 5 minutes is generous.
        if (!semaphore.tryAcquire(5, TimeUnit.MINUTES)) {
            Log.w(TAG, "Sync request timed out!");
            syncResult.stats.numIoExceptions++;
        }
    } catch (InterruptedException e) {
        Log.w(TAG, "Got InterruptedException when trying to request an invalidation.", e);
        // Using numIoExceptions so Android will treat this as a soft error.
        syncResult.stats.numIoExceptions++;
    }
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:42,代码来源:ChromeBrowserSyncAdapter.java

示例5: onPerformSync

import org.chromium.chrome.browser.init.BrowserParts; //导入依赖的package包/类
@Override
public void onPerformSync(Account account, Bundle extras, String authority,
        ContentProviderClient provider, SyncResult syncResult) {
    if (extras.getBoolean(ContentResolver.SYNC_EXTRAS_INITIALIZE)) {
        Account signedInAccount = ChromeSigninController.get().getSignedInUser();
        if (account.equals(signedInAccount)) {
            ContentResolver.setIsSyncable(account, authority, 1);
        } else {
            ContentResolver.setIsSyncable(account, authority, 0);
        }
        return;
    }
    PendingInvalidation invalidation = new PendingInvalidation(extras);

    DelayedInvalidationsController controller = DelayedInvalidationsController.getInstance();
    if (!controller.shouldNotifyInvalidation(extras)) {
        controller.addPendingInvalidation(getContext(), account.name, invalidation);
        return;
    }

    // Browser startup is asynchronous, so we will need to wait for startup to finish.
    Semaphore semaphore = new Semaphore(0);

    // Configure the BrowserParts with all the data it needs.
    BrowserParts parts =
            getBrowserParts(mApplication, account.name, invalidation, syncResult, semaphore);
    startBrowserProcess(parts, syncResult, semaphore);

    try {
        // This code is only synchronously calling a single native method
        // to trigger and asynchronous sync cycle, so 5 minutes is generous.
        if (!semaphore.tryAcquire(5, TimeUnit.MINUTES)) {
            Log.w(TAG, "Sync request timed out!");
            syncResult.stats.numIoExceptions++;
        }
    } catch (InterruptedException e) {
        Log.w(TAG, "Got InterruptedException when trying to request an invalidation.", e);
        // Using numIoExceptions so Android will treat this as a soft error.
        syncResult.stats.numIoExceptions++;
    }
}
 
开发者ID:mogoweb,项目名称:365browser,代码行数:42,代码来源:ChromeBrowserSyncAdapter.java


注:本文中的org.chromium.chrome.browser.init.BrowserParts类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。