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


Java BrowserStartupController.StartupCallback方法代码示例

本文整理汇总了Java中org.chromium.content.browser.BrowserStartupController.StartupCallback方法的典型用法代码示例。如果您正苦于以下问题:Java BrowserStartupController.StartupCallback方法的具体用法?Java BrowserStartupController.StartupCallback怎么用?Java BrowserStartupController.StartupCallback使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.chromium.content.browser.BrowserStartupController的用法示例。


在下文中一共展示了BrowserStartupController.StartupCallback方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: startBrowserProcessesSync

import org.chromium.content.browser.BrowserStartupController; //导入方法依赖的package包/类
@SuppressFBWarnings("DM_EXIT")
private void startBrowserProcessesSync(
        final BrowserStartupController.StartupCallback callback) {
    try {
        BrowserStartupController.get(mApplication, LibraryProcessType.PROCESS_BROWSER)
                .startBrowserProcessesSync(false);
    } catch (ProcessInitException e) {
        Log.e(TAG, "Unable to load native library.", e);
        System.exit(-1);
    }
    new Handler().post(new Runnable() {
        @Override
        public void run() {
            callback.onSuccess(false);
        }
    });
}
 
开发者ID:Smalinuxer,项目名称:Vafrinn,代码行数:18,代码来源:ChromiumSyncAdapter.java

示例2: getStartupCallback

import org.chromium.content.browser.BrowserStartupController; //导入方法依赖的package包/类
private BrowserStartupController.StartupCallback getStartupCallback(final Context context,
        final String account, final PendingInvalidation invalidation,
        final SyncResult syncResult, final Semaphore semaphore) {
    return new BrowserStartupController.StartupCallback() {
        @Override
        public void onSuccess(boolean alreadyStarted) {
            // Startup succeeded, so we can notify the invalidation.
            notifyInvalidation(invalidation.mObjectSource, invalidation.mObjectId,
                    invalidation.mVersion, invalidation.mPayload);
            semaphore.release();
        }

        @Override
        public void onFailure() {
            // 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:Smalinuxer,项目名称:Vafrinn,代码行数:24,代码来源:ChromiumSyncAdapter.java

示例3: onReceive

import org.chromium.content.browser.BrowserStartupController; //导入方法依赖的package包/类
@Override
public void onReceive(final Context context, Intent intent) {
    if (AccountManager.LOGIN_ACCOUNTS_CHANGED_ACTION.equals(intent.getAction())) {
        final Account signedInUser =
                ChromeSigninController.get(context).getSignedInUser();
        if (signedInUser != null) {
            BrowserStartupController.StartupCallback callback =
                    new BrowserStartupController.StartupCallback() {
                @Override
                public void onSuccess(boolean alreadyStarted) {
                    OAuth2TokenService.getForProfile(Profile.getLastUsedProfile())
                            .validateAccounts(context);
                }

                @Override
                public void onFailure() {
                    Log.w(TAG, "Failed to start browser process.");
                }
            };
            startBrowserProcessOnUiThread(context, callback);
        }
    }
}
 
开发者ID:morristech,项目名称:android-chromium,代码行数:24,代码来源:AccountsChangedReceiver.java

示例4: onPerformSync

import org.chromium.content.browser.BrowserStartupController; //导入方法依赖的package包/类
@Override
public void onPerformSync(Account account, Bundle extras, String authority,
                          ContentProviderClient provider, SyncResult syncResult) {
    if (!DelayedSyncController.getInstance().shouldPerformSync(getContext(), extras, account)) {
        return;
    }

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

    // Configure the callback with all the data it needs.
    BrowserStartupController.StartupCallback callback =
            getStartupCallback(mApplication, account, extras, syncResult, semaphore);
    startBrowserProcess(callback, syncResult, semaphore);

    try {
        // Wait for startup to complete.
        semaphore.acquire();
    } catch (InterruptedException e) {
        Log.w(TAG, "Got InterruptedException when trying to request a sync.", e);
        // Using numIoExceptions so Android will treat this as a soft error.
        syncResult.stats.numIoExceptions++;
    }
}
 
开发者ID:morristech,项目名称:android-chromium,代码行数:25,代码来源:ChromiumSyncAdapter.java

示例5: startBrowserProcess

import org.chromium.content.browser.BrowserStartupController; //导入方法依赖的package包/类
private void startBrowserProcess(
        final BrowserStartupController.StartupCallback callback,
        final SyncResult syncResult, Semaphore semaphore) {
    try {
        ThreadUtils.runOnUiThreadBlocking(new Runnable() {
            @Override
            public void run() {
                initCommandLine();
                if (mAsyncStartup) {
                    BrowserStartupController.get(mApplication)
                            .startBrowserProcessesAsync(callback);
                } else {
                    startBrowserProcessesSync(callback);
                }
            }
        });
    } catch (RuntimeException e) {
        // It is still unknown why we ever experience this. See http://crbug.com/180044.
        Log.w(TAG, "Got exception when trying to request a sync. Informing Android system.", e);
        // Using numIoExceptions so Android will treat this as a soft error.
        syncResult.stats.numIoExceptions++;
        semaphore.release();
    }
}
 
开发者ID:morristech,项目名称:android-chromium,代码行数:25,代码来源:ChromiumSyncAdapter.java

示例6: startBrowserProcessesSync

import org.chromium.content.browser.BrowserStartupController; //导入方法依赖的package包/类
private void startBrowserProcessesSync(
        final BrowserStartupController.StartupCallback callback) {
    if (BrowserStartupController.get(mApplication).startBrowserProcessesSync(
            BrowserStartupController.MAX_RENDERERS_LIMIT)) {
        new Handler().post(new Runnable() {
            @Override
            public void run() {
                callback.onSuccess(false);
            }
        });
    } else {
        Log.e(TAG, "Unable to start browser process.");
        new Handler().post(new Runnable() {
            @Override
            public void run() {
                callback.onFailure();
            }
        });
    }
}
 
开发者ID:morristech,项目名称:android-chromium,代码行数:21,代码来源:ChromiumSyncAdapter.java

示例7: startChromeBrowserProcessesAsync

import org.chromium.content.browser.BrowserStartupController; //导入方法依赖的package包/类
private void startChromeBrowserProcessesAsync(
        boolean startGpuProcess,
        BrowserStartupController.StartupCallback callback) throws ProcessInitException {
    try {
        TraceEvent.begin("ChromeBrowserInitializer.startChromeBrowserProcessesAsync");
        BrowserStartupController.get(mApplication, LibraryProcessType.PROCESS_BROWSER)
                .startBrowserProcessesAsync(startGpuProcess, callback);
    } finally {
        TraceEvent.end("ChromeBrowserInitializer.startChromeBrowserProcessesAsync");
    }
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:12,代码来源:ChromeBrowserInitializer.java

示例8: startChromeBrowserProcesses

import org.chromium.content.browser.BrowserStartupController; //导入方法依赖的package包/类
private void startChromeBrowserProcesses(BrowserParts parts,
        BrowserStartupController.StartupCallback callback) {
    try {
        TraceEvent.begin("ChromeBrowserInitializer.startChromeBrowserProcesses");
        mApplication.startChromeBrowserProcessesAsync(callback);
    } catch (ProcessInitException e) {
        parts.onStartupFailure();
    } finally {
        TraceEvent.end("ChromeBrowserInitializer.startChromeBrowserProcesses");
    }
}
 
开发者ID:Smalinuxer,项目名称:Vafrinn,代码行数:12,代码来源:ChromeBrowserInitializer.java

示例9: startChromeBrowserProcessesAsync

import org.chromium.content.browser.BrowserStartupController; //导入方法依赖的package包/类
/**
 * Start the browser process asynchronously. This will set up a queue of UI
 * thread tasks to initialize the browser process.
 *
 * Note that this can only be called on the UI thread.
 *
 * @param callback the callback to be called when browser startup is complete.
 * @throws ProcessInitException
 */
public void startChromeBrowserProcessesAsync(BrowserStartupController.StartupCallback callback)
        throws ProcessInitException {
    assert ThreadUtils.runningOnUiThread() : "Tried to start the browser on the wrong thread";
    // The policies are used by browser startup, so we need to register the policy providers
    // before starting the browser process.
    registerPolicyProviders(CombinedPolicyProvider.get());
    Context applicationContext = getApplicationContext();
    BrowserStartupController.get(applicationContext, LibraryProcessType.PROCESS_BROWSER)
            .startBrowserProcessesAsync(callback);
}
 
开发者ID:Smalinuxer,项目名称:Vafrinn,代码行数:20,代码来源:ChromeApplication.java

示例10: startChromeBrowserProcessesAsync

import org.chromium.content.browser.BrowserStartupController; //导入方法依赖的package包/类
private void startChromeBrowserProcessesAsync(
        boolean startGpuProcess,
        BrowserStartupController.StartupCallback callback) throws ProcessInitException {
    try {
        TraceEvent.begin("ChromeBrowserInitializer.startChromeBrowserProcessesAsync");
        BrowserStartupController.get(LibraryProcessType.PROCESS_BROWSER)
                .startBrowserProcessesAsync(startGpuProcess, callback);
    } finally {
        TraceEvent.end("ChromeBrowserInitializer.startChromeBrowserProcessesAsync");
    }
}
 
开发者ID:mogoweb,项目名称:365browser,代码行数:12,代码来源:ChromeBrowserInitializer.java

示例11: onCreate

import org.chromium.content.browser.BrowserStartupController; //导入方法依赖的package包/类
@Override
protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    ChromiumTestShellApplication.initCommandLine();
    waitForDebuggerIfNeeded();

    DeviceUtils.addDeviceSpecificUserAgentSwitch(this);

    BrowserStartupController.StartupCallback callback =
            new BrowserStartupController.StartupCallback() {
                @Override
                public void onSuccess(boolean alreadyStarted) {
                    finishInitialization(savedInstanceState);
                }

                @Override
                public void onFailure() {
                    Toast.makeText(ChromiumTestShellActivity.this,
                                   R.string.browser_process_initialization_failed,
                                   Toast.LENGTH_SHORT).show();
                    Log.e(TAG, "Chromium browser process initialization failed");
                    finish();
                }
            };
    BrowserStartupController.get(this).startBrowserProcessesAsync(callback);
}
 
开发者ID:morristech,项目名称:android-chromium,代码行数:28,代码来源:ChromiumTestShellActivity.java

示例12: startBrowserProcessOnUiThread

import org.chromium.content.browser.BrowserStartupController; //导入方法依赖的package包/类
private static void startBrowserProcessOnUiThread(final Context context,
        final BrowserStartupController.StartupCallback callback) {
    ThreadUtils.runOnUiThread(new Runnable() {
        @Override
        public void run() {
            BrowserStartupController.get(context).startBrowserProcessesAsync(callback);
        }
    });
}
 
开发者ID:morristech,项目名称:android-chromium,代码行数:10,代码来源:AccountsChangedReceiver.java

示例13: getStartupCallback

import org.chromium.content.browser.BrowserStartupController; //导入方法依赖的package包/类
private BrowserStartupController.StartupCallback getStartupCallback(
        final Context context, final Account acct, Bundle extras,
        final SyncResult syncResult, final Semaphore semaphore) {
    final boolean syncAllTypes = extras.getString(INVALIDATION_OBJECT_ID_KEY) == null;
    final int objectSource = syncAllTypes ? 0 : extras.getInt(INVALIDATION_OBJECT_SOURCE_KEY);
    final String objectId = syncAllTypes ? "" : extras.getString(INVALIDATION_OBJECT_ID_KEY);
    final long version = syncAllTypes ? 0 : extras.getLong(INVALIDATION_VERSION_KEY);
    final String payload = syncAllTypes ? "" : extras.getString(INVALIDATION_PAYLOAD_KEY);

    return new BrowserStartupController.StartupCallback() {
        @Override
        public void onSuccess(boolean alreadyStarted) {
            // Startup succeeded, so we can tickle the sync engine.
            if (syncAllTypes) {
                Log.v(TAG, "Received sync tickle for all types.");
                requestSyncForAllTypes();
            } else {
                // Invalidations persisted before objectSource was added should be assumed to be
                // for Sync objects. TODO(stepco): Remove this check once all persisted
                // invalidations can be expected to have the objectSource.
                int resolvedSource = objectSource;
                if (resolvedSource == 0) {
                  resolvedSource = Types.ObjectSource.Type.CHROME_SYNC.getNumber();
                }
                Log.v(TAG, "Received sync tickle for " + resolvedSource + " " + objectId + ".");
                requestSync(resolvedSource, objectId, version, payload);
            }
            semaphore.release();
        }

        @Override
        public void onFailure() {
            // The startup failed, so we reset the delayed sync state.
            DelayedSyncController.getInstance().setDelayedSync(context, acct.name);
            // Using numIoExceptions so Android will treat this as a soft error.
            syncResult.stats.numIoExceptions++;
            semaphore.release();
        }
    };
}
 
开发者ID:morristech,项目名称:android-chromium,代码行数:41,代码来源:ChromiumSyncAdapter.java

示例14: onPerformSync

import org.chromium.content.browser.BrowserStartupController; //导入方法依赖的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 callback with all the data it needs.
    BrowserStartupController.StartupCallback callback =
            getStartupCallback(mApplication, account.name, invalidation, syncResult, semaphore);
    startBrowserProcess(callback, 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:Smalinuxer,项目名称:Vafrinn,代码行数:42,代码来源:ChromiumSyncAdapter.java


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