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

Unified Diff: android_webview/java/src/org/chromium/android_webview/crash/SynchronizedWebViewCommandLine.java

Issue 2515353005: [Android WebView] Implement copying and uploading of Minidumps. (Closed)
Patch Set: Fix findbugs errors for realz! Created 4 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: android_webview/java/src/org/chromium/android_webview/crash/SynchronizedWebViewCommandLine.java
diff --git a/android_webview/java/src/org/chromium/android_webview/crash/SynchronizedWebViewCommandLine.java b/android_webview/java/src/org/chromium/android_webview/crash/SynchronizedWebViewCommandLine.java
new file mode 100644
index 0000000000000000000000000000000000000000..27331a89ab9eb92b3ea300b7a7a6f0d829377db8
--- /dev/null
+++ b/android_webview/java/src/org/chromium/android_webview/crash/SynchronizedWebViewCommandLine.java
@@ -0,0 +1,59 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.android_webview.crash;
+
+import org.chromium.base.CommandLine;
+import org.chromium.base.annotations.SuppressFBWarnings;
+
+/**
+ * Class for fetching command line switches for WebView in a thread-safe way.
+ */
+class SynchronizedWebViewCommandLine {
+ private static final Object sLock = new Object();
+ private static InitState sInitialized = InitState.NOT_STARTED;
+ // TODO(gsennton): this value is used in WebViewChromiumFactoryProvider as well - set it
+ // somewhere where it can be read from both classes.
+ private static final String WEBVIEW_COMMAND_LINE_FILE = "/data/local/tmp/webview-command-line";
+
+ private enum InitState { NOT_STARTED, STARTED, DONE }
+
+ /**
+ * Initialize the global CommandLine using the WebView command line file.
+ * This method includes IO operations - it shouldn't be performed on the main thread.
+ */
+ public static void initOnSeparateThread() {
+ synchronized (sLock) {
+ if (sInitialized != InitState.NOT_STARTED) return;
+ sInitialized = InitState.STARTED;
+ }
+ new Thread(new Runnable() {
+ @SuppressFBWarnings("DMI_HARDCODED_ABSOLUTE_FILENAME")
+ @Override
+ public void run() {
+ CommandLine.initFromFile(WEBVIEW_COMMAND_LINE_FILE);
+ synchronized (sLock) {
+ sInitialized = InitState.DONE;
+ sLock.notifyAll();
+ }
+ }
+ }, "WebView-command-line-init-thread").start();
+ }
+
+ /**
+ * Returns true if this command line contains the given switch.
+ */
+ public static boolean hasSwitch(String switchString) {
+ synchronized (sLock) {
+ while (sInitialized != InitState.DONE) {
+ try {
+ sLock.wait();
+ } catch (InterruptedException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ return CommandLine.getInstance().hasSwitch(switchString);
+ }
+ }
+}
« no previous file with comments | « android_webview/java/src/org/chromium/android_webview/crash/MinidumpUploaderImpl.java ('k') | android_webview/javatests/DEPS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698