OLD | NEW |
---|---|
(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 } | |
OLD | NEW |