Commit fe4a3436 authored by Sam Maier's avatar Sam Maier Committed by Commit Bot

Android: Removing more Params usages in AsyncTask

This is a follow-up to
https://chromium-review.googlesource.com/c/chromium/src/+/1136730

I appear to have missed a few sites in the previous CL.

Bug: 843745
Change-Id: I541f0db2e9cf8e419a3303b7ab2a08a1df0c0372
Reviewed-on: https://chromium-review.googlesource.com/1148982
Commit-Queue: Sam Maier <smaier@chromium.org>
Reviewed-by: default avatarBernhard Bauer <bauerb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#577909}
parent d3cf1351
...@@ -173,10 +173,10 @@ public final class DefaultBrowserInfo { ...@@ -173,10 +173,10 @@ public final class DefaultBrowserInfo {
.isStartupSuccessfullyCompleted(); .isStartupSuccessfullyCompleted();
try { try {
new AsyncTask<Context, Void, DefaultInfo>() { new AsyncTask<Void, Void, DefaultInfo>() {
@Override @Override
protected DefaultInfo doInBackground(Context... params) { protected DefaultInfo doInBackground(Void... params) {
Context context = params[0]; Context context = ContextUtils.getApplicationContext();
PackageManager pm = context.getPackageManager(); PackageManager pm = context.getPackageManager();
...@@ -222,8 +222,7 @@ public final class DefaultBrowserInfo { ...@@ -222,8 +222,7 @@ public final class DefaultBrowserInfo {
getDefaultBrowserUmaState(info), MobileDefaultBrowserState.NUM_ENTRIES); getDefaultBrowserUmaState(info), MobileDefaultBrowserState.NUM_ENTRIES);
} }
} }
.executeOnExecutor( .executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
AsyncTask.THREAD_POOL_EXECUTOR, ContextUtils.getApplicationContext());
} catch (RejectedExecutionException ex) { } catch (RejectedExecutionException ex) {
// Fail silently here since this is not a critical task. // Fail silently here since this is not a critical task.
} }
......
...@@ -67,22 +67,25 @@ class FileDeletionQueue { ...@@ -67,22 +67,25 @@ class FileDeletionQueue {
System.out.println("dtrainor: Starting " + file.getName()); System.out.println("dtrainor: Starting " + file.getName());
mTask = new FileDeletionTask(); mTask = new FileDeletionTask(file);
mTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, file); mTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} }
private class FileDeletionTask extends AsyncTask<File, Void, Void> { private class FileDeletionTask extends AsyncTask<Void, Void, Void> {
// AsyncTask implementation. private final File mFile;
FileDeletionTask(File file) {
mFile = file;
}
@Override @Override
protected Void doInBackground(File... params) { protected Void doInBackground(Void... params) {
System.out.println("dtrainor: Deleting " + params[0].getName()); mDeleter.onResult(mFile);
mDeleter.onResult(params[0]);
return null; return null;
} }
@Override @Override
protected void onPostExecute(Void result) { protected void onPostExecute(Void result) {
System.out.println("dtrainor: Post");
super.onPostExecute(result); super.onPostExecute(result);
mTask = null; mTask = null;
deleteNextFile(); deleteNextFile();
......
...@@ -95,9 +95,9 @@ public final class ConnectivityChecker { ...@@ -95,9 +95,9 @@ public final class ConnectivityChecker {
postResult(callback, ConnectivityCheckResult.ERROR); postResult(callback, ConnectivityCheckResult.ERROR);
return; return;
} }
new AsyncTask<String, Void, Integer>() { new AsyncTask<Void, Void, Integer>() {
@Override @Override
protected Integer doInBackground(String... strings) { protected Integer doInBackground(Void... params) {
try { try {
HttpURLConnection conn = (HttpURLConnection) url.openConnection(); HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setInstanceFollowRedirects(false); conn.setInstanceFollowRedirects(false);
...@@ -127,7 +127,8 @@ public final class ConnectivityChecker { ...@@ -127,7 +127,8 @@ public final class ConnectivityChecker {
protected void onPostExecute(Integer result) { protected void onPostExecute(Integer result) {
callback.onResult(result); callback.onResult(result);
} }
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); }
.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} }
/** /**
......
...@@ -150,12 +150,13 @@ public class WebApkServiceConnectionManager { ...@@ -150,12 +150,13 @@ public class WebApkServiceConnectionManager {
public void disconnectAll(final Context appContext) { public void disconnectAll(final Context appContext) {
if (mConnections.isEmpty()) return; if (mConnections.isEmpty()) return;
Connection[] values = mConnections.values().toArray(new Connection[mConnections.size()]); final Connection[] values =
mConnections.values().toArray(new Connection[mConnections.size()]);
mConnections.clear(); mConnections.clear();
new AsyncTask<Connection, Void, Void>() { new AsyncTask<Void, Void, Void>() {
@Override @Override
protected final Void doInBackground(Connection... values) { protected final Void doInBackground(Void... params) {
for (Connection connection : values) { for (Connection connection : values) {
if (connection.getService() != null) { if (connection.getService() != null) {
appContext.unbindService(connection); appContext.unbindService(connection);
...@@ -163,7 +164,8 @@ public class WebApkServiceConnectionManager { ...@@ -163,7 +164,8 @@ public class WebApkServiceConnectionManager {
} }
return null; return null;
} }
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, values); }
.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} }
public WebApkServiceConnectionManager(String category, String action) { public WebApkServiceConnectionManager(String category, String action) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment