Bug 672956 - Use history expiration. r=mfinkle
authorWes Johnston <wjohnston@mozilla.com>
Fri, 19 Oct 2012 17:36:21 -0700
changeset 110974 0636839be2d1530f1ff271d6d0558757b0612101
parent 110973 31cdc85ce16ebc66af489319967d60ed9bde6d09
child 110975 d40649836ffaab8d927fdfea1c8f159eece9fda3
push id93
push usernmatsakis@mozilla.com
push dateWed, 31 Oct 2012 21:26:57 +0000
reviewersmfinkle
bugs672956
milestone19.0a1
Bug 672956 - Use history expiration. r=mfinkle
mobile/android/base/GeckoApp.java
mobile/android/base/MemoryMonitor.java
--- a/mobile/android/base/GeckoApp.java
+++ b/mobile/android/base/GeckoApp.java
@@ -1,16 +1,17 @@
 /* -*- Mode: Java; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: nil; -*-
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 package org.mozilla.gecko;
 
 import org.mozilla.gecko.db.BrowserDB;
+import org.mozilla.gecko.db.BrowserContract;
 import org.mozilla.gecko.gfx.Layer;
 import org.mozilla.gecko.gfx.LayerView;
 import org.mozilla.gecko.gfx.PluginLayer;
 import org.mozilla.gecko.gfx.PointUtils;
 import org.mozilla.gecko.ui.PanZoomController;
 import org.mozilla.gecko.util.GeckoAsyncTask;
 import org.mozilla.gecko.util.GeckoBackgroundThread;
 import org.mozilla.gecko.util.GeckoEventListener;
@@ -2096,16 +2097,19 @@ abstract public class GeckoApp
         // interacting with the user.
         GeckoBackgroundThread.getHandler().post(new Runnable() {
             public void run() {
                 SharedPreferences prefs =
                     GeckoApp.mAppContext.getSharedPreferences(GeckoApp.PREFS_NAME, 0);
                 SharedPreferences.Editor editor = prefs.edit();
                 editor.putBoolean(GeckoApp.PREFS_WAS_STOPPED, true);
                 editor.commit();
+
+                BrowserDB.expireHistory(getContentResolver(),
+                                        BrowserContract.ExpirePriority.NORMAL);
             }
         });
 
         GeckoScreenOrientationListener.getInstance().stop();
 
         super.onPause();
     }
 
--- a/mobile/android/base/MemoryMonitor.java
+++ b/mobile/android/base/MemoryMonitor.java
@@ -1,16 +1,17 @@
 /* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 package org.mozilla.gecko;
 
 import org.mozilla.gecko.db.BrowserDB;
+import org.mozilla.gecko.db.BrowserContract;
 
 import android.content.BroadcastReceiver;
 import android.content.ComponentCallbacks2;
 import android.content.Context;
 import android.content.Intent;
 import android.content.IntentFilter;
 import android.os.Build;
 import android.os.Debug;
@@ -48,24 +49,26 @@ class MemoryMonitor extends BroadcastRec
 
     static MemoryMonitor getInstance() {
         return sInstance;
     }
 
     private final PressureDecrementer mPressureDecrementer;
     private int mMemoryPressure;
     private boolean mStoragePressure;
+    private Context mContext;
 
     private MemoryMonitor() {
         mPressureDecrementer = new PressureDecrementer();
         mMemoryPressure = MEMORY_PRESSURE_NONE;
         mStoragePressure = false;
     }
 
     public void init(Context context) {
+        mContext = context;
         IntentFilter filter = new IntentFilter();
         filter.addAction(Intent.ACTION_DEVICE_STORAGE_LOW);
         filter.addAction(Intent.ACTION_DEVICE_STORAGE_OK);
         filter.addAction(ACTION_MEMORY_DUMP);
         filter.addAction(ACTION_FORCE_PRESSURE);
         context.getApplicationContext().registerReceiver(this, filter);
     }
 
@@ -212,13 +215,15 @@ class MemoryMonitor extends BroadcastRec
                 return;
             }
 
             if (!mStoragePressure) {
                 // pressure is off, so we can abort
                 return;
             }
 
+            BrowserDB.expireHistory(mContext.getContentResolver(),
+                                    BrowserContract.ExpirePriority.AGGRESSIVE);
             BrowserDB.removeThumbnails(Tabs.getInstance().getContentResolver());
             // TODO: drop or shrink disk caches
         }
     }
 }