summaryrefslogtreecommitdiffstats
path: root/android_webview/java/src/org
diff options
context:
space:
mode:
authormnaganov <mnaganov@chromium.org>2016-03-11 13:30:29 -0800
committerCommit bot <commit-bot@chromium.org>2016-03-11 21:32:34 +0000
commitc092dc59169fea93f5347722cacf6d5834e332f3 (patch)
tree4de9128368f70ab1ded47076c146f8dcee4cdbb9 /android_webview/java/src/org
parentd4da63d8b5c49d7fa7a2ec9821400350a0670059 (diff)
downloadchromium_src-c092dc59169fea93f5347722cacf6d5834e332f3.zip
chromium_src-c092dc59169fea93f5347722cacf6d5834e332f3.tar.gz
chromium_src-c092dc59169fea93f5347722cacf6d5834e332f3.tar.bz2
[Android WebView] Enable disk access in data dir locking code
Dir locking code needs to run synchronously before starting the browser process, as if we figure out that the dir is already in use we need to avoid starting the browser, as it will mess up the data. Thus the only way to alleviate strict mode violation is to enable disk access. BUG=558377,593353 Review URL: https://codereview.chromium.org/1781653004 Cr-Commit-Position: refs/heads/master@{#380738}
Diffstat (limited to 'android_webview/java/src/org')
-rw-r--r--android_webview/java/src/org/chromium/android_webview/AwBrowserProcess.java33
1 files changed, 20 insertions, 13 deletions
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 94be4df..fd8040b 100644
--- a/android_webview/java/src/org/chromium/android_webview/AwBrowserProcess.java
+++ b/android_webview/java/src/org/chromium/android_webview/AwBrowserProcess.java
@@ -5,6 +5,7 @@
package org.chromium.android_webview;
import android.content.Context;
+import android.os.StrictMode;
import org.chromium.android_webview.policy.AwPolicyProvider;
import org.chromium.base.CommandLine;
@@ -93,20 +94,26 @@ public abstract class AwBrowserProcess {
}
private static void tryObtainingDataDirLockOrDie(Context context) {
- String dataPath = PathUtils.getDataDirectory(context);
- File lockFile = new File(dataPath, EXCLUSIVE_LOCK_FILE);
- boolean success = false;
+ StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads();
+ StrictMode.allowThreadDiskWrites();
try {
- // Note that the file is not closed intentionally.
- RandomAccessFile file = new RandomAccessFile(lockFile, "rw");
- sExclusiveFileLock = file.getChannel().tryLock();
- success = sExclusiveFileLock != null;
- } catch (IOException e) {
- Log.w(TAG, "Failed to create lock file " + lockFile, e);
- }
- if (!success) {
- Log.w(TAG, "The app may have another WebView opened in a separate process. "
- + "This is not recommended and may stop working in future versions.");
+ String dataPath = PathUtils.getDataDirectory(context);
+ File lockFile = new File(dataPath, EXCLUSIVE_LOCK_FILE);
+ boolean success = false;
+ try {
+ // Note that the file is not closed intentionally.
+ RandomAccessFile file = new RandomAccessFile(lockFile, "rw");
+ sExclusiveFileLock = file.getChannel().tryLock();
+ success = sExclusiveFileLock != null;
+ } catch (IOException e) {
+ Log.w(TAG, "Failed to create lock file " + lockFile, e);
+ }
+ if (!success) {
+ Log.w(TAG, "The app may have another WebView opened in a separate process. "
+ + "This is not recommended and may stop working in future versions.");
+ }
+ } finally {
+ StrictMode.setThreadPolicy(oldPolicy);
}
}
}