mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 746630 - Trigger the "setting up" screen via callbacks instead of timers. r=blassey a=blocking-fennec
This commit is contained in:
parent
37f4d82a7d
commit
2983d0a348
@ -2298,13 +2298,33 @@ abstract public class GeckoApp
|
||||
|
||||
// Do a migration run on the first start after an upgrade.
|
||||
if (!profileMigrator.hasMigrationRun()) {
|
||||
// Show the "Setting up Fennec" screen if this takes
|
||||
// a while.
|
||||
final SetupScreen setupScreen = new SetupScreen(app);
|
||||
|
||||
// Don't show unless this take a while.
|
||||
setupScreen.showDelayed(mMainHandler);
|
||||
final Runnable startCallback = new Runnable() {
|
||||
public void run() {
|
||||
GeckoApp.mAppContext.runOnUiThread(new Runnable() {
|
||||
public void run() {
|
||||
setupScreen.show();
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
final Runnable stopCallback = new Runnable() {
|
||||
public void run() {
|
||||
GeckoApp.mAppContext.runOnUiThread(new Runnable() {
|
||||
public void run() {
|
||||
setupScreen.dismiss();
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
profileMigrator.setLongOperationCallbacks(startCallback,
|
||||
stopCallback);
|
||||
profileMigrator.launchPlaces();
|
||||
setupScreen.dismiss();
|
||||
|
||||
long timeDiff = SystemClock.uptimeMillis() - currentTime;
|
||||
Log.i(LOGTAG, "Profile migration took " + timeDiff + " ms");
|
||||
|
@ -98,6 +98,9 @@ public class ProfileMigrator {
|
||||
private File mProfileDir;
|
||||
private ContentResolver mCr;
|
||||
private Context mContext;
|
||||
private Runnable mLongOperationStartCallback;
|
||||
private boolean mLongOperationStartRun;
|
||||
private Runnable mLongOperationStopCallback;
|
||||
|
||||
// Default number of history entries to migrate in one run.
|
||||
private static final int DEFAULT_HISTORY_MIGRATE_COUNT = 2000;
|
||||
@ -260,6 +263,17 @@ public class ProfileMigrator {
|
||||
mProfileDir = profileDir;
|
||||
mContext = context;
|
||||
mCr = mContext.getContentResolver();
|
||||
mLongOperationStartCallback = null;
|
||||
mLongOperationStopCallback = null;
|
||||
}
|
||||
|
||||
// Define callbacks to run if the operation will take a while.
|
||||
// Stop callback is only run if there was a start callback that was run.
|
||||
public void setLongOperationCallbacks(Runnable start,
|
||||
Runnable stop) {
|
||||
mLongOperationStartCallback = start;
|
||||
mLongOperationStopCallback = stop;
|
||||
mLongOperationStartRun = false;
|
||||
}
|
||||
|
||||
public void launchPlaces() {
|
||||
@ -276,6 +290,7 @@ public class ProfileMigrator {
|
||||
}
|
||||
|
||||
public void launchPlaces(int maxEntries) {
|
||||
mLongOperationStartRun = false;
|
||||
// Places migration is heavy on the phone, allow it to block
|
||||
// other processing.
|
||||
new PlacesRunnable(maxEntries).run();
|
||||
@ -1171,6 +1186,11 @@ public class ProfileMigrator {
|
||||
setMigratedHistory();
|
||||
} else {
|
||||
// Compatible schema. Let's go.
|
||||
if (mLongOperationStartCallback != null) {
|
||||
mLongOperationStartCallback.run();
|
||||
mLongOperationStartRun = true;
|
||||
}
|
||||
|
||||
calculateReroot(db);
|
||||
|
||||
if (!areBookmarksMigrated()) {
|
||||
@ -1205,7 +1225,12 @@ public class ProfileMigrator {
|
||||
db.close();
|
||||
}
|
||||
Log.e(LOGTAG, "Error on places database:", e);
|
||||
return;
|
||||
} finally {
|
||||
if (mLongOperationStopCallback != null) {
|
||||
if (mLongOperationStartRun) {
|
||||
mLongOperationStopCallback.run();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user