Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(533)

Unified Diff: components/policy/android/java/src/org/chromium/policy/AbstractAppRestrictionsProvider.java

Issue 1514903002: Move some calls from the Android UI thread to the Chrome one (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Pass findbug Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/policy/android/java/src/org/chromium/policy/AbstractAppRestrictionsProvider.java
diff --git a/components/policy/android/java/src/org/chromium/policy/AbstractAppRestrictionsProvider.java b/components/policy/android/java/src/org/chromium/policy/AbstractAppRestrictionsProvider.java
index 82b19399d9ec1ae6f8fe20fcb4cb678ee251b5ed..64f886b169d84764d0a02b7cdcf3b3c01a8bf122 100644
--- a/components/policy/android/java/src/org/chromium/policy/AbstractAppRestrictionsProvider.java
+++ b/components/policy/android/java/src/org/chromium/policy/AbstractAppRestrictionsProvider.java
@@ -11,11 +11,13 @@
import android.content.SharedPreferences;
import android.os.AsyncTask;
import android.os.Bundle;
+import android.os.Handler;
import android.os.Parcel;
import android.preference.PreferenceManager;
import android.util.Base64;
import org.chromium.base.Log;
+import org.chromium.base.ThreadUtils;
import org.chromium.base.VisibleForTesting;
import org.chromium.base.metrics.RecordHistogram;
@@ -75,8 +77,10 @@ public AbstractAppRestrictionsProvider(Context context) {
public void startListeningForPolicyChanges() {
String changeIntentAction = getRestrictionChangeIntentAction();
if (changeIntentAction == null) return;
- mContext.registerReceiver(
- mAppRestrictionsChangedReceiver, new IntentFilter(changeIntentAction));
+
+ mContext.registerReceiver(mAppRestrictionsChangedReceiver,
+ new IntentFilter(changeIntentAction), null,
+ new Handler(ThreadUtils.getUiThreadLooper()));
}
/**
@@ -95,21 +99,22 @@ public void refresh() {
notifySettingsAvailable(cachedResult);
}
- new AsyncTask<Void, Void, Bundle>() {
+ mExecutor.execute(new Runnable() {
@Override
- protected Bundle doInBackground(Void... params) {
+ public void run() {
long startTime = System.currentTimeMillis();
- Bundle bundle = getApplicationRestrictions(mContext.getPackageName());
+ final Bundle bundle = getApplicationRestrictions(mContext.getPackageName());
recordStartTimeHistogram(startTime);
- return bundle;
- }
- @Override
- protected void onPostExecute(Bundle result) {
- cachePolicies(result);
- notifySettingsAvailable(result);
+ ThreadUtils.runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ cachePolicies(bundle);
+ notifySettingsAvailable(bundle);
+ }
+ });
}
- }.executeOnExecutor(mExecutor);
+ });
}
@Override

Powered by Google App Engine
This is Rietveld 408576698