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

Side by Side Diff: android_webview/java/src/org/chromium/android_webview/AwBrowserProcess.java

Issue 2862353003: [Crash Reporting] Fix a race between uploading and appending logcat data. (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 unified diff | Download patch
« no previous file with comments | « no previous file | android_webview/java/src/org/chromium/android_webview/crash/AwMinidumpUploaderDelegate.java » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.android_webview; 5 package org.chromium.android_webview;
6 6
7 import android.content.ComponentName; 7 import android.content.ComponentName;
8 import android.content.Context; 8 import android.content.Context;
9 import android.content.Intent; 9 import android.content.Intent;
10 import android.content.ServiceConnection; 10 import android.content.ServiceConnection;
(...skipping 30 matching lines...) Expand all
41 * Wrapper for the steps needed to initialize the java and native sides of webvi ew chromium. 41 * Wrapper for the steps needed to initialize the java and native sides of webvi ew chromium.
42 */ 42 */
43 public abstract class AwBrowserProcess { 43 public abstract class AwBrowserProcess {
44 public static final String PRIVATE_DATA_DIRECTORY_SUFFIX = "webview"; 44 public static final String PRIVATE_DATA_DIRECTORY_SUFFIX = "webview";
45 45
46 private static final String TAG = "AwBrowserProcess"; 46 private static final String TAG = "AwBrowserProcess";
47 private static final String EXCLUSIVE_LOCK_FILE = "webview_data.lock"; 47 private static final String EXCLUSIVE_LOCK_FILE = "webview_data.lock";
48 private static RandomAccessFile sLockFile; 48 private static RandomAccessFile sLockFile;
49 private static FileLock sExclusiveFileLock; 49 private static FileLock sExclusiveFileLock;
50 50
51 private static final int MAX_MINIDUMP_UPLOAD_TRIES = 3;
52
53 /** 51 /**
54 * Loads the native library, and performs basic static construction of objec ts needed 52 * Loads the native library, and performs basic static construction of objec ts needed
55 * to run webview in this process. Does not create threads; safe to call fro m zygote. 53 * to run webview in this process. Does not create threads; safe to call fro m zygote.
56 * Note: it is up to the caller to ensure this is only called once. 54 * Note: it is up to the caller to ensure this is only called once.
57 */ 55 */
58 public static void loadLibrary() { 56 public static void loadLibrary() {
59 PathUtils.setPrivateDataDirectorySuffix(PRIVATE_DATA_DIRECTORY_SUFFIX); 57 PathUtils.setPrivateDataDirectorySuffix(PRIVATE_DATA_DIRECTORY_SUFFIX);
60 try { 58 try {
61 LibraryLoader libraryLoader = LibraryLoader.get(LibraryProcessType.P ROCESS_WEBVIEW); 59 LibraryLoader libraryLoader = LibraryLoader.get(LibraryProcessType.P ROCESS_WEBVIEW);
62 libraryLoader.loadNow(); 60 libraryLoader.loadNow();
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 */ 156 */
159 public static void handleMinidumps( 157 public static void handleMinidumps(
160 final String webViewPackageName, final boolean userApproved) { 158 final String webViewPackageName, final boolean userApproved) {
161 new AsyncTask<Void, Void, Void>() { 159 new AsyncTask<Void, Void, Void>() {
162 @Override 160 @Override
163 protected Void doInBackground(Void... params) { 161 protected Void doInBackground(Void... params) {
164 final Context appContext = ContextUtils.getApplicationContext(); 162 final Context appContext = ContextUtils.getApplicationContext();
165 final File crashSpoolDir = new File(appContext.getCacheDir().get Path(), "WebView"); 163 final File crashSpoolDir = new File(appContext.getCacheDir().get Path(), "WebView");
166 if (!crashSpoolDir.isDirectory()) return null; 164 if (!crashSpoolDir.isDirectory()) return null;
167 final CrashFileManager crashFileManager = new CrashFileManager(c rashSpoolDir); 165 final CrashFileManager crashFileManager = new CrashFileManager(c rashSpoolDir);
168 final File[] minidumpFiles = 166
169 crashFileManager.getAllMinidumpFiles(MAX_MINIDUMP_UPLOAD _TRIES); 167 // The lifecycle of a minidump in the app directory is very simp le: foo.dmpNNNNN --
168 // where NNNNN is a Process ID (PID) -- gets created, and is eit her deleted or
169 // copied over to the shared crash directory for all WebView-usi ng apps.
170 final File[] minidumpFiles = crashFileManager.getMinidumpsSansLo gcat();
170 if (minidumpFiles.length == 0) return null; 171 if (minidumpFiles.length == 0) return null;
171 172
172 // Delete the minidumps if the user doesn't allow crash data upl oading. 173 // Delete the minidumps if the user doesn't allow crash data upl oading.
173 if (!userApproved) { 174 if (!userApproved) {
174 for (File minidump : minidumpFiles) { 175 for (File minidump : minidumpFiles) {
175 if (!minidump.delete()) { 176 if (!minidump.delete()) {
176 Log.w(TAG, "Couldn't delete file " + minidump.getAbs olutePath()); 177 Log.w(TAG, "Couldn't delete file " + minidump.getAbs olutePath());
177 } 178 }
178 } 179 }
179 return null; 180 return null;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 public void onServiceDisconnected(ComponentName className) { } 231 public void onServiceDisconnected(ComponentName className) { }
231 }; 232 };
232 if (!appContext.bindService(intent, connection, Context.BIND_AUT O_CREATE)) { 233 if (!appContext.bindService(intent, connection, Context.BIND_AUT O_CREATE)) {
233 Log.w(TAG, "Could not bind to Minidump-copying Service " + i ntent); 234 Log.w(TAG, "Could not bind to Minidump-copying Service " + i ntent);
234 } 235 }
235 return null; 236 return null;
236 } 237 }
237 }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); 238 }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
238 } 239 }
239 } 240 }
OLDNEW
« no previous file with comments | « no previous file | android_webview/java/src/org/chromium/android_webview/crash/AwMinidumpUploaderDelegate.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698