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

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/crash/MinidumpDirectoryObserver.java

Issue 1579723002: Add a file observer to monitor if there is a crash (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: call "start watching" static method instead of calling the startWatching method from an instance Created 4 years, 10 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
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 package org.chromium.chrome.browser.crash;
6
7 import android.content.Context;
8 import android.content.Intent;
9 import android.os.FileObserver;
10
11 import org.chromium.base.ApplicationStatus;
12 import org.chromium.base.Log;
13 import org.chromium.base.ThreadUtils;
14 import org.chromium.base.metrics.RecordUserAction;
15
16 import java.io.File;
17
18 /**
19 * This class is a singleton that holds utilities for observer to monitor the mi nidump directory.
20 */
21 public final class MinidumpDirectoryObserver extends FileObserver {
22
23 private static final String TAG = "MinidumpDirObserver";
24
25 private static MinidumpDirectoryObserver sMinidumpDirectoryObserver;
26 private static Context sContext = ApplicationStatus.getApplicationContext();
27
28 public static final String MINIDUMP_EXPERIMENT_NAME = "AddMinidumpDirObserve r";
29
30 public static void startObserverWatching() {
31 ThreadUtils.assertOnUiThread();
32 if (sMinidumpDirectoryObserver == null) {
33 sMinidumpDirectoryObserver = new MinidumpDirectoryObserver();
34 }
35 sMinidumpDirectoryObserver.startWatching();
36 }
37
38 private MinidumpDirectoryObserver() {
39 // The file observer detects MOVED_TO for renderer crash and GPU crash;
no sievers 2016/01/29 23:52:34 nit: I'd just say 'child processes'. There's also
Menglin 2016/01/30 00:29:11 Done.
40 // it detects CREATE for browser crash
41 super(new File(sContext.getCacheDir(), CrashFileManager.CRASH_DUMP_DIR). toString(),
42 FileObserver.MOVED_TO);
43 }
44
45 /**
46 * When a miniudump is detected, upload it to Google crash server
47 */
48 @Override
49 public void onEvent(int event, String path) {
no sievers 2016/01/29 23:52:34 nit: Can you put a comment that this is happening
Menglin 2016/01/30 00:29:11 Done.
50 if (CrashFileManager.isMinidumpMIMEFirstTry(path)) {
51 Intent intent = MinidumpUploadService.createFindAndUploadLastCrashIn tent(sContext);
52 sContext.startService(intent);
53 Log.i(TAG, "Detects a new minidump %s sending intent to MinidumpUplo adService", path);
54 RecordUserAction.record("MobileBreakpadUploadAttempt");
no sievers 2016/01/29 23:52:34 This stat is still a bit broken, since the name su
Menglin 2016/01/30 00:29:12 I will leave it as it is for now and fix that in a
55 }
56 }
57 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698