зеркало из https://github.com/mozilla/gecko-dev.git
Bug 802130 - Move GeckoAppShell.getHandler() to ThreadUtils.getBackgroundHandler(). r=mfinkle
This commit is contained in:
Родитель
baeed09fed
Коммит
e0e4690d71
|
@ -12,6 +12,7 @@ import org.mozilla.gecko.db.BrowserDB.URLColumns;
|
||||||
import org.mozilla.gecko.db.BrowserDB.TopSitesCursorWrapper;
|
import org.mozilla.gecko.db.BrowserDB.TopSitesCursorWrapper;
|
||||||
import org.mozilla.gecko.sync.setup.SyncAccounts;
|
import org.mozilla.gecko.sync.setup.SyncAccounts;
|
||||||
import org.mozilla.gecko.util.ActivityResultHandler;
|
import org.mozilla.gecko.util.ActivityResultHandler;
|
||||||
|
import org.mozilla.gecko.util.ThreadUtils;
|
||||||
import org.mozilla.gecko.util.UiAsyncTask;
|
import org.mozilla.gecko.util.UiAsyncTask;
|
||||||
|
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
|
@ -143,7 +144,7 @@ public class AboutHomeContent extends ScrollView
|
||||||
// Because the tabs URI is coarse grained, this updates the
|
// Because the tabs URI is coarse grained, this updates the
|
||||||
// remote tabs component on *every* tab change
|
// remote tabs component on *every* tab change
|
||||||
// The observer will run on the background thread (see constructor argument)
|
// The observer will run on the background thread (see constructor argument)
|
||||||
mTabsContentObserver = new ContentObserver(GeckoAppShell.getHandler()) {
|
mTabsContentObserver = new ContentObserver(ThreadUtils.getBackgroundHandler()) {
|
||||||
@Override
|
@Override
|
||||||
public void onChange(boolean selfChange) {
|
public void onChange(boolean selfChange) {
|
||||||
update(EnumSet.of(AboutHomeContent.UpdateFlags.REMOTE_TABS));
|
update(EnumSet.of(AboutHomeContent.UpdateFlags.REMOTE_TABS));
|
||||||
|
@ -426,7 +427,7 @@ public class AboutHomeContent extends ScrollView
|
||||||
if (urls.size() == 0)
|
if (urls.size() == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
(new UiAsyncTask<Void, Void, Cursor>(GeckoAppShell.getHandler()) {
|
(new UiAsyncTask<Void, Void, Cursor>(ThreadUtils.getBackgroundHandler()) {
|
||||||
@Override
|
@Override
|
||||||
public Cursor doInBackground(Void... params) {
|
public Cursor doInBackground(Void... params) {
|
||||||
return BrowserDB.getThumbnailsForUrls(cr, urls);
|
return BrowserDB.getThumbnailsForUrls(cr, urls);
|
||||||
|
@ -440,7 +441,7 @@ public class AboutHomeContent extends ScrollView
|
||||||
}
|
}
|
||||||
|
|
||||||
void update(final EnumSet<UpdateFlags> flags) {
|
void update(final EnumSet<UpdateFlags> flags) {
|
||||||
GeckoAppShell.getHandler().post(new Runnable() {
|
ThreadUtils.postToBackgroundThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (flags.contains(UpdateFlags.TOP_SITES))
|
if (flags.contains(UpdateFlags.TOP_SITES))
|
||||||
|
@ -990,7 +991,7 @@ public class AboutHomeContent extends ScrollView
|
||||||
final String url = holder.getUrl();
|
final String url = holder.getUrl();
|
||||||
// Quickly update the view so that there isn't as much lag between the request and response
|
// Quickly update the view so that there isn't as much lag between the request and response
|
||||||
clearThumbnail(holder);
|
clearThumbnail(holder);
|
||||||
(new UiAsyncTask<Void, Void, Void>(GeckoAppShell.getHandler()) {
|
(new UiAsyncTask<Void, Void, Void>(ThreadUtils.getBackgroundHandler()) {
|
||||||
@Override
|
@Override
|
||||||
public Void doInBackground(Void... params) {
|
public Void doInBackground(Void... params) {
|
||||||
final ContentResolver resolver = mActivity.getContentResolver();
|
final ContentResolver resolver = mActivity.getContentResolver();
|
||||||
|
@ -1011,7 +1012,7 @@ public class AboutHomeContent extends ScrollView
|
||||||
holder.setPinned(true);
|
holder.setPinned(true);
|
||||||
|
|
||||||
// update the database on a background thread
|
// update the database on a background thread
|
||||||
(new UiAsyncTask<Void, Void, Void>(GeckoAppShell.getHandler()) {
|
(new UiAsyncTask<Void, Void, Void>(ThreadUtils.getBackgroundHandler()) {
|
||||||
@Override
|
@Override
|
||||||
public Void doInBackground(Void... params) {
|
public Void doInBackground(Void... params) {
|
||||||
final ContentResolver resolver = mActivity.getContentResolver();
|
final ContentResolver resolver = mActivity.getContentResolver();
|
||||||
|
@ -1056,7 +1057,7 @@ public class AboutHomeContent extends ScrollView
|
||||||
holder.setPinned(true);
|
holder.setPinned(true);
|
||||||
|
|
||||||
// update the database on a background thread
|
// update the database on a background thread
|
||||||
(new UiAsyncTask<Void, Void, Bitmap>(GeckoAppShell.getHandler()) {
|
(new UiAsyncTask<Void, Void, Bitmap>(ThreadUtils.getBackgroundHandler()) {
|
||||||
@Override
|
@Override
|
||||||
public Bitmap doInBackground(Void... params) {
|
public Bitmap doInBackground(Void... params) {
|
||||||
final ContentResolver resolver = mActivity.getContentResolver();
|
final ContentResolver resolver = mActivity.getContentResolver();
|
||||||
|
|
|
@ -7,6 +7,7 @@ package org.mozilla.gecko;
|
||||||
import org.mozilla.gecko.db.BrowserDB;
|
import org.mozilla.gecko.db.BrowserDB;
|
||||||
import org.mozilla.gecko.sync.setup.activities.SetupSyncActivity;
|
import org.mozilla.gecko.sync.setup.activities.SetupSyncActivity;
|
||||||
import org.mozilla.gecko.sync.setup.SyncAccounts;
|
import org.mozilla.gecko.sync.setup.SyncAccounts;
|
||||||
|
import org.mozilla.gecko.util.ThreadUtils;
|
||||||
import org.mozilla.gecko.util.UiAsyncTask;
|
import org.mozilla.gecko.util.UiAsyncTask;
|
||||||
|
|
||||||
import android.accounts.Account;
|
import android.accounts.Account;
|
||||||
|
@ -70,7 +71,7 @@ public class AboutHomePromoBox extends TextView implements View.OnClickListener
|
||||||
showRandomPromo();
|
showRandomPromo();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
AccountManager.get(mContext).addOnAccountsUpdatedListener(mAccountListener, GeckoAppShell.getHandler(), false);
|
AccountManager.get(mContext).addOnAccountsUpdatedListener(mAccountListener, ThreadUtils.getBackgroundHandler(), false);
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public boolean canShow() {
|
public boolean canShow() {
|
||||||
|
@ -193,7 +194,7 @@ public class AboutHomePromoBox extends TextView implements View.OnClickListener
|
||||||
}
|
}
|
||||||
|
|
||||||
private void getAvailableTypes(final GetTypesCallback callback) {
|
private void getAvailableTypes(final GetTypesCallback callback) {
|
||||||
(new UiAsyncTask<Void, Void, ArrayList<Type>>(GeckoAppShell.getHandler()) {
|
(new UiAsyncTask<Void, Void, ArrayList<Type>>(ThreadUtils.getBackgroundHandler()) {
|
||||||
@Override
|
@Override
|
||||||
public ArrayList<Type> doInBackground(Void... params) {
|
public ArrayList<Type> doInBackground(Void... params) {
|
||||||
// Run all of this on a background thread
|
// Run all of this on a background thread
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
package org.mozilla.gecko;
|
package org.mozilla.gecko;
|
||||||
|
|
||||||
import org.mozilla.gecko.util.GeckoBackgroundThread;
|
import org.mozilla.gecko.util.ThreadUtils;
|
||||||
|
|
||||||
import android.app.ProgressDialog;
|
import android.app.ProgressDialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
@ -85,7 +85,7 @@ class AndroidImportPreference extends MultiChoicePreference {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
GeckoBackgroundThread.getHandler().post(
|
ThreadUtils.postToBackgroundThread(
|
||||||
// Constructing AndroidImport may need finding the profile,
|
// Constructing AndroidImport may need finding the profile,
|
||||||
// which hits disk, so it needs to go into a Runnable too.
|
// which hits disk, so it needs to go into a Runnable too.
|
||||||
new Runnable() {
|
new Runnable() {
|
||||||
|
|
|
@ -579,7 +579,7 @@ public class AwesomeBar extends GeckoActivity {
|
||||||
editPrompt.setPositiveButton(R.string.button_ok, new DialogInterface.OnClickListener() {
|
editPrompt.setPositiveButton(R.string.button_ok, new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int whichButton) {
|
public void onClick(DialogInterface dialog, int whichButton) {
|
||||||
(new UiAsyncTask<Void, Void, Void>(GeckoAppShell.getHandler()) {
|
(new UiAsyncTask<Void, Void, Void>(ThreadUtils.getBackgroundHandler()) {
|
||||||
@Override
|
@Override
|
||||||
public Void doInBackground(Void... params) {
|
public Void doInBackground(Void... params) {
|
||||||
String newUrl = locationText.getText().toString().trim();
|
String newUrl = locationText.getText().toString().trim();
|
||||||
|
@ -629,7 +629,7 @@ public class AwesomeBar extends GeckoActivity {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case R.id.remove_bookmark: {
|
case R.id.remove_bookmark: {
|
||||||
(new UiAsyncTask<Void, Void, Void>(GeckoAppShell.getHandler()) {
|
(new UiAsyncTask<Void, Void, Void>(ThreadUtils.getBackgroundHandler()) {
|
||||||
private boolean mInReadingList;
|
private boolean mInReadingList;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -659,7 +659,7 @@ public class AwesomeBar extends GeckoActivity {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case R.id.remove_history: {
|
case R.id.remove_history: {
|
||||||
(new UiAsyncTask<Void, Void, Void>(GeckoAppShell.getHandler()) {
|
(new UiAsyncTask<Void, Void, Void>(ThreadUtils.getBackgroundHandler()) {
|
||||||
@Override
|
@Override
|
||||||
public Void doInBackground(Void... params) {
|
public Void doInBackground(Void... params) {
|
||||||
BrowserDB.removeHistoryEntry(getContentResolver(), id);
|
BrowserDB.removeHistoryEntry(getContentResolver(), id);
|
||||||
|
|
|
@ -10,7 +10,6 @@ import org.mozilla.gecko.db.BrowserDB;
|
||||||
import org.mozilla.gecko.gfx.BitmapUtils;
|
import org.mozilla.gecko.gfx.BitmapUtils;
|
||||||
import org.mozilla.gecko.gfx.ImmutableViewportMetrics;
|
import org.mozilla.gecko.gfx.ImmutableViewportMetrics;
|
||||||
import org.mozilla.gecko.util.UiAsyncTask;
|
import org.mozilla.gecko.util.UiAsyncTask;
|
||||||
import org.mozilla.gecko.util.GeckoBackgroundThread;
|
|
||||||
import org.mozilla.gecko.util.ThreadUtils;
|
import org.mozilla.gecko.util.ThreadUtils;
|
||||||
|
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
|
@ -377,7 +376,7 @@ abstract public class BrowserApp extends GeckoApp
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
GeckoAppShell.getHandler().post(new Runnable() {
|
ThreadUtils.postToBackgroundThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
BrowserDB.addReadingListItem(getContentResolver(), title, url);
|
BrowserDB.addReadingListItem(getContentResolver(), title, url);
|
||||||
|
@ -387,7 +386,7 @@ abstract public class BrowserApp extends GeckoApp
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleReaderRemoved(final String url) {
|
void handleReaderRemoved(final String url) {
|
||||||
GeckoAppShell.getHandler().post(new Runnable() {
|
ThreadUtils.postToBackgroundThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
BrowserDB.removeReadingListItemWithURL(getContentResolver(), url);
|
BrowserDB.removeReadingListItemWithURL(getContentResolver(), url);
|
||||||
|
@ -1198,7 +1197,7 @@ abstract public class BrowserApp extends GeckoApp
|
||||||
item.setIcon(drawable);
|
item.setIcon(drawable);
|
||||||
}
|
}
|
||||||
else if (info.icon.startsWith("jar:") || info.icon.startsWith("file://")) {
|
else if (info.icon.startsWith("jar:") || info.icon.startsWith("file://")) {
|
||||||
GeckoAppShell.getHandler().post(new Runnable() {
|
ThreadUtils.postToBackgroundThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
|
@ -1548,7 +1547,7 @@ abstract public class BrowserApp extends GeckoApp
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
(new UiAsyncTask<Void, Void, Boolean>(GeckoAppShell.getHandler()) {
|
(new UiAsyncTask<Void, Void, Boolean>(ThreadUtils.getBackgroundHandler()) {
|
||||||
@Override
|
@Override
|
||||||
public synchronized Boolean doInBackground(Void... params) {
|
public synchronized Boolean doInBackground(Void... params) {
|
||||||
// Check to see how many times the app has been launched.
|
// Check to see how many times the app has been launched.
|
||||||
|
@ -1575,7 +1574,7 @@ abstract public class BrowserApp extends GeckoApp
|
||||||
}
|
}
|
||||||
|
|
||||||
private void resetFeedbackLaunchCount() {
|
private void resetFeedbackLaunchCount() {
|
||||||
GeckoBackgroundThread.post(new Runnable() {
|
ThreadUtils.postToBackgroundThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public synchronized void run() {
|
public synchronized void run() {
|
||||||
SharedPreferences settings = getPreferences(Activity.MODE_PRIVATE);
|
SharedPreferences settings = getPreferences(Activity.MODE_PRIVATE);
|
||||||
|
@ -1585,7 +1584,7 @@ abstract public class BrowserApp extends GeckoApp
|
||||||
}
|
}
|
||||||
|
|
||||||
private void getLastUrl() {
|
private void getLastUrl() {
|
||||||
(new UiAsyncTask<Void, Void, String>(GeckoAppShell.getHandler()) {
|
(new UiAsyncTask<Void, Void, String>(ThreadUtils.getBackgroundHandler()) {
|
||||||
@Override
|
@Override
|
||||||
public synchronized String doInBackground(Void... params) {
|
public synchronized String doInBackground(Void... params) {
|
||||||
// Get the most recent URL stored in browser history.
|
// Get the most recent URL stored in browser history.
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
package org.mozilla.gecko;
|
package org.mozilla.gecko;
|
||||||
|
|
||||||
import org.mozilla.gecko.util.GeckoBackgroundThread;
|
import org.mozilla.gecko.util.ThreadUtils;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
@ -45,7 +45,7 @@ public final class Distribution {
|
||||||
*/
|
*/
|
||||||
public static void init(final Context context, final String packagePath) {
|
public static void init(final Context context, final String packagePath) {
|
||||||
// Read/write preferences and files on the background thread.
|
// Read/write preferences and files on the background thread.
|
||||||
GeckoBackgroundThread.getHandler().post(new Runnable() {
|
ThreadUtils.postToBackgroundThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
// Bail if we've already initialized the distribution.
|
// Bail if we've already initialized the distribution.
|
||||||
|
|
|
@ -112,7 +112,7 @@ public class Favicons {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
LoadFaviconTask task = new LoadFaviconTask(GeckoAppShell.getHandler(), pageUrl, faviconUrl, persist, listener);
|
LoadFaviconTask task = new LoadFaviconTask(ThreadUtils.getBackgroundHandler(), pageUrl, faviconUrl, persist, listener);
|
||||||
|
|
||||||
long taskId = task.getId();
|
long taskId = task.getId();
|
||||||
mLoadTasks.put(taskId, task);
|
mLoadTasks.put(taskId, task);
|
||||||
|
|
|
@ -43,7 +43,7 @@ public class GeckoAccessibility {
|
||||||
}));
|
}));
|
||||||
|
|
||||||
public static void updateAccessibilitySettings () {
|
public static void updateAccessibilitySettings () {
|
||||||
GeckoAppShell.getHandler().post(new Runnable() {
|
ThreadUtils.postToBackgroundThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
JSONObject ret = new JSONObject();
|
JSONObject ret = new JSONObject();
|
||||||
|
@ -130,7 +130,7 @@ public class GeckoAccessibility {
|
||||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
|
||||||
// Before Jelly Bean we send events directly from here while spoofing the source by setting
|
// Before Jelly Bean we send events directly from here while spoofing the source by setting
|
||||||
// the package and class name manually.
|
// the package and class name manually.
|
||||||
GeckoAppShell.getHandler().post(new Runnable() {
|
ThreadUtils.postToBackgroundThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
sendDirectAccessibilityEvent(eventType, message);
|
sendDirectAccessibilityEvent(eventType, message);
|
||||||
|
|
|
@ -15,7 +15,6 @@ import org.mozilla.gecko.gfx.PluginLayer;
|
||||||
import org.mozilla.gecko.gfx.PointUtils;
|
import org.mozilla.gecko.gfx.PointUtils;
|
||||||
import org.mozilla.gecko.updater.UpdateService;
|
import org.mozilla.gecko.updater.UpdateService;
|
||||||
import org.mozilla.gecko.updater.UpdateServiceHelper;
|
import org.mozilla.gecko.updater.UpdateServiceHelper;
|
||||||
import org.mozilla.gecko.util.GeckoBackgroundThread;
|
|
||||||
import org.mozilla.gecko.util.GeckoEventListener;
|
import org.mozilla.gecko.util.GeckoEventListener;
|
||||||
import org.mozilla.gecko.util.GeckoEventResponder;
|
import org.mozilla.gecko.util.GeckoEventResponder;
|
||||||
import org.mozilla.gecko.util.ThreadUtils;
|
import org.mozilla.gecko.util.ThreadUtils;
|
||||||
|
@ -626,7 +625,7 @@ abstract public class GeckoApp
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleFaviconRequest(final String url) {
|
void handleFaviconRequest(final String url) {
|
||||||
(new UiAsyncTask<Void, Void, String>(GeckoAppShell.getHandler()) {
|
(new UiAsyncTask<Void, Void, String>(ThreadUtils.getBackgroundHandler()) {
|
||||||
@Override
|
@Override
|
||||||
public String doInBackground(Void... params) {
|
public String doInBackground(Void... params) {
|
||||||
return Favicons.getInstance().getFaviconUrlForPageUrl(url);
|
return Favicons.getInstance().getFaviconUrlForPageUrl(url);
|
||||||
|
@ -802,7 +801,7 @@ abstract public class GeckoApp
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
Toast.makeText(GeckoApp.mAppContext, R.string.bookmark_added, Toast.LENGTH_SHORT).show();
|
Toast.makeText(GeckoApp.mAppContext, R.string.bookmark_added, Toast.LENGTH_SHORT).show();
|
||||||
GeckoAppShell.getHandler().post(new Runnable() {
|
ThreadUtils.postToBackgroundThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
BrowserDB.addBookmark(GeckoApp.mAppContext.getContentResolver(), title, url);
|
BrowserDB.addBookmark(GeckoApp.mAppContext.getContentResolver(), title, url);
|
||||||
|
@ -1104,7 +1103,7 @@ abstract public class GeckoApp
|
||||||
notification.setLatestEventInfo(mAppContext, fileName, progText, emptyIntent );
|
notification.setLatestEventInfo(mAppContext, fileName, progText, emptyIntent );
|
||||||
notification.flags |= Notification.FLAG_ONGOING_EVENT;
|
notification.flags |= Notification.FLAG_ONGOING_EVENT;
|
||||||
notification.show();
|
notification.show();
|
||||||
new UiAsyncTask<Void, Void, Boolean>(GeckoAppShell.getHandler()){
|
new UiAsyncTask<Void, Void, Boolean>(ThreadUtils.getBackgroundHandler()) {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Boolean doInBackground(Void... params) {
|
protected Boolean doInBackground(Void... params) {
|
||||||
|
@ -1440,7 +1439,7 @@ abstract public class GeckoApp
|
||||||
mPrivateBrowsingSession = savedInstanceState.getString(SAVED_STATE_PRIVATE_SESSION);
|
mPrivateBrowsingSession = savedInstanceState.getString(SAVED_STATE_PRIVATE_SESSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
GeckoBackgroundThread.getHandler().post(new Runnable() {
|
ThreadUtils.postToBackgroundThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
SharedPreferences prefs =
|
SharedPreferences prefs =
|
||||||
|
@ -1545,7 +1544,7 @@ abstract public class GeckoApp
|
||||||
Uri data = intent.getData();
|
Uri data = intent.getData();
|
||||||
if (data != null && "http".equals(data.getScheme())) {
|
if (data != null && "http".equals(data.getScheme())) {
|
||||||
startupAction = StartupAction.PREFETCH;
|
startupAction = StartupAction.PREFETCH;
|
||||||
GeckoAppShell.getHandler().post(new PrefetchRunnable(data.toString()));
|
ThreadUtils.postToBackgroundThread(new PrefetchRunnable(data.toString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
Tabs.registerOnTabsChangedListener(this);
|
Tabs.registerOnTabsChangedListener(this);
|
||||||
|
@ -1706,7 +1705,7 @@ abstract public class GeckoApp
|
||||||
// End of the startup of our Java App
|
// End of the startup of our Java App
|
||||||
mJavaUiStartupTimer.stop();
|
mJavaUiStartupTimer.stop();
|
||||||
|
|
||||||
GeckoAppShell.getHandler().postDelayed(new Runnable() {
|
ThreadUtils.getBackgroundHandler().postDelayed(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
// Sync settings need Gecko to be loaded, so
|
// Sync settings need Gecko to be loaded, so
|
||||||
|
@ -1949,7 +1948,7 @@ abstract public class GeckoApp
|
||||||
// User may have enabled/disabled accessibility.
|
// User may have enabled/disabled accessibility.
|
||||||
GeckoAccessibility.updateAccessibilitySettings();
|
GeckoAccessibility.updateAccessibilitySettings();
|
||||||
|
|
||||||
GeckoBackgroundThread.getHandler().post(new Runnable() {
|
ThreadUtils.postToBackgroundThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
SharedPreferences prefs =
|
SharedPreferences prefs =
|
||||||
|
@ -1995,7 +1994,7 @@ abstract public class GeckoApp
|
||||||
// In some way it's sad that Android will trigger StrictMode warnings
|
// In some way it's sad that Android will trigger StrictMode warnings
|
||||||
// here as the whole point is to save to disk while the activity is not
|
// here as the whole point is to save to disk while the activity is not
|
||||||
// interacting with the user.
|
// interacting with the user.
|
||||||
GeckoBackgroundThread.getHandler().post(new Runnable() {
|
ThreadUtils.postToBackgroundThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
SharedPreferences prefs =
|
SharedPreferences prefs =
|
||||||
|
@ -2017,7 +2016,7 @@ abstract public class GeckoApp
|
||||||
@Override
|
@Override
|
||||||
public void onRestart()
|
public void onRestart()
|
||||||
{
|
{
|
||||||
GeckoBackgroundThread.getHandler().post(new Runnable() {
|
ThreadUtils.postToBackgroundThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
SharedPreferences prefs =
|
SharedPreferences prefs =
|
||||||
|
@ -2213,7 +2212,7 @@ abstract public class GeckoApp
|
||||||
if (profileDir != null) {
|
if (profileDir != null) {
|
||||||
final GeckoApp app = GeckoApp.mAppContext;
|
final GeckoApp app = GeckoApp.mAppContext;
|
||||||
|
|
||||||
GeckoAppShell.getHandler().post(new Runnable() {
|
ThreadUtils.postToBackgroundThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
ProfileMigrator profileMigrator = new ProfileMigrator(app);
|
ProfileMigrator profileMigrator = new ProfileMigrator(app);
|
||||||
|
|
|
@ -12,7 +12,6 @@ import org.mozilla.gecko.gfx.LayerView;
|
||||||
import org.mozilla.gecko.gfx.PanZoomController;
|
import org.mozilla.gecko.gfx.PanZoomController;
|
||||||
import org.mozilla.gecko.mozglue.GeckoLoader;
|
import org.mozilla.gecko.mozglue.GeckoLoader;
|
||||||
import org.mozilla.gecko.util.EventDispatcher;
|
import org.mozilla.gecko.util.EventDispatcher;
|
||||||
import org.mozilla.gecko.util.GeckoBackgroundThread;
|
|
||||||
import org.mozilla.gecko.util.GeckoEventListener;
|
import org.mozilla.gecko.util.GeckoEventListener;
|
||||||
import org.mozilla.gecko.util.ThreadUtils;
|
import org.mozilla.gecko.util.ThreadUtils;
|
||||||
|
|
||||||
|
@ -49,7 +48,6 @@ import android.net.ConnectivityManager;
|
||||||
import android.net.NetworkInfo;
|
import android.net.NetworkInfo;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Handler;
|
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
import android.os.MessageQueue;
|
import android.os.MessageQueue;
|
||||||
|
@ -256,10 +254,6 @@ public class GeckoAppShell
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Handler getHandler() {
|
|
||||||
return GeckoBackgroundThread.getHandler();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void runGecko(String apkPath, String args, String url, String type) {
|
public static void runGecko(String apkPath, String args, String url, String type) {
|
||||||
Looper.prepare();
|
Looper.prepare();
|
||||||
|
|
||||||
|
@ -608,7 +602,7 @@ public class GeckoAppShell
|
||||||
public static void createShortcut(final String aTitle, final String aURI, final String aUniqueURI,
|
public static void createShortcut(final String aTitle, final String aURI, final String aUniqueURI,
|
||||||
final Bitmap aIcon, final String aType)
|
final Bitmap aIcon, final String aType)
|
||||||
{
|
{
|
||||||
getHandler().post(new Runnable() {
|
ThreadUtils.postToBackgroundThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
// the intent to be launched by the shortcut
|
// the intent to be launched by the shortcut
|
||||||
|
@ -645,7 +639,7 @@ public class GeckoAppShell
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void removeShortcut(final String aTitle, final String aURI, final String aUniqueURI, final String aType) {
|
public static void removeShortcut(final String aTitle, final String aURI, final String aUniqueURI, final String aType) {
|
||||||
getHandler().post(new Runnable() {
|
ThreadUtils.postToBackgroundThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
// the intent to be launched by the shortcut
|
// the intent to be launched by the shortcut
|
||||||
|
@ -680,7 +674,7 @@ public class GeckoAppShell
|
||||||
// On uninstall, we need to do a couple of things:
|
// On uninstall, we need to do a couple of things:
|
||||||
// 1. nuke the running app process.
|
// 1. nuke the running app process.
|
||||||
// 2. nuke the profile that was assigned to that webapp
|
// 2. nuke the profile that was assigned to that webapp
|
||||||
getHandler().post(new Runnable() {
|
ThreadUtils.postToBackgroundThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
int index = WebAppAllocator.getInstance(GeckoApp.mAppContext).releaseIndexForApp(uniqueURI);
|
int index = WebAppAllocator.getInstance(GeckoApp.mAppContext).releaseIndexForApp(uniqueURI);
|
||||||
|
@ -1117,7 +1111,7 @@ public class GeckoAppShell
|
||||||
// Note: the main looper won't work because it may be blocked on the
|
// Note: the main looper won't work because it may be blocked on the
|
||||||
// gecko thread, which is most likely this thread
|
// gecko thread, which is most likely this thread
|
||||||
static String getClipboardText() {
|
static String getClipboardText() {
|
||||||
getHandler().post(new Runnable() {
|
ThreadUtils.postToBackgroundThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public void run() {
|
public void run() {
|
||||||
|
@ -1151,7 +1145,7 @@ public class GeckoAppShell
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setClipboardText(final String text) {
|
static void setClipboardText(final String text) {
|
||||||
getHandler().post(new Runnable() {
|
ThreadUtils.postToBackgroundThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public void run() {
|
public void run() {
|
||||||
|
@ -1852,7 +1846,7 @@ public class GeckoAppShell
|
||||||
}
|
}
|
||||||
|
|
||||||
static void markUriVisited(final String uri) { // invoked from native JNI code
|
static void markUriVisited(final String uri) { // invoked from native JNI code
|
||||||
getHandler().post(new Runnable() {
|
ThreadUtils.postToBackgroundThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
GlobalHistory.getInstance().add(uri);
|
GlobalHistory.getInstance().add(uri);
|
||||||
|
@ -1861,7 +1855,7 @@ public class GeckoAppShell
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setUriTitle(final String uri, final String title) { // invoked from native JNI code
|
static void setUriTitle(final String uri, final String title) { // invoked from native JNI code
|
||||||
getHandler().post(new Runnable() {
|
ThreadUtils.postToBackgroundThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
GlobalHistory.getInstance().update(uri, title);
|
GlobalHistory.getInstance().update(uri, title);
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
package org.mozilla.gecko;
|
package org.mozilla.gecko;
|
||||||
|
|
||||||
import org.mozilla.gecko.db.BrowserDB;
|
import org.mozilla.gecko.db.BrowserDB;
|
||||||
|
import org.mozilla.gecko.util.ThreadUtils;
|
||||||
|
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
|
@ -39,7 +40,7 @@ class GlobalHistory {
|
||||||
private boolean mProcessing; // = false // whether or not the runnable is queued/working
|
private boolean mProcessing; // = false // whether or not the runnable is queued/working
|
||||||
|
|
||||||
private GlobalHistory() {
|
private GlobalHistory() {
|
||||||
mHandler = GeckoAppShell.getHandler();
|
mHandler = ThreadUtils.getBackgroundHandler();
|
||||||
mPendingUris = new LinkedList<String>();
|
mPendingUris = new LinkedList<String>();
|
||||||
mVisitedCache = new SoftReference<Set<String>>(null);
|
mVisitedCache = new SoftReference<Set<String>>(null);
|
||||||
mNotifierRunnable = new Runnable() {
|
mNotifierRunnable = new Runnable() {
|
||||||
|
|
|
@ -7,6 +7,7 @@ package org.mozilla.gecko;
|
||||||
|
|
||||||
import org.mozilla.gecko.db.BrowserDB;
|
import org.mozilla.gecko.db.BrowserDB;
|
||||||
import org.mozilla.gecko.db.BrowserContract;
|
import org.mozilla.gecko.db.BrowserContract;
|
||||||
|
import org.mozilla.gecko.util.ThreadUtils;
|
||||||
|
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.ComponentCallbacks2;
|
import android.content.ComponentCallbacks2;
|
||||||
|
@ -105,7 +106,7 @@ class MemoryMonitor extends BroadcastReceiver {
|
||||||
if (Intent.ACTION_DEVICE_STORAGE_LOW.equals(intent.getAction())) {
|
if (Intent.ACTION_DEVICE_STORAGE_LOW.equals(intent.getAction())) {
|
||||||
Log.d(LOGTAG, "Device storage is low");
|
Log.d(LOGTAG, "Device storage is low");
|
||||||
mStoragePressure = true;
|
mStoragePressure = true;
|
||||||
GeckoAppShell.getHandler().post(new StorageReducer(context));
|
ThreadUtils.postToBackgroundThread(new StorageReducer(context));
|
||||||
} else if (Intent.ACTION_DEVICE_STORAGE_OK.equals(intent.getAction())) {
|
} else if (Intent.ACTION_DEVICE_STORAGE_OK.equals(intent.getAction())) {
|
||||||
Log.d(LOGTAG, "Device storage is ok");
|
Log.d(LOGTAG, "Device storage is ok");
|
||||||
mStoragePressure = false;
|
mStoragePressure = false;
|
||||||
|
@ -178,9 +179,9 @@ class MemoryMonitor extends BroadcastReceiver {
|
||||||
synchronized void start() {
|
synchronized void start() {
|
||||||
if (mPosted) {
|
if (mPosted) {
|
||||||
// cancel the old one before scheduling a new one
|
// cancel the old one before scheduling a new one
|
||||||
GeckoAppShell.getHandler().removeCallbacks(this);
|
ThreadUtils.getBackgroundHandler().removeCallbacks(this);
|
||||||
}
|
}
|
||||||
GeckoAppShell.getHandler().postDelayed(this, DECREMENT_DELAY);
|
ThreadUtils.getBackgroundHandler().postDelayed(this, DECREMENT_DELAY);
|
||||||
mPosted = true;
|
mPosted = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -193,7 +194,7 @@ class MemoryMonitor extends BroadcastReceiver {
|
||||||
}
|
}
|
||||||
|
|
||||||
// need to keep decrementing
|
// need to keep decrementing
|
||||||
GeckoAppShell.getHandler().postDelayed(this, DECREMENT_DELAY);
|
ThreadUtils.getBackgroundHandler().postDelayed(this, DECREMENT_DELAY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -207,7 +208,7 @@ class MemoryMonitor extends BroadcastReceiver {
|
||||||
public void run() {
|
public void run() {
|
||||||
// this might get run right on startup, if so wait 10 seconds and try again
|
// this might get run right on startup, if so wait 10 seconds and try again
|
||||||
if (!GeckoThread.checkLaunchState(GeckoThread.LaunchState.GeckoRunning)) {
|
if (!GeckoThread.checkLaunchState(GeckoThread.LaunchState.GeckoRunning)) {
|
||||||
GeckoAppShell.getHandler().postDelayed(this, 10000);
|
ThreadUtils.getBackgroundHandler().postDelayed(this, 10000);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
|
|
||||||
package org.mozilla.gecko;
|
package org.mozilla.gecko;
|
||||||
|
|
||||||
|
import org.mozilla.gecko.util.ThreadUtils;
|
||||||
|
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.app.AlertDialog.Builder;
|
import android.app.AlertDialog.Builder;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
@ -184,7 +186,7 @@ class MultiChoicePreference extends DialogPreference {
|
||||||
mPrevValues = mValues.clone();
|
mPrevValues = mValues.clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
GeckoAppShell.getHandler().post(new Runnable() {
|
ThreadUtils.postToBackgroundThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
for (int i = 0; i < mEntryKeys.length; i++) {
|
for (int i = 0; i < mEntryKeys.length; i++) {
|
||||||
|
@ -233,7 +235,7 @@ class MultiChoicePreference extends DialogPreference {
|
||||||
}
|
}
|
||||||
|
|
||||||
mValues = new boolean[entryCount];
|
mValues = new boolean[entryCount];
|
||||||
GeckoAppShell.getHandler().post(new Runnable() {
|
ThreadUtils.postToBackgroundThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
for (int i = 0; i < entryCount; i++) {
|
for (int i = 0; i < entryCount; i++) {
|
||||||
|
|
|
@ -14,6 +14,7 @@ import org.mozilla.gecko.sqlite.SQLiteBridge;
|
||||||
import org.mozilla.gecko.sqlite.SQLiteBridgeException;
|
import org.mozilla.gecko.sqlite.SQLiteBridgeException;
|
||||||
import org.mozilla.gecko.sync.setup.SyncAccounts;
|
import org.mozilla.gecko.sync.setup.SyncAccounts;
|
||||||
import org.mozilla.gecko.sync.setup.SyncAccounts.SyncAccountParameters;
|
import org.mozilla.gecko.sync.setup.SyncAccounts.SyncAccountParameters;
|
||||||
|
import org.mozilla.gecko.util.ThreadUtils;
|
||||||
|
|
||||||
import android.accounts.Account;
|
import android.accounts.Account;
|
||||||
import android.content.ContentProviderOperation;
|
import android.content.ContentProviderOperation;
|
||||||
|
@ -609,7 +610,7 @@ public class ProfileMigrator {
|
||||||
final String clientName = mSyncSettingsMap.get("services.sync.client.name");
|
final String clientName = mSyncSettingsMap.get("services.sync.client.name");
|
||||||
final String clientGuid = mSyncSettingsMap.get("services.sync.client.GUID");
|
final String clientGuid = mSyncSettingsMap.get("services.sync.client.GUID");
|
||||||
|
|
||||||
GeckoAppShell.getHandler().post(new Runnable() {
|
ThreadUtils.postToBackgroundThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (userName == null || syncKey == null || syncPass == null) {
|
if (userName == null || syncKey == null || syncPass == null) {
|
||||||
|
@ -637,7 +638,7 @@ public class ProfileMigrator {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void registerAndRequest() {
|
protected void registerAndRequest() {
|
||||||
GeckoAppShell.getHandler().post(new Runnable() {
|
ThreadUtils.postToBackgroundThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
requestValues();
|
requestValues();
|
||||||
|
@ -652,7 +653,7 @@ public class ProfileMigrator {
|
||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(Boolean result) {
|
protected void onPostExecute(Boolean result) {
|
||||||
if (result.booleanValue()) {
|
if (result.booleanValue()) {
|
||||||
GeckoAppShell.getHandler().post(new Runnable() {
|
ThreadUtils.postToBackgroundThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
Log.i(LOGTAG, "Sync account already configured, skipping.");
|
Log.i(LOGTAG, "Sync account already configured, skipping.");
|
||||||
|
@ -933,7 +934,7 @@ public class ProfileMigrator {
|
||||||
|
|
||||||
// GlobalHistory access communicates with Gecko
|
// GlobalHistory access communicates with Gecko
|
||||||
// and must run on its thread.
|
// and must run on its thread.
|
||||||
GeckoAppShell.getHandler().post(new Runnable() {
|
ThreadUtils.postToBackgroundThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
for (String url : placesHistory) {
|
for (String url : placesHistory) {
|
||||||
|
|
|
@ -15,6 +15,7 @@ import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import org.mozilla.gecko.db.BrowserDB;
|
import org.mozilla.gecko.db.BrowserDB;
|
||||||
import org.mozilla.gecko.gfx.Layer;
|
import org.mozilla.gecko.gfx.Layer;
|
||||||
|
import org.mozilla.gecko.util.ThreadUtils;
|
||||||
|
|
||||||
import android.content.ContentResolver;
|
import android.content.ContentResolver;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
|
@ -163,7 +164,7 @@ public class Tab {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateThumbnail(final Bitmap b) {
|
public void updateThumbnail(final Bitmap b) {
|
||||||
GeckoAppShell.getHandler().post(new Runnable() {
|
ThreadUtils.postToBackgroundThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (b != null) {
|
if (b != null) {
|
||||||
|
@ -321,7 +322,7 @@ public class Tab {
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateBookmark() {
|
void updateBookmark() {
|
||||||
GeckoAppShell.getHandler().post(new Runnable() {
|
ThreadUtils.postToBackgroundThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
final String url = getURL();
|
final String url = getURL();
|
||||||
|
@ -339,7 +340,7 @@ public class Tab {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addBookmark() {
|
public void addBookmark() {
|
||||||
GeckoAppShell.getHandler().post(new Runnable() {
|
ThreadUtils.postToBackgroundThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
String url = getURL();
|
String url = getURL();
|
||||||
|
@ -352,7 +353,7 @@ public class Tab {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeBookmark() {
|
public void removeBookmark() {
|
||||||
GeckoAppShell.getHandler().post(new Runnable() {
|
ThreadUtils.postToBackgroundThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
String url = getURL();
|
String url = getURL();
|
||||||
|
@ -549,7 +550,7 @@ public class Tab {
|
||||||
|
|
||||||
final String oldURL = getURL();
|
final String oldURL = getURL();
|
||||||
final Tab tab = this;
|
final Tab tab = this;
|
||||||
GeckoAppShell.getHandler().postDelayed(new Runnable() {
|
ThreadUtils.getBackgroundHandler().postDelayed(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
// tab.getURL() may return null
|
// tab.getURL() may return null
|
||||||
|
|
|
@ -6,8 +6,9 @@
|
||||||
package org.mozilla.gecko;
|
package org.mozilla.gecko;
|
||||||
|
|
||||||
import org.mozilla.gecko.db.BrowserDB;
|
import org.mozilla.gecko.db.BrowserDB;
|
||||||
import org.mozilla.gecko.util.GeckoEventListener;
|
|
||||||
import org.mozilla.gecko.sync.setup.SyncAccounts;
|
import org.mozilla.gecko.sync.setup.SyncAccounts;
|
||||||
|
import org.mozilla.gecko.util.GeckoEventListener;
|
||||||
|
import org.mozilla.gecko.util.ThreadUtils;
|
||||||
|
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
@ -106,7 +107,7 @@ public class Tabs implements GeckoEventListener {
|
||||||
};
|
};
|
||||||
|
|
||||||
// The listener will run on the background thread (see 2nd argument).
|
// The listener will run on the background thread (see 2nd argument).
|
||||||
mAccountManager.addOnAccountsUpdatedListener(mAccountListener, GeckoAppShell.getHandler(), false);
|
mAccountManager.addOnAccountsUpdatedListener(mAccountListener, ThreadUtils.getBackgroundHandler(), false);
|
||||||
|
|
||||||
if (mContentObserver != null) {
|
if (mContentObserver != null) {
|
||||||
BrowserDB.registerBookmarkObserver(getContentResolver(), mContentObserver);
|
BrowserDB.registerBookmarkObserver(getContentResolver(), mContentObserver);
|
||||||
|
@ -449,7 +450,7 @@ public class Tabs implements GeckoEventListener {
|
||||||
|
|
||||||
public void refreshThumbnails() {
|
public void refreshThumbnails() {
|
||||||
final ThumbnailHelper helper = ThumbnailHelper.getInstance();
|
final ThumbnailHelper helper = ThumbnailHelper.getInstance();
|
||||||
GeckoAppShell.getHandler().post(new Runnable() {
|
ThreadUtils.postToBackgroundThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
for (final Tab tab : mOrder) {
|
for (final Tab tab : mOrder) {
|
||||||
|
@ -553,7 +554,7 @@ public class Tabs implements GeckoEventListener {
|
||||||
public void persistAllTabs() {
|
public void persistAllTabs() {
|
||||||
final GeckoApp activity = getActivity();
|
final GeckoApp activity = getActivity();
|
||||||
final Iterable<Tab> tabs = getTabsInOrder();
|
final Iterable<Tab> tabs = getTabsInOrder();
|
||||||
GeckoAppShell.getHandler().post(new Runnable() {
|
ThreadUtils.postToBackgroundThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
boolean syncIsSetup = SyncAccounts.syncAccountsExist(activity);
|
boolean syncIsSetup = SyncAccounts.syncAccountsExist(activity);
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
package org.mozilla.gecko;
|
package org.mozilla.gecko;
|
||||||
|
|
||||||
import org.mozilla.gecko.db.BrowserContract;
|
import org.mozilla.gecko.db.BrowserContract;
|
||||||
|
import org.mozilla.gecko.util.ThreadUtils;
|
||||||
import org.mozilla.gecko.util.UiAsyncTask;
|
import org.mozilla.gecko.util.UiAsyncTask;
|
||||||
|
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
|
@ -73,7 +74,7 @@ public final class TabsAccessor {
|
||||||
if (listener == null)
|
if (listener == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
(new UiAsyncTask<Void, Void, List<RemoteTab>>(GeckoAppShell.getHandler()) {
|
(new UiAsyncTask<Void, Void, List<RemoteTab>>(ThreadUtils.getBackgroundHandler()) {
|
||||||
@Override
|
@Override
|
||||||
protected List<RemoteTab> doInBackground(Void... unused) {
|
protected List<RemoteTab> doInBackground(Void... unused) {
|
||||||
Uri uri = BrowserContract.Tabs.CONTENT_URI;
|
Uri uri = BrowserContract.Tabs.CONTENT_URI;
|
||||||
|
|
|
@ -10,7 +10,7 @@ import android.content.SharedPreferences;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
|
|
||||||
import org.mozilla.gecko.gfx.BitmapUtils;
|
import org.mozilla.gecko.gfx.BitmapUtils;
|
||||||
import org.mozilla.gecko.util.GeckoBackgroundThread;
|
import org.mozilla.gecko.util.ThreadUtils;
|
||||||
|
|
||||||
public class WebAppAllocator {
|
public class WebAppAllocator {
|
||||||
private final String LOGTAG = "GeckoWebAppAllocator";
|
private final String LOGTAG = "GeckoWebAppAllocator";
|
||||||
|
@ -70,7 +70,7 @@ public class WebAppAllocator {
|
||||||
if (!mPrefs.contains(appKey(i))) {
|
if (!mPrefs.contains(appKey(i))) {
|
||||||
// found unused index i
|
// found unused index i
|
||||||
final int foundIndex = i;
|
final int foundIndex = i;
|
||||||
GeckoBackgroundThread.getHandler().post(new Runnable() {
|
ThreadUtils.postToBackgroundThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
int color = 0;
|
int color = 0;
|
||||||
|
@ -118,7 +118,7 @@ public class WebAppAllocator {
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void releaseIndex(final int index) {
|
public synchronized void releaseIndex(final int index) {
|
||||||
GeckoBackgroundThread.getHandler().post(new Runnable() {
|
ThreadUtils.postToBackgroundThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
mPrefs.edit()
|
mPrefs.edit()
|
||||||
|
|
|
@ -177,7 +177,7 @@ public class AllPagesTab extends AwesomeBarTab implements GeckoEventListener {
|
||||||
* Query for suggestions, but don't show them yet.
|
* Query for suggestions, but don't show them yet.
|
||||||
*/
|
*/
|
||||||
private void primeSuggestions() {
|
private void primeSuggestions() {
|
||||||
GeckoAppShell.getHandler().post(new Runnable() {
|
ThreadUtils.postToBackgroundThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
mSuggestClient.query(mSearchTerm);
|
mSuggestClient.query(mSearchTerm);
|
||||||
|
@ -844,7 +844,7 @@ public class AllPagesTab extends AwesomeBarTab implements GeckoEventListener {
|
||||||
if (urls.size() == 0)
|
if (urls.size() == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
(new UiAsyncTask<Void, Void, Cursor>(GeckoAppShell.getHandler()) {
|
(new UiAsyncTask<Void, Void, Cursor>(ThreadUtils.getBackgroundHandler()) {
|
||||||
@Override
|
@Override
|
||||||
public Cursor doInBackground(Void... params) {
|
public Cursor doInBackground(Void... params) {
|
||||||
return BrowserDB.getFaviconsForUrls(getContentResolver(), urls);
|
return BrowserDB.getFaviconsForUrls(getContentResolver(), urls);
|
||||||
|
|
|
@ -356,7 +356,7 @@ public class HistoryTab extends AwesomeBarTab {
|
||||||
|
|
||||||
if (mContentObserver == null) {
|
if (mContentObserver == null) {
|
||||||
// Register an observer to update the history tab contents if they change.
|
// Register an observer to update the history tab contents if they change.
|
||||||
mContentObserver = new ContentObserver(GeckoAppShell.getHandler()) {
|
mContentObserver = new ContentObserver(ThreadUtils.getBackgroundHandler()) {
|
||||||
@Override
|
@Override
|
||||||
public void onChange(boolean selfChange) {
|
public void onChange(boolean selfChange) {
|
||||||
mQueryTask = new HistoryQueryTask();
|
mQueryTask = new HistoryQueryTask();
|
||||||
|
|
|
@ -38,8 +38,8 @@ import org.mozilla.gecko.db.DBUtils;
|
||||||
import org.mozilla.gecko.gfx.BitmapUtils;
|
import org.mozilla.gecko.gfx.BitmapUtils;
|
||||||
import org.mozilla.gecko.ProfileMigrator;
|
import org.mozilla.gecko.ProfileMigrator;
|
||||||
import org.mozilla.gecko.sync.Utils;
|
import org.mozilla.gecko.sync.Utils;
|
||||||
import org.mozilla.gecko.util.GeckoBackgroundThread;
|
|
||||||
import org.mozilla.gecko.util.GeckoJarReader;
|
import org.mozilla.gecko.util.GeckoJarReader;
|
||||||
|
import org.mozilla.gecko.util.ThreadUtils;
|
||||||
|
|
||||||
import android.app.SearchManager;
|
import android.app.SearchManager;
|
||||||
import android.content.ContentProvider;
|
import android.content.ContentProvider;
|
||||||
|
@ -1026,7 +1026,7 @@ public class BrowserProvider extends ContentProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
// create icons in a separate thread to avoid blocking about:home on startup
|
// create icons in a separate thread to avoid blocking about:home on startup
|
||||||
GeckoBackgroundThread.getHandler().post(new Runnable() {
|
ThreadUtils.postToBackgroundThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
|
@ -1069,7 +1069,7 @@ public class BrowserProvider extends ContentProvider {
|
||||||
createBookmark(db, title, url, pos);
|
createBookmark(db, title, url, pos);
|
||||||
|
|
||||||
// create icons in a separate thread to avoid blocking about:home on startup
|
// create icons in a separate thread to avoid blocking about:home on startup
|
||||||
GeckoBackgroundThread.getHandler().post(new Runnable() {
|
ThreadUtils.postToBackgroundThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
Bitmap icon = getDefaultFaviconFromPath(name);
|
Bitmap icon = getDefaultFaviconFromPath(name);
|
||||||
|
@ -1993,7 +1993,7 @@ public class BrowserProvider extends ContentProvider {
|
||||||
public boolean onCreate() {
|
public boolean onCreate() {
|
||||||
debug("Creating BrowserProvider");
|
debug("Creating BrowserProvider");
|
||||||
|
|
||||||
GeckoBackgroundThread.post(new Runnable() {
|
ThreadUtils.postToBackgroundThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
// Kick this off early. It is synchronized so that other callers will wait
|
// Kick this off early. It is synchronized so that other callers will wait
|
||||||
|
|
|
@ -15,7 +15,7 @@ import org.mozilla.gecko.db.BrowserContract.Clients;
|
||||||
import org.mozilla.gecko.db.BrowserContract.Tabs;
|
import org.mozilla.gecko.db.BrowserContract.Tabs;
|
||||||
import org.mozilla.gecko.db.BrowserContract;
|
import org.mozilla.gecko.db.BrowserContract;
|
||||||
import org.mozilla.gecko.db.DBUtils;
|
import org.mozilla.gecko.db.DBUtils;
|
||||||
import org.mozilla.gecko.util.GeckoBackgroundThread;
|
import org.mozilla.gecko.util.ThreadUtils;
|
||||||
|
|
||||||
import android.content.ContentProvider;
|
import android.content.ContentProvider;
|
||||||
import android.content.ContentUris;
|
import android.content.ContentUris;
|
||||||
|
@ -289,7 +289,7 @@ public class TabsProvider extends ContentProvider {
|
||||||
public boolean onCreate() {
|
public boolean onCreate() {
|
||||||
debug("Creating TabsProvider");
|
debug("Creating TabsProvider");
|
||||||
|
|
||||||
GeckoBackgroundThread.post(new Runnable() {
|
ThreadUtils.postToBackgroundThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
// Kick this off early. It is synchronized so that other callers will wait
|
// Kick this off early. It is synchronized so that other callers will wait
|
||||||
|
|
|
@ -9,7 +9,7 @@ import android.os.Looper;
|
||||||
|
|
||||||
import java.util.concurrent.SynchronousQueue;
|
import java.util.concurrent.SynchronousQueue;
|
||||||
|
|
||||||
public final class GeckoBackgroundThread extends Thread {
|
final class GeckoBackgroundThread extends Thread {
|
||||||
private static final String LOOPER_NAME = "GeckoBackgroundThread";
|
private static final String LOOPER_NAME = "GeckoBackgroundThread";
|
||||||
|
|
||||||
// Guarded by 'this'.
|
// Guarded by 'this'.
|
||||||
|
@ -33,7 +33,7 @@ public final class GeckoBackgroundThread extends Thread {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get a Handler for a looper thread, or create one if it doesn't yet exist.
|
// Get a Handler for a looper thread, or create one if it doesn't yet exist.
|
||||||
public static synchronized Handler getHandler() {
|
/*package*/ static synchronized Handler getHandler() {
|
||||||
if (sHandler == null) {
|
if (sHandler == null) {
|
||||||
GeckoBackgroundThread lt = new GeckoBackgroundThread();
|
GeckoBackgroundThread lt = new GeckoBackgroundThread();
|
||||||
ThreadUtils.setBackgroundThread(lt);
|
ThreadUtils.setBackgroundThread(lt);
|
||||||
|
@ -45,7 +45,7 @@ public final class GeckoBackgroundThread extends Thread {
|
||||||
return sHandler;
|
return sHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void post(Runnable runnable) {
|
/*package*/ static void post(Runnable runnable) {
|
||||||
Handler handler = getHandler();
|
Handler handler = getHandler();
|
||||||
if (handler == null) {
|
if (handler == null) {
|
||||||
throw new IllegalStateException("No handler! Must have been interrupted. Not posting.");
|
throw new IllegalStateException("No handler! Must have been interrupted. Not posting.");
|
||||||
|
|
|
@ -47,6 +47,14 @@ public final class ThreadUtils {
|
||||||
return sBackgroundThread;
|
return sBackgroundThread;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Handler getBackgroundHandler() {
|
||||||
|
return GeckoBackgroundThread.getHandler();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void postToBackgroundThread(Runnable runnable) {
|
||||||
|
GeckoBackgroundThread.post(runnable);
|
||||||
|
}
|
||||||
|
|
||||||
public static void assertOnUiThread() {
|
public static void assertOnUiThread() {
|
||||||
assertOnThread(getUiThread());
|
assertOnThread(getUiThread());
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче