Bug 1238785 - Start file cleanup in onStart. r=ahunt

I added some log statements to ensure this worked correctly locally - on a new
profile:
  * Log statements were printed listed the two files I expected to be deleted
and their paths
  * The log statements did not appear after closing and reopened fennec,
meaning the process short-circuited as expected.

Ideally, I'd test that a profile that currently has these files actually gets
them deleted, but it's not easy to create profiles.

The previous patches also contributed unit tests.

MozReview-Commit-ID: 1FOZraATc6x

--HG--
extra : rebase_source : f6481569ce478b64571997c7ec44ad59ea0f9d93
This commit is contained in:
Michael Comella 2016-04-12 16:59:50 -07:00
parent 1c8d441139
commit 343dabcba8

View File

@ -20,6 +20,7 @@ import org.mozilla.gecko.GeckoProfileDirectories.NoMozillaDirectoryException;
import org.mozilla.gecko.Tabs.TabEvents;
import org.mozilla.gecko.animation.PropertyAnimator;
import org.mozilla.gecko.animation.ViewHelper;
import org.mozilla.gecko.cleanup.FileCleanupController;
import org.mozilla.gecko.db.BrowserContract;
import org.mozilla.gecko.db.BrowserDB;
import org.mozilla.gecko.db.SuggestedSites;
@ -1062,6 +1063,11 @@ public class BrowserApp extends GeckoApp
// have been shown.
GuestSession.hideNotification(BrowserApp.this);
}
// It'd be better to launch this once, in onCreate, but there's ambiguity for when the
// profile is created so we run here instead. Don't worry, call start short-circuits pretty fast.
final SharedPreferences sharedPrefs = GeckoSharedPrefs.forProfileName(BrowserApp.this, profile.getName());
FileCleanupController.startIfReady(BrowserApp.this, sharedPrefs, profile.getDir().getAbsolutePath());
}
});