diff options
| author | John Reck <jreck@google.com> | 2011-07-21 18:15:39 -0700 |
|---|---|---|
| committer | John Reck <jreck@google.com> | 2011-07-21 18:19:56 -0700 |
| commit | f57c029329e874399199259b5e69f4d0b8a12a38 (patch) | |
| tree | 87d7df605584484af494c69185d3e5dccb0e63cf /src/com/android/browser/BrowserSettings.java | |
| parent | 78a6a1d7c2f5666f90222ecc28fcc26740807cb7 (diff) | |
| download | packages_apps_Browser-f57c029329e874399199259b5e69f4d0b8a12a38.tar.gz packages_apps_Browser-f57c029329e874399199259b5e69f4d0b8a12a38.tar.bz2 packages_apps_Browser-f57c029329e874399199259b5e69f4d0b8a12a38.zip | |
Startup optimization
Bug: 5019676
Save one thread by letting CrashRecoveryHandler re-use the BrowserSettings
startup thread
Lazy initialize the wake lock only if we need it (avoids IPC overhead at startup)
Slight ordering shuffle in BrowserActivity to maximize the usefulness of the
BrowserSettings startup thread
Change-Id: I1fc7412d492f93e0630008fa6030da9e0d726ebb
Diffstat (limited to 'src/com/android/browser/BrowserSettings.java')
| -rw-r--r-- | src/com/android/browser/BrowserSettings.java | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/com/android/browser/BrowserSettings.java b/src/com/android/browser/BrowserSettings.java index 97769fce3..a4f0f044b 100644 --- a/src/com/android/browser/BrowserSettings.java +++ b/src/com/android/browser/BrowserSettings.java @@ -22,6 +22,7 @@ import android.content.Context; import android.content.SharedPreferences; import android.content.SharedPreferences.OnSharedPreferenceChangeListener; import android.os.Build; +import android.os.Looper; import android.os.Message; import android.preference.PreferenceManager; import android.provider.Browser; @@ -103,6 +104,10 @@ public class BrowserSettings implements OnSharedPreferenceChangeListener, private AutofillHandler mAutofillHandler; private WeakHashMap<WebSettings, String> mCustomUserAgents; private boolean mInitialized = false; + // Looper shared between some lightweight background operations + // Specifically, this is created on the thread that initializes browser settings + // and is then reused by CrashRecoveryHandler + private Looper mBackgroundLooper; // Cached values private int mPageCacheCapacity = 1; @@ -127,7 +132,7 @@ public class BrowserSettings implements OnSharedPreferenceChangeListener, mCustomUserAgents = new WeakHashMap<WebSettings, String>(); mPrefs.registerOnSharedPreferenceChangeListener(this); mAutofillHandler.asyncLoadFromDb(); - new Thread(mInitialization, "BrowserSettingsInitialization").start(); + new Thread(mSetupAndLoop, "BackgroundLooper").start(); } public void setController(Controller controller) { @@ -139,6 +144,11 @@ public class BrowserSettings implements OnSharedPreferenceChangeListener, } } + public Looper getBackgroundLooper() { + requireInitialization(); + return mBackgroundLooper; + } + public void startManagingSettings(WebSettings settings) { synchronized (mManagedSettings) { syncStaticSettings(settings); @@ -147,7 +157,7 @@ public class BrowserSettings implements OnSharedPreferenceChangeListener, } } - private Runnable mInitialization = new Runnable() { + private Runnable mSetupAndLoop = new Runnable() { @Override public void run() { @@ -189,10 +199,13 @@ public class BrowserSettings implements OnSharedPreferenceChangeListener, } mPrefs.edit().remove(PREF_TEXT_SIZE).apply(); } + Looper.prepare(); + mBackgroundLooper = Looper.myLooper(); synchronized (BrowserSettings.this) { mInitialized = true; BrowserSettings.this.notifyAll(); } + Looper.loop(); } }; |
