Chromium Code Reviews| 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..02a279516dffdb35d74832b1204c5d9705cdae1a 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) { |
|
gsennton
2017/04/20 20:32:46
Having this is a bit ugly... but we fetch the WebV
paulmiller
2017/04/20 23:38:51
I was going to do something like this anyway. The
gsennton
2017/04/21 15:46:33
Haha, damn ;)
|
| + 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 */); |
|
Tobias Sargeant
2017/04/21 16:18:04
I think now we could get into a situation where we
gsennton
2017/04/24 08:27:16
Right, that might be undesirable ;)
I think any al
gsennton
2017/04/24 12:39:54
As Toby pointed out offline, if we just post these
|
| + } |
| + |
| + /** |
| + * 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 |
|
paulmiller
2017/04/20 23:38:51
This flag feels hacky. Why not have 2 queryMetrics
gsennton
2017/04/21 15:46:33
We could do that, I just don't like duplicating th
paulmiller
2017/04/21 17:50:01
I don't think that calling queryMetricsSetting twi
gsennton
2017/04/24 08:27:16
I'm more concerned about the whole enableMinidumpU
|
| + * 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 |