Loading mobile/android/base/MemoryMonitor.java +22 −2 Original line number Diff line number Diff line Loading @@ -5,6 +5,8 @@ package org.mozilla.gecko; import org.mozilla.gecko.db.BrowserDB; import android.content.BroadcastReceiver; import android.content.ComponentCallbacks2; import android.content.Context; Loading Loading @@ -106,8 +108,7 @@ class MemoryMonitor extends BroadcastReceiver { if (Intent.ACTION_DEVICE_STORAGE_LOW.equals(intent.getAction())) { Log.d(LOGTAG, "Device storage is low"); mStoragePressure = true; // TODO: drop or shrink disk caches // TODO: drop stuff from browser.db GeckoAppShell.getHandler().post(new StorageReducer()); } else if (Intent.ACTION_DEVICE_STORAGE_OK.equals(intent.getAction())) { Log.d(LOGTAG, "Device storage is ok"); mStoragePressure = false; Loading Loading @@ -201,4 +202,23 @@ class MemoryMonitor extends BroadcastReceiver { GeckoAppShell.getHandler().postDelayed(this, DECREMENT_DELAY); } } class StorageReducer implements Runnable { @Override public void run() { // this might get run right on startup, if so wait 10 seconds and try again if (!GeckoApp.checkLaunchState(GeckoApp.LaunchState.GeckoRunning)) { GeckoAppShell.getHandler().postDelayed(this, 10000); return; } if (!mStoragePressure) { // pressure is off, so we can abort return; } BrowserDB.removeThumbnails(Tabs.getInstance().getContentResolver()); // TODO: drop or shrink disk caches } } } mobile/android/base/db/BrowserDB.java +6 −0 Original line number Diff line number Diff line Loading @@ -75,6 +75,8 @@ public class BrowserDB { public byte[] getThumbnailForUrl(ContentResolver cr, String uri); public void removeThumbnails(ContentResolver cr); public void registerBookmarkObserver(ContentResolver cr, ContentObserver observer); public void registerHistoryObserver(ContentResolver cr, ContentObserver observer); Loading Loading @@ -186,6 +188,10 @@ public class BrowserDB { return sDb.getThumbnailForUrl(cr, uri); } public static void removeThumbnails(ContentResolver cr) { sDb.removeThumbnails(cr); } public static void registerBookmarkObserver(ContentResolver cr, ContentObserver observer) { sDb.registerBookmarkObserver(cr, observer); } Loading mobile/android/base/db/BrowserProvider.java.in +3 −3 Original line number Diff line number Diff line Loading @@ -1662,10 +1662,10 @@ public class BrowserProvider extends ContentProvider { String url = values.getAsString(Images.URL); // if no URL is provided, update all of the entries if (TextUtils.isEmpty(url)) throw new IllegalArgumentException("Images.URL is required"); if (shouldUpdateOrInsert(uri)) updated = updateExistingImage(uri, values, null, null); else if (shouldUpdateOrInsert(uri)) updated = updateOrInsertImage(uri, values, Images.URL + " = ?", new String[] { url }); else Loading mobile/android/base/db/LocalBrowserDB.java +6 −0 Original line number Diff line number Diff line Loading @@ -680,6 +680,12 @@ public class LocalBrowserDB implements BrowserDB.BrowserDBIface { return b; } public void removeThumbnails(ContentResolver cr) { ContentValues values = new ContentValues(); values.putNull(Images.THUMBNAIL); cr.update(mImagesUriWithProfile, values, null, null); } // Utility function for updating existing history using batch operations public void updateHistoryInBatch(ContentResolver cr, Collection<ContentProviderOperation> operations, Loading Loading
mobile/android/base/MemoryMonitor.java +22 −2 Original line number Diff line number Diff line Loading @@ -5,6 +5,8 @@ package org.mozilla.gecko; import org.mozilla.gecko.db.BrowserDB; import android.content.BroadcastReceiver; import android.content.ComponentCallbacks2; import android.content.Context; Loading Loading @@ -106,8 +108,7 @@ class MemoryMonitor extends BroadcastReceiver { if (Intent.ACTION_DEVICE_STORAGE_LOW.equals(intent.getAction())) { Log.d(LOGTAG, "Device storage is low"); mStoragePressure = true; // TODO: drop or shrink disk caches // TODO: drop stuff from browser.db GeckoAppShell.getHandler().post(new StorageReducer()); } else if (Intent.ACTION_DEVICE_STORAGE_OK.equals(intent.getAction())) { Log.d(LOGTAG, "Device storage is ok"); mStoragePressure = false; Loading Loading @@ -201,4 +202,23 @@ class MemoryMonitor extends BroadcastReceiver { GeckoAppShell.getHandler().postDelayed(this, DECREMENT_DELAY); } } class StorageReducer implements Runnable { @Override public void run() { // this might get run right on startup, if so wait 10 seconds and try again if (!GeckoApp.checkLaunchState(GeckoApp.LaunchState.GeckoRunning)) { GeckoAppShell.getHandler().postDelayed(this, 10000); return; } if (!mStoragePressure) { // pressure is off, so we can abort return; } BrowserDB.removeThumbnails(Tabs.getInstance().getContentResolver()); // TODO: drop or shrink disk caches } } }
mobile/android/base/db/BrowserDB.java +6 −0 Original line number Diff line number Diff line Loading @@ -75,6 +75,8 @@ public class BrowserDB { public byte[] getThumbnailForUrl(ContentResolver cr, String uri); public void removeThumbnails(ContentResolver cr); public void registerBookmarkObserver(ContentResolver cr, ContentObserver observer); public void registerHistoryObserver(ContentResolver cr, ContentObserver observer); Loading Loading @@ -186,6 +188,10 @@ public class BrowserDB { return sDb.getThumbnailForUrl(cr, uri); } public static void removeThumbnails(ContentResolver cr) { sDb.removeThumbnails(cr); } public static void registerBookmarkObserver(ContentResolver cr, ContentObserver observer) { sDb.registerBookmarkObserver(cr, observer); } Loading
mobile/android/base/db/BrowserProvider.java.in +3 −3 Original line number Diff line number Diff line Loading @@ -1662,10 +1662,10 @@ public class BrowserProvider extends ContentProvider { String url = values.getAsString(Images.URL); // if no URL is provided, update all of the entries if (TextUtils.isEmpty(url)) throw new IllegalArgumentException("Images.URL is required"); if (shouldUpdateOrInsert(uri)) updated = updateExistingImage(uri, values, null, null); else if (shouldUpdateOrInsert(uri)) updated = updateOrInsertImage(uri, values, Images.URL + " = ?", new String[] { url }); else Loading
mobile/android/base/db/LocalBrowserDB.java +6 −0 Original line number Diff line number Diff line Loading @@ -680,6 +680,12 @@ public class LocalBrowserDB implements BrowserDB.BrowserDBIface { return b; } public void removeThumbnails(ContentResolver cr) { ContentValues values = new ContentValues(); values.putNull(Images.THUMBNAIL); cr.update(mImagesUriWithProfile, values, null, null); } // Utility function for updating existing history using batch operations public void updateHistoryInBatch(ContentResolver cr, Collection<ContentProviderOperation> operations, Loading