Merge mozilla-central to mozilla-inbound

This commit is contained in:
Ed Morley 2012-10-08 10:02:28 +01:00
Родитель a41d9f7522 6d04357320
Коммит b112ca967d
6 изменённых файлов: 20 добавлений и 18 удалений

Просмотреть файл

@ -547,7 +547,7 @@ public class AwesomeBar extends GeckoActivity {
editPrompt.setPositiveButton(R.string.button_ok, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
(new GeckoAsyncTask<Void, Void, Void>() {
(new GeckoAsyncTask<Void, Void, Void>(GeckoApp.mAppContext, GeckoAppShell.getHandler()) {
@Override
public Void doInBackground(Void... params) {
String newUrl = locationText.getText().toString().trim();
@ -623,7 +623,7 @@ public class AwesomeBar extends GeckoActivity {
break;
}
case R.id.remove_history: {
(new GeckoAsyncTask<Void, Void, Void>() {
(new GeckoAsyncTask<Void, Void, Void>(GeckoApp.mAppContext, GeckoAppShell.getHandler()) {
@Override
public Void doInBackground(Void... params) {
BrowserDB.removeHistoryEntry(mResolver, id);

Просмотреть файл

@ -917,7 +917,7 @@ abstract public class BrowserApp extends GeckoApp
if (!Intent.ACTION_MAIN.equals(intent.getAction()))
return;
(new GeckoAsyncTask<Void, Void, Boolean>() {
(new GeckoAsyncTask<Void, Void, Boolean>(mAppContext, GeckoAppShell.getHandler()) {
@Override
public synchronized Boolean doInBackground(Void... params) {
// Check to see how many times the app has been launched.
@ -954,7 +954,7 @@ abstract public class BrowserApp extends GeckoApp
}
private void getLastUrl() {
(new GeckoAsyncTask<Void, Void, String>() {
(new GeckoAsyncTask<Void, Void, String>(mAppContext, GeckoAppShell.getHandler()) {
@Override
public synchronized String doInBackground(Void... params) {
// Get the most recent URL stored in browser history.

Просмотреть файл

@ -775,7 +775,7 @@ abstract public class GeckoApp
}
void handleFaviconRequest(final String url) {
(new GeckoAsyncTask<Void, Void, String>() {
(new GeckoAsyncTask<Void, Void, String>(mAppContext, GeckoAppShell.getHandler()) {
@Override
public String doInBackground(Void... params) {
return getFavicons().getFaviconUrlForPageUrl(url);

Просмотреть файл

@ -5,20 +5,22 @@
package org.mozilla.gecko.util;
import android.app.Activity;
import android.os.Handler;
// GeckoAsyncTask runs onPostExecute on the thread it is constructed on.
// To ensure that onPostExecute() runs on UI thread, do either of these:
// 1. construct GeckoAsyncTask on the UI thread
// 2. post to the view's UI thread, in onPostExecute()
// AsyncTask runs onPostExecute on the thread it is constructed on
// We construct these off of the main thread, and we want that to run
// on the main UI thread, so this is a convenience class to do that
public abstract class GeckoAsyncTask<Params, Progress, Result> {
public enum Priority { NORMAL, HIGH };
private final Handler mHandler;
private final Activity mActivity;
private final Handler mBackgroundThreadHandler;
private Priority mPriority = Priority.NORMAL;
public GeckoAsyncTask() {
mHandler = new Handler();
public GeckoAsyncTask(Activity activity, Handler backgroundThreadHandler) {
mActivity = activity;
mBackgroundThreadHandler = backgroundThreadHandler;
}
private final class BackgroundTaskRunnable implements Runnable {
@ -30,7 +32,7 @@ public abstract class GeckoAsyncTask<Params, Progress, Result> {
public void run() {
final Result result = doInBackground(mParams);
mHandler.post(new Runnable() {
mActivity.runOnUiThread(new Runnable() {
public void run() {
onPostExecute(result);
}
@ -41,9 +43,9 @@ public abstract class GeckoAsyncTask<Params, Progress, Result> {
public final void execute(final Params... params) {
BackgroundTaskRunnable runnable = new BackgroundTaskRunnable(params);
if (mPriority == Priority.HIGH)
GeckoBackgroundThread.getHandler().postAtFrontOfQueue(runnable);
mBackgroundThreadHandler.postAtFrontOfQueue(runnable);
else
GeckoBackgroundThread.getHandler().post(runnable);
mBackgroundThreadHandler.post(runnable);
}
public final GeckoAsyncTask<Params, Progress, Result> setPriority(Priority priority) {

Просмотреть файл

@ -378,7 +378,7 @@ public final class Tab {
if (url == null)
return;
(new GeckoAsyncTask<Void, Void, Void>() {
(new GeckoAsyncTask<Void, Void, Void>(GeckoApp.mAppContext, GeckoAppShell.getHandler()) {
@Override
public Void doInBackground(Void... params) {
if (url.equals(getURL())) {

Просмотреть файл

@ -71,7 +71,7 @@ public final class TabsAccessor {
if (listener == null)
return;
(new GeckoAsyncTask<Void, Void, Boolean>() {
(new GeckoAsyncTask<Void, Void, Boolean>(GeckoApp.mAppContext, GeckoAppShell.getHandler()) {
@Override
protected Boolean doInBackground(Void... unused) {
Uri uri = BrowserContract.Tabs.CONTENT_URI;
@ -115,7 +115,7 @@ public final class TabsAccessor {
if (listener == null)
return;
(new GeckoAsyncTask<Void, Void, List<RemoteTab>>() {
(new GeckoAsyncTask<Void, Void, List<RemoteTab>>(GeckoApp.mAppContext, GeckoAppShell.getHandler()) {
@Override
protected List<RemoteTab> doInBackground(Void... unused) {
Uri uri = BrowserContract.Tabs.CONTENT_URI;