summaryrefslogtreecommitdiffstats
path: root/src/com/android/browser/SystemAllowGeolocationOrigins.java
diff options
context:
space:
mode:
authorJohn Reck <jreck@google.com>2011-07-25 11:36:17 -0700
committerJohn Reck <jreck@google.com>2011-07-25 13:59:38 -0700
commitcadae72b6309303bc7b22e85181222b73e176c32 (patch)
treea33394121bd6c3553f9dc4a6d3dca04a914f4604 /src/com/android/browser/SystemAllowGeolocationOrigins.java
parent420d149566e19f1663db69420375b6dd1f0acd6f (diff)
downloadpackages_apps_Browser-cadae72b6309303bc7b22e85181222b73e176c32.zip
packages_apps_Browser-cadae72b6309303bc7b22e85181222b73e176c32.tar.gz
packages_apps_Browser-cadae72b6309303bc7b22e85181222b73e176c32.tar.bz2
Switch to a background thread pool
Bug: 5019676 Use a shared thread pool Eliminate some unnecessary use of AsyncTask (which has extra overhead compared to using a thread pool) Change-Id: I01d6c84816a9c9705216c8fdb8ed8c990265626a
Diffstat (limited to 'src/com/android/browser/SystemAllowGeolocationOrigins.java')
-rw-r--r--src/com/android/browser/SystemAllowGeolocationOrigins.java65
1 files changed, 32 insertions, 33 deletions
diff --git a/src/com/android/browser/SystemAllowGeolocationOrigins.java b/src/com/android/browser/SystemAllowGeolocationOrigins.java
index b53611f..a01541f 100644
--- a/src/com/android/browser/SystemAllowGeolocationOrigins.java
+++ b/src/com/android/browser/SystemAllowGeolocationOrigins.java
@@ -73,49 +73,48 @@ class SystemAllowGeolocationOrigins {
}
void maybeApplySettingAsync() {
- new AsyncTask<Void,Void,Void>() {
- @Override
- protected Void doInBackground(Void... params) {
- maybeApplySetting();
- return null;
- }
- }.execute();
+ BackgroundHandler.execute(mMaybeApplySetting);
}
/**
* Checks to see if the system setting has changed and if so,
* updates the Geolocation permissions accordingly.
*/
- private void maybeApplySetting() {
- // Get the new value
- String newSetting = getSystemSetting();
-
- // Get the last read value
- SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(mContext);
- String lastReadSetting =
- preferences.getString(LAST_READ_ALLOW_GEOLOCATION_ORIGINS, "");
-
- // If the new value is the same as the last one we read, we're done.
- if (TextUtils.equals(lastReadSetting, newSetting)) {
- return;
- }
+ private Runnable mMaybeApplySetting = new Runnable() {
- // Save the new value as the last read value
- preferences.edit()
- .putString(LAST_READ_ALLOW_GEOLOCATION_ORIGINS, newSetting)
- .apply();
+ @Override
+ public void run() {
+ // Get the new value
+ String newSetting = getSystemSetting();
+
+ // Get the last read value
+ SharedPreferences preferences = BrowserSettings.getInstance()
+ .getPreferences();
+ String lastReadSetting =
+ preferences.getString(LAST_READ_ALLOW_GEOLOCATION_ORIGINS, "");
+
+ // If the new value is the same as the last one we read, we're done.
+ if (TextUtils.equals(lastReadSetting, newSetting)) {
+ return;
+ }
- Set<String> oldOrigins = parseAllowGeolocationOrigins(lastReadSetting);
- Set<String> newOrigins = parseAllowGeolocationOrigins(newSetting);
- Set<String> addedOrigins = setMinus(newOrigins, oldOrigins);
- Set<String> removedOrigins = setMinus(oldOrigins, newOrigins);
+ // Save the new value as the last read value
+ preferences.edit()
+ .putString(LAST_READ_ALLOW_GEOLOCATION_ORIGINS, newSetting)
+ .apply();
- // Remove the origins in the last read value
- removeOrigins(removedOrigins);
+ Set<String> oldOrigins = parseAllowGeolocationOrigins(lastReadSetting);
+ Set<String> newOrigins = parseAllowGeolocationOrigins(newSetting);
+ Set<String> addedOrigins = setMinus(newOrigins, oldOrigins);
+ Set<String> removedOrigins = setMinus(oldOrigins, newOrigins);
- // Add the origins in the new value
- addOrigins(addedOrigins);
- }
+ // Remove the origins in the last read value
+ removeOrigins(removedOrigins);
+
+ // Add the origins in the new value
+ addOrigins(addedOrigins);
+ }
+ };
/**
* Parses the value of the default geolocation permissions setting.