Commit daadd52a authored by Karolina Soltys's avatar Karolina Soltys Committed by Commit Bot

[scheduler] Changing serial AsyncTask to SequencedTaskRunner.

Bug: 863341
Change-Id: I47e06b340428875125a139f764d2dae570a9eafc
Reviewed-on: https://chromium-review.googlesource.com/c/1478874
Commit-Queue: Karolina Soltys <ksolt@chromium.org>
Reviewed-by: default avatarBo <boliu@chromium.org>
Reviewed-by: default avatarSami Kyöstilä <skyostil@chromium.org>
Cr-Commit-Position: refs/heads/master@{#635960}
parent a188a493
......@@ -28,8 +28,9 @@ import org.chromium.base.annotations.JNINamespace;
import org.chromium.base.library_loader.LibraryLoader;
import org.chromium.base.library_loader.LibraryProcessType;
import org.chromium.base.library_loader.ProcessInitException;
import org.chromium.base.task.AsyncTask;
import org.chromium.base.task.BackgroundOnlyAsyncTask;
import org.chromium.base.task.PostTask;
import org.chromium.base.task.TaskRunner;
import org.chromium.base.task.TaskTraits;
import org.chromium.components.minidump_uploader.CrashFileManager;
import org.chromium.content_public.browser.BrowserStartupController;
import org.chromium.content_public.browser.ChildProcessCreationParams;
......@@ -51,10 +52,22 @@ public final class AwBrowserProcess {
private static final String WEBVIEW_DIR_BASENAME = "webview";
private static final String EXCLUSIVE_LOCK_FILE = "webview_data.lock";
// To avoid any potential synchronization issues we post all minidump-copying actions to
// the same sequence to be run serially.
private static final TaskRunner sSequencedTaskRunner =
PostTask.createSequencedTaskRunner(TaskTraits.BEST_EFFORT_MAY_BLOCK);
private static RandomAccessFile sLockFile;
private static FileLock sExclusiveFileLock;
private static String sWebViewPackageName;
// TODO(ksolt): This is a temporary solution to avoid lifetime check errors.
// Will be fixed after we decide how to handle the destruction of static TaskRunners.
static {
sSequencedTaskRunner.disableLifetimeCheck();
}
/**
* Loads the native library, and performs basic static construction of objects needed
* to run webview in this process. Does not create threads; safe to call from zygote.
......@@ -229,19 +242,17 @@ public final class AwBrowserProcess {
* minidumps, if we don't, delete them.
*/
public static void handleMinidumps(final boolean userApproved) {
new BackgroundOnlyAsyncTask<Void>() {
@Override
protected Void doInBackground() {
sSequencedTaskRunner.postTask(() -> {
final Context appContext = ContextUtils.getApplicationContext();
final File crashSpoolDir = new File(appContext.getCacheDir().getPath(), "WebView");
if (!crashSpoolDir.isDirectory()) return null;
if (!crashSpoolDir.isDirectory()) return;
final CrashFileManager crashFileManager = new CrashFileManager(crashSpoolDir);
// The lifecycle of a minidump in the app directory is very simple: foo.dmpNNNNN --
// where NNNNN is a Process ID (PID) -- gets created, and is either deleted or
// copied over to the shared crash directory for all WebView-using apps.
final File[] minidumpFiles = crashFileManager.getMinidumpsSansLogcat();
if (minidumpFiles.length == 0) return null;
if (minidumpFiles.length == 0) return;
// Delete the minidumps if the user doesn't allow crash data uploading.
if (!userApproved) {
......@@ -250,7 +261,7 @@ public final class AwBrowserProcess {
Log.w(TAG, "Couldn't delete file " + minidump.getAbsolutePath());
}
}
return null;
return;
}
final Intent intent = new Intent();
......@@ -277,7 +288,8 @@ public final class AwBrowserProcess {
minidumpFds[i] = null; // This is slightly ugly :)
}
if (!minidumpFiles[i].delete()) {
Log.w(TAG, "Couldn't delete file "
Log.w(TAG,
"Couldn't delete file "
+ minidumpFiles[i].getAbsolutePath());
}
}
......@@ -306,11 +318,7 @@ public final class AwBrowserProcess {
if (!appContext.bindService(intent, connection, Context.BIND_AUTO_CREATE)) {
Log.w(TAG, "Could not bind to Minidump-copying Service " + intent);
}
return null;
}
// To avoid any potential synchronization issues we post all minidump-copying actions to
// the same thread to be run serially.
}.executeOnExecutor(AsyncTask.SERIAL_EXECUTOR);
});
}
// Do not instantiate this class.
......
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