bug 623598 - avoid repeatedly extracting and deleting libraries r=mbrubeck a=blocking-fennec

This commit is contained in:
Brad Lassey 2011-01-06 21:02:07 -05:00
parent 4a7bcc91be
commit 20887a7a34
2 changed files with 15 additions and 4 deletions

View File

@ -79,7 +79,8 @@ class GeckoAppShell
static private final int NOTIFY_IME_CANCELCOMPOSITION = 2;
static private final int NOTIFY_IME_FOCUSCHANGE = 3;
static private final long kFreeSpaceThreshold = 19660800L; // 150Mb
static private final long kFreeSpaceThreshold = 157286400L; // 150MB
static private final long kLibFreeSpaceBuffer = 20971520L; // 29MB
/* The Android-side API: API methods that Android calls */
@ -138,8 +139,7 @@ class GeckoAppShell
putLocaleEnv();
boolean shouldExtact = freeSpace > kFreeSpaceThreshold;
if (!shouldExtact) {
if (freeSpace + kLibFreeSpaceBuffer < kFreeSpaceThreshold) {
// remove any previously extracted libs since we're apparently low
Iterator cacheFiles = Arrays.asList(cacheFile.listFiles()).iterator();
while (cacheFiles.hasNext()) {
@ -148,7 +148,7 @@ class GeckoAppShell
libFile.delete();
}
}
loadLibs(apkName, shouldExtact);
loadLibs(apkName, freeSpace > kFreeSpaceThreshold);
}
private static void putLocaleEnv() {

View File

@ -464,6 +464,16 @@ static void * mozload(const char * path, void *zip,
if (letoh16(file->compression) == DEFLATE) {
int cache_fd = lookupLibCacheFd(path + 4);
fd = cache_fd;
if (fd < 0) {
char fullpath[256];
snprintf(fullpath, 256, "%s/%s", getenv("CACHE_PATH"), path + 4);
fd = open(fullpath, O_RDWR);
struct stat status;
if (stat(fullpath, &status) ||
status.st_size != lib_size ||
apk_mtime > status.st_mtime)
fd = -1;
}
if (fd < 0)
fd = createAshmem(lib_size);
#ifdef DEBUG
@ -644,6 +654,7 @@ Java_org_mozilla_gecko_GeckoAppShell_loadLibs(JNIEnv *jenv, jclass jGeckoAppShel
{
if (jShouldExtract)
extractLibs = 1;
const char* str;
// XXX: java doesn't give us true UTF8, we should figure out something
// better to do here