Bug 919645 - crash in android.os.NetworkOnMainThreadException. r=bnicholson

This commit is contained in:
Richard Newman 2013-10-07 12:54:41 -07:00
parent 4960e67245
commit 4031f88e1f

View File

@ -18,6 +18,7 @@ import org.mozilla.gecko.GeckoAppShell;
import org.mozilla.gecko.db.BrowserDB;
import org.mozilla.gecko.gfx.BitmapUtils;
import org.mozilla.gecko.util.GeckoJarReader;
import org.mozilla.gecko.util.ThreadUtils;
import org.mozilla.gecko.util.UiAsyncTask;
import static org.mozilla.gecko.favicons.Favicons.sContext;
@ -212,8 +213,21 @@ public class LoadFaviconTask extends UiAsyncTask<Void, Void, Bitmap> {
}
static void closeHTTPClient() {
if (sHttpClient != null) {
sHttpClient.close();
// This work must be done on a background thread because it shuts down
// the connection pool, which typically involves closing a connection --
// which counts as network activity.
if (ThreadUtils.isOnBackgroundThread()) {
if (sHttpClient != null) {
sHttpClient.close();
}
return;
}
ThreadUtils.postToBackgroundThread(new Runnable() {
@Override
public void run() {
LoadFaviconTask.closeHTTPClient();
}
});
}
}