Java Code Examples for org.chromium.base.ThreadUtils#assertOnBackgroundThread()
The following examples show how to use
org.chromium.base.ThreadUtils#assertOnBackgroundThread() .
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: AndroidCellularSignalStrength.java From cronet with BSD 3-Clause "New" or "Revised" License | 5 votes |
CellStateListener() { ThreadUtils.assertOnBackgroundThread(); mTelephonyManager = (TelephonyManager) ContextUtils.getApplicationContext().getSystemService( Context.TELEPHONY_SERVICE); if (mTelephonyManager.getSimState() != TelephonyManager.SIM_STATE_READY) return; ApplicationStatus.registerApplicationStateListener(this); onApplicationStateChange(ApplicationStatus.getStateForApplication()); }
Example 2
Source File: InstalledAppProviderImpl.java From 365browser with Apache License 2.0 | 5 votes |
/** * Filters a list of apps, returning those that are both installed and match the origin. * * @param relatedApps A list of applications to be filtered. * @param frameUrl The URL of the frame this operation was called from. * @return Pair of: A subsequence of applications that meet the criteria, and, the total amount * of time in ms that should be delayed before returning to the user, to mask the * installed state of the requested apps. */ private Pair<RelatedApplication[], Integer> filterInstalledAppsOnBackgroundThread( RelatedApplication[] relatedApps, URI frameUrl) { ThreadUtils.assertOnBackgroundThread(); ArrayList<RelatedApplication> installedApps = new ArrayList<RelatedApplication>(); int delayMillis = 0; PackageManager pm = mContext.getPackageManager(); for (RelatedApplication app : relatedApps) { // If the package is of type "play", it is installed, and the origin is associated with // package, add the package to the list of valid packages. // NOTE: For security, it must not be possible to distinguish (from the response) // between the app not being installed and the origin not being associated with the app // (otherwise, arbitrary websites would be able to test whether un-associated apps are // installed on the user's device). if (app.platform.equals(RELATED_APP_PLATFORM_ANDROID) && app.id != null) { delayMillis += calculateDelayForPackageMs(app.id); if (isAppInstalledAndAssociatedWithOrigin(app.id, frameUrl, pm)) { installedApps.add(app); } } else if (app.platform.equals(RELATED_APP_PLATFORM_INSTANT_APP) && app.url != null) { boolean checkHoldback = HOLDBACK_STRING.equals(app.id); if (mInstantAppsHandler.isInstantAppAvailable(app.url, checkHoldback)) { installedApps.add(app); } } } RelatedApplication[] installedAppsArray = new RelatedApplication[installedApps.size()]; installedApps.toArray(installedAppsArray); return Pair.create(installedAppsArray, delayMillis); }
Example 3
Source File: CrashDumpManager.java From 365browser with Apache License 2.0 | 5 votes |
/** * Attempts to upload the specified child process minidump (or a no-op if no observer has been * registered). * * @param minidumpPath The file path for the generated minidump. */ @CalledByNative public static void tryToUploadMinidump(String minidumpPath) { // The C++ code that calls into this method should be running on a background thread. It's // important to be off the UI thread for the file operations done below. ThreadUtils.assertOnBackgroundThread(); if (minidumpPath == null) { Log.e(TAG, "Minidump path should be non-null! Bailing..."); return; } final File minidump = new File(minidumpPath); if (!minidump.exists() || !minidump.isFile()) { Log.e(TAG, "Minidump path '" + minidumpPath + "' should describe a file that exists! Bailing..."); return; } // The callback should only be accessed on the UI thread. ThreadUtils.postOnUiThread(new Runnable() { @Override public void run() { if (sCallback == null) { Log.w(TAG, "Ignoring crash observed before a callback was registered..."); return; } sCallback.tryToUploadMinidump(minidump); } }); }