Backed out changesets 4fee6e1f1ad2 and f5db0dae1434 (bug 1075644) for Android 2.3 robocop failures.

CLOSED TREE
This commit is contained in:
Ryan VanderMeulen 2014-10-06 15:47:30 -04:00
Родитель 6e7b635c34
Коммит 4324a5dfea
4 изменённых файлов: 18 добавлений и 25 удалений

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

@ -1177,6 +1177,8 @@ public abstract class GeckoApp
Class.forName("android.os.AsyncTask");
} catch (ClassNotFoundException e) {}
MemoryMonitor.getInstance().init(getApplicationContext());
// GeckoAppShell is tightly coupled to us, rather than
// the app context, because various parts of Fennec (e.g.,
// GeckoScreenOrientation) use GAS to access the Activity in
@ -1186,6 +1188,13 @@ public abstract class GeckoApp
GeckoAppShell.setContextGetter(this);
GeckoAppShell.setGeckoInterface(this);
Tabs.getInstance().attachToContext(this);
try {
Favicons.initializeWithContext(this);
} catch (Exception e) {
Log.e(LOGTAG, "Exception starting favicon cache. Corrupt resources?", e);
}
// Did the OS locale change while we were backgrounded? If so,
// we need to die so that Gecko will re-init add-ons that touch
// the UI.
@ -1229,20 +1238,6 @@ public abstract class GeckoApp
}, 1000 * 5 /* 5 seconds */);
}
// Heavy load on the Gecko thread can slow down the time it takes for UI to appear on
// single-core devices. By minimizing the Gecko thread priority, we ensure that the UI
// appears quickly. The priority is reset to normal once thumbnails are loaded.
ThreadUtils.reduceGeckoPriority();
MemoryMonitor.getInstance().init(getApplicationContext());
Tabs.getInstance().attachToContext(this);
try {
Favicons.initializeWithContext(this);
} catch (Exception e) {
Log.e(LOGTAG, "Exception starting favicon cache. Corrupt resources?", e);
}
Bundle stateBundle = getIntent().getBundleExtra(EXTRA_STATE_BUNDLE);
if (stateBundle != null) {
// Use the state bundle if it was given as an intent extra. This is
@ -1610,10 +1605,6 @@ public abstract class GeckoApp
} else if (NotificationHelper.HELPER_BROADCAST_ACTION.equals(action)) {
NotificationHelper.getInstance(getApplicationContext()).handleNotificationIntent(intent);
}
// Reset Gecko to normal priority. We may reduce the
// priority again later, e.g. for loading thumbnails.
ThreadUtils.resetGeckoPriority();
}
private String restoreSessionTabs(final boolean isExternalURL) throws SessionRestoreException {

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

@ -51,7 +51,6 @@ public class GeckoThread extends Thread implements GeckoEventListener {
if (isCreated())
return false;
sGeckoThread = new GeckoThread(sArgs, sAction, sUri);
ThreadUtils.sGeckoThread = sGeckoThread;
return true;
}
@ -165,6 +164,7 @@ public class GeckoThread extends Thread implements GeckoEventListener {
@Override
public void run() {
Looper.prepare();
ThreadUtils.sGeckoThread = this;
ThreadUtils.sGeckoHandler = new Handler();
ThreadUtils.sGeckoQueue = Looper.myQueue();

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

@ -98,6 +98,9 @@ public class TopSitesPanel extends HomeFragment {
// Max number of entries shown in the grid from the cursor.
private int mMaxGridEntries;
// Time in ms until the Gecko thread is reset to normal priority.
private static final long PRIORITY_RESET_TIMEOUT = 10000;
public static TopSitesPanel newInstance() {
return new TopSitesPanel();
}
@ -344,7 +347,7 @@ public class TopSitesPanel extends HomeFragment {
// appear, especially during startup (bug 897162). By minimizing the
// Gecko thread priority, we ensure that the UI appears quickly. The
// priority is reset to normal once thumbnails are loaded.
ThreadUtils.reduceGeckoPriority();
ThreadUtils.reduceGeckoPriority(PRIORITY_RESET_TIMEOUT);
}
/**

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

@ -17,9 +17,6 @@ import android.util.Log;
public final class ThreadUtils {
private static final String LOGTAG = "ThreadUtils";
// Time in ms until the Gecko thread is reset to normal priority.
private static final long PRIORITY_RESET_TIMEOUT = 10000;
/**
* Controls the action taken when a method like
* {@link ThreadUtils#assertOnUiThread(AssertBehavior)} detects a problem.
@ -212,8 +209,10 @@ public final class ThreadUtils {
*
* Note that there are no guards in place to prevent multiple calls
* to this method from conflicting with each other.
*
* @param timeout Timeout in ms after which the priority will be reset
*/
public static void reduceGeckoPriority() {
public static void reduceGeckoPriority(long timeout) {
if (Runtime.getRuntime().availableProcessors() > 1) {
// Don't reduce priority for multicore devices. We use availableProcessors()
// for its fast performance. It may give false negatives (i.e. multicore
@ -223,7 +222,7 @@ public final class ThreadUtils {
if (!sIsGeckoPriorityReduced && sGeckoThread != null) {
sIsGeckoPriorityReduced = true;
sGeckoThread.setPriority(Thread.MIN_PRIORITY);
getUiHandler().postDelayed(sPriorityResetRunnable, PRIORITY_RESET_TIMEOUT);
getUiHandler().postDelayed(sPriorityResetRunnable, timeout);
}
}