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

Unified Diff: android_webview/java/src/org/chromium/android_webview/AwBrowserProcess.java

Issue 2833893002: [Android WebView] Trigger minidump uploading on renderer crash. (Closed)
Patch Set: Rebase Created 3 years, 7 months 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
« no previous file with comments | « android_webview/glue/java/src/com/android/webview/chromium/WebViewChromiumFactoryProvider.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: android_webview/java/src/org/chromium/android_webview/AwBrowserProcess.java
diff --git a/android_webview/java/src/org/chromium/android_webview/AwBrowserProcess.java b/android_webview/java/src/org/chromium/android_webview/AwBrowserProcess.java
index 64b7c6fc210b41fafd6bb68e92d2d23e182bbe30..756f10225f1505254de9d4be00de4863a93545ee 100644
--- a/android_webview/java/src/org/chromium/android_webview/AwBrowserProcess.java
+++ b/android_webview/java/src/org/chromium/android_webview/AwBrowserProcess.java
@@ -13,7 +13,9 @@ import android.os.IBinder;
import android.os.ParcelFileDescriptor;
import android.os.RemoteException;
import android.os.StrictMode;
+import android.webkit.ValueCallback;
+import org.chromium.android_webview.command_line.CommandLineUtil;
import org.chromium.android_webview.crash.CrashReceiverService;
import org.chromium.android_webview.crash.ICrashReceiverService;
import org.chromium.android_webview.policy.AwPolicyProvider;
@@ -22,6 +24,8 @@ import org.chromium.base.ContextUtils;
import org.chromium.base.Log;
import org.chromium.base.PathUtils;
import org.chromium.base.ThreadUtils;
+import org.chromium.base.annotations.CalledByNative;
+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;
@@ -40,6 +44,7 @@ import java.nio.channels.FileLock;
/**
* Wrapper for the steps needed to initialize the java and native sides of webview chromium.
*/
+@JNINamespace("android_webview")
public abstract class AwBrowserProcess {
public static final String PRIVATE_DATA_DIRECTORY_SUFFIX = "webview";
@@ -47,6 +52,7 @@ public abstract class AwBrowserProcess {
private static final String EXCLUSIVE_LOCK_FILE = "webview_data.lock";
private static RandomAccessFile sLockFile;
private static FileLock sExclusiveFileLock;
+ private static String sWebViewPackageName;
private static final int MAX_MINIDUMP_UPLOAD_TRIES = 3;
@@ -149,6 +155,49 @@ public abstract class AwBrowserProcess {
}
}
+ public static void setWebViewPackageName(String webViewPackageName) {
+ assert sWebViewPackageName == null || sWebViewPackageName.equals(webViewPackageName);
+ sWebViewPackageName = webViewPackageName;
+ }
+
+ /**
+ * Trigger minidump copying, which in turn triggers minidump uploading.
+ */
+ @CalledByNative
+ private static void triggerMinidumpUploading() {
+ handleMinidumpsAndSetMetricsConsent(sWebViewPackageName, false /* updateMetricsConsent */);
+ }
+
+ /**
+ * Trigger minidump uploading, and optionaly also update the metrics-consent value depending on
+ * whether the Android Checkbox is toggled on.
+ * @param updateMetricsConsent whether to update the metrics-consent value to represent the
+ * Android Checkbox toggle.
+ */
+ public static void handleMinidumpsAndSetMetricsConsent(
+ final String webViewPackageName, final boolean updateMetricsConsent) {
+ final boolean enableMinidumpUploadingForTesting = CommandLine.getInstance().hasSwitch(
+ CommandLineUtil.CRASH_UPLOADS_ENABLED_FOR_TESTING_SWITCH);
+ if (enableMinidumpUploadingForTesting) {
+ AwBrowserProcess.handleMinidumps(webViewPackageName, true /* enabled */);
+ }
+
+ PlatformServiceBridge.getInstance().queryMetricsSetting(new ValueCallback<Boolean>() {
+ // Actions conditioned on whether the Android Checkbox is toggled on
+ public void onReceiveValue(Boolean enabled) {
+ ThreadUtils.assertOnUiThread();
+ if (updateMetricsConsent) {
+ AwMetricsServiceClient.setConsentSetting(
+ ContextUtils.getApplicationContext(), enabled);
+ }
+
+ if (!enableMinidumpUploadingForTesting) {
+ AwBrowserProcess.handleMinidumps(webViewPackageName, enabled);
+ }
+ }
+ });
+ }
+
/**
* Pass Minidumps to a separate Service declared in the WebView provider package.
* That Service will copy the Minidumps to its own data directory - at which point we can delete
@@ -234,6 +283,9 @@ public abstract class AwBrowserProcess {
}
return null;
}
- }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ // To avoid any potential synchronization issues we post all minidump-copying actions to
+ // the same thread to be run serially.
+ }
+ .executeOnExecutor(AsyncTask.SERIAL_EXECUTOR);
}
}
« no previous file with comments | « android_webview/glue/java/src/com/android/webview/chromium/WebViewChromiumFactoryProvider.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698