diff options
| author | Ben Murdoch <benm@google.com> | 2011-07-25 15:40:58 +0100 |
|---|---|---|
| committer | Ben Murdoch <benm@google.com> | 2011-07-25 16:22:08 +0100 |
| commit | aaa1f375bc9d6a6a175819fac34d39202f69a166 (patch) | |
| tree | 14a9c33f089cbc757778146b90840c1ede48d56c /src/com/android/browser/BrowserSettings.java | |
| parent | 1b4193001e845711376b2c0406fab6898f4660c6 (diff) | |
| download | packages_apps_Browser-aaa1f375bc9d6a6a175819fac34d39202f69a166.tar.gz packages_apps_Browser-aaa1f375bc9d6a6a175819fac34d39202f69a166.tar.bz2 packages_apps_Browser-aaa1f375bc9d6a6a175819fac34d39202f69a166.zip | |
Cache the factory reset URL.
Hitting the browser provider for the factory reset url is one of
our most common strict mode violations, and triggers sqlite disk
io. So now read it once in a background thread and cache it for
future accesses.
Needed to make the requireInitialization() function static, so we
now wait/notify on BrowserSettings.class rather than the instance.
Bug:5072979
Change-Id: I78550965887e32b4f8ad0eaf0013753e63d6f602
Diffstat (limited to 'src/com/android/browser/BrowserSettings.java')
| -rw-r--r-- | src/com/android/browser/BrowserSettings.java | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/src/com/android/browser/BrowserSettings.java b/src/com/android/browser/BrowserSettings.java index a4f0f044b..2023ee61e 100644 --- a/src/com/android/browser/BrowserSettings.java +++ b/src/com/android/browser/BrowserSettings.java @@ -103,7 +103,7 @@ public class BrowserSettings implements OnSharedPreferenceChangeListener, private WebStorageSizeManager mWebStorageSizeManager; private AutofillHandler mAutofillHandler; private WeakHashMap<WebSettings, String> mCustomUserAgents; - private boolean mInitialized = false; + private static boolean sInitialized = 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 @@ -116,6 +116,8 @@ public class BrowserSettings implements OnSharedPreferenceChangeListener, // Cached settings private SearchEngine mSearchEngine; + private static String sFactoryResetUrl; + public static void initialize(final Context context) { sInstance = new BrowserSettings(context); } @@ -199,21 +201,28 @@ public class BrowserSettings implements OnSharedPreferenceChangeListener, } mPrefs.edit().remove(PREF_TEXT_SIZE).apply(); } + + sFactoryResetUrl = mContext.getResources().getString(R.string.homepage_base); + if (sFactoryResetUrl.indexOf("{CID}") != -1) { + sFactoryResetUrl = sFactoryResetUrl.replace("{CID}", + BrowserProvider.getClientId(mContext.getContentResolver())); + } + Looper.prepare(); mBackgroundLooper = Looper.myLooper(); - synchronized (BrowserSettings.this) { - mInitialized = true; - BrowserSettings.this.notifyAll(); + synchronized (BrowserSettings.class) { + sInitialized = true; + BrowserSettings.class.notifyAll(); } Looper.loop(); } }; - void requireInitialization() { - synchronized (BrowserSettings.this) { - while (!mInitialized) { + private static void requireInitialization() { + synchronized (BrowserSettings.class) { + while (!sInitialized) { try { - BrowserSettings.this.wait(); + BrowserSettings.class.wait(); } catch (InterruptedException e) { } } @@ -334,12 +343,8 @@ public class BrowserSettings implements OnSharedPreferenceChangeListener, } public static String getFactoryResetHomeUrl(Context context) { - String url = context.getResources().getString(R.string.homepage_base); - if (url.indexOf("{CID}") != -1) { - url = url.replace("{CID}", - BrowserProvider.getClientId(context.getContentResolver())); - } - return url; + requireInitialization(); + return sFactoryResetUrl; } public LayoutAlgorithm getLayoutAlgorithm() { |
