diff options
| author | John Reck <jreck@google.com> | 2011-07-22 11:28:05 -0700 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-07-22 11:28:05 -0700 |
| commit | 7c6a6dcb2fafab1ceca86e70c84095d21a0671b3 (patch) | |
| tree | d9d689a2912fe8efcbf0c116c99c49877121b842 /src/com/android/browser/Controller.java | |
| parent | b765583492ef90c163b61588d16789d58f941b7b (diff) | |
| parent | f57c029329e874399199259b5e69f4d0b8a12a38 (diff) | |
Merge "Startup optimization"
Diffstat (limited to 'src/com/android/browser/Controller.java')
| -rw-r--r-- | src/com/android/browser/Controller.java | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/src/com/android/browser/Controller.java b/src/com/android/browser/Controller.java index 03e2d8b4..731da18d 100644 --- a/src/com/android/browser/Controller.java +++ b/src/com/android/browser/Controller.java @@ -206,7 +206,6 @@ public class Controller // Checks to see when the bookmarks database has changed, and updates the // Tabs' notion of whether they represent bookmarked sites. private ContentObserver mBookmarksObserver; - private DataController mDataController; private CrashRecoveryHandler mCrashRecoveryHandler; private boolean mSimulateActionBarOverlayMode; @@ -228,7 +227,6 @@ public class Controller public Controller(Activity browser) { mActivity = browser; mSettings = BrowserSettings.getInstance(); - mDataController = DataController.getInstance(mActivity); mTabControl = new TabControl(this); mSettings.setController(this); mCrashRecoveryHandler = CrashRecoveryHandler.initialize(this); @@ -239,10 +237,6 @@ public class Controller mPageDialogsHandler = new PageDialogsHandler(mActivity, this); mNfcHandler = new NfcHandler(mActivity, this); - PowerManager pm = (PowerManager) mActivity - .getSystemService(Context.POWER_SERVICE); - mWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "Browser"); - startHandler(); mBookmarksObserver = new ContentObserver(mHandler) { @Override @@ -518,7 +512,7 @@ public class Controller break; case RELEASE_WAKELOCK: - if (mWakeLock.isHeld()) { + if (mWakeLock != null && mWakeLock.isHeld()) { mWakeLock.release(); // if we reach here, Browser should be still in the // background loading after WAKELOCK_TIMEOUT (5-min). @@ -622,6 +616,11 @@ public class Controller if (tab != null) { tab.pause(); if (!pauseWebViewTimers(tab)) { + if (mWakeLock == null) { + PowerManager pm = (PowerManager) mActivity + .getSystemService(Context.POWER_SERVICE); + mWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "Browser"); + } mWakeLock.acquire(); mHandler.sendMessageDelayed(mHandler .obtainMessage(RELEASE_WAKELOCK), WAKELOCK_TIMEOUT); @@ -662,10 +661,7 @@ public class Controller current.resume(); resumeWebViewTimers(current); } - if (mWakeLock.isHeld()) { - mHandler.removeMessages(RELEASE_WAKELOCK); - mWakeLock.release(); - } + releaseWakeLock(); mUi.onResume(); mNetworkHandler.onResume(); @@ -673,6 +669,13 @@ public class Controller WebView.enablePlatformNotifications(); } + private void releaseWakeLock() { + if (mWakeLock != null && mWakeLock.isHeld()) { + mHandler.removeMessages(RELEASE_WAKELOCK); + mWakeLock.release(); + } + } + /** * resume all WebView timers using the WebView instance of the given tab * @param tab guaranteed non-null @@ -832,10 +835,7 @@ public class Controller // pause the WebView timer and release the wake lock if it is finished // while BrowserActivity is in pause state. if (mActivityPaused && pauseWebViewTimers(tab)) { - if (mWakeLock.isHeld()) { - mHandler.removeMessages(RELEASE_WAKELOCK); - mWakeLock.release(); - } + releaseWakeLock(); } // Performance probe @@ -890,7 +890,7 @@ public class Controller } // Update the title in the history database if not in private browsing mode if (!tab.isPrivateBrowsingEnabled()) { - mDataController.updateHistoryTitle(pageUrl, title); + DataController.getInstance(mActivity).updateHistoryTitle(pageUrl, title); } } @@ -937,7 +937,7 @@ public class Controller || url.regionMatches(true, 0, "about:", 0, 6)) { return; } - mDataController.updateVisitedHistory(url); + DataController.getInstance(mActivity).updateVisitedHistory(url); WebIconDatabase.getInstance().retainIconForPageUrl(url); if (!mActivityPaused) { // Since we clear the state in onPause, don't backup the current |
