mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-30 21:55:31 +00:00
Bug 919645 - crash in android.os.NetworkOnMainThreadException. r=bnicholson
This commit is contained in:
parent
4960e67245
commit
4031f88e1f
@ -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();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user