OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #ifndef COMPONENTS_CRASH_CONTENT_BROWSER_CRASH_DUMP_MANAGER_ANDROID_H_ | 5 #ifndef COMPONENTS_CRASH_CONTENT_BROWSER_CRASH_DUMP_MANAGER_ANDROID_H_ |
6 #define COMPONENTS_CRASH_CONTENT_BROWSER_CRASH_DUMP_MANAGER_ANDROID_H_ | 6 #define COMPONENTS_CRASH_CONTENT_BROWSER_CRASH_DUMP_MANAGER_ANDROID_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 | 9 |
| 10 #include "base/android/application_status_listener.h" |
10 #include "base/files/file.h" | 11 #include "base/files/file.h" |
11 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
| 13 #include "base/process/kill.h" |
12 #include "base/process/process.h" | 14 #include "base/process/process.h" |
13 #include "base/synchronization/lock.h" | 15 #include "base/synchronization/lock.h" |
14 #include "content/public/browser/browser_child_process_observer.h" | 16 #include "content/public/browser/browser_child_process_observer.h" |
15 #include "content/public/browser/notification_observer.h" | 17 #include "content/public/browser/notification_observer.h" |
16 #include "content/public/browser/notification_registrar.h" | 18 #include "content/public/browser/notification_registrar.h" |
| 19 #include "content/public/common/process_type.h" |
17 | 20 |
18 namespace content { | 21 namespace content { |
19 class RenderProcessHost; | 22 class RenderProcessHost; |
20 } | 23 } |
21 | 24 |
22 namespace breakpad { | 25 namespace breakpad { |
23 | 26 |
24 // This class manages the crash minidumps. | 27 // This class manages the crash minidumps. |
25 // On Android, because of process isolation, each renderer process runs with a | 28 // On Android, because of process isolation, each renderer process runs with a |
26 // different UID. As a result, we cannot generate the minidumps in the browser | 29 // different UID. As a result, we cannot generate the minidumps in the browser |
(...skipping 14 matching lines...) Expand all Loading... |
41 | 44 |
42 ~CrashDumpManager() override; | 45 ~CrashDumpManager() override; |
43 | 46 |
44 // Returns a file that should be used to generate a minidump for the process | 47 // Returns a file that should be used to generate a minidump for the process |
45 // |child_process_id|. | 48 // |child_process_id|. |
46 base::File CreateMinidumpFile(int child_process_id); | 49 base::File CreateMinidumpFile(int child_process_id); |
47 | 50 |
48 private: | 51 private: |
49 typedef std::map<int, base::FilePath> ChildProcessIDToMinidumpPath; | 52 typedef std::map<int, base::FilePath> ChildProcessIDToMinidumpPath; |
50 | 53 |
| 54 // This enum is used to back a UMA histogram, and must be treated as |
| 55 // append-only. |
| 56 enum ExitStatus { |
| 57 EMPTY_MINIDUMP_WHILE_RUNNING = 0, |
| 58 EMPTY_MINIDUMP_WHILE_PAUSED = 1, |
| 59 EMPTY_MINIDUMP_WHILE_BACKGROUND = 2, |
| 60 VALID_MINIDUMP_WHILE_RUNNING = 3, |
| 61 VALID_MINIDUMP_WHILE_PAUSED = 4, |
| 62 VALID_MINIDUMP_WHILE_BACKGROUND = 5, |
| 63 COUNT = 6 |
| 64 }; |
| 65 |
51 static void ProcessMinidump(const base::FilePath& minidump_path, | 66 static void ProcessMinidump(const base::FilePath& minidump_path, |
52 base::ProcessHandle pid); | 67 base::ProcessHandle pid, |
| 68 content::ProcessType process_type, |
| 69 base::TerminationStatus exit_status, |
| 70 base::android::ApplicationState app_state); |
53 | 71 |
54 // content::BrowserChildProcessObserver implementation: | 72 // content::BrowserChildProcessObserver implementation: |
55 void BrowserChildProcessHostDisconnected( | 73 void BrowserChildProcessHostDisconnected( |
56 const content::ChildProcessData& data) override; | 74 const content::ChildProcessData& data) override; |
57 void BrowserChildProcessCrashed( | 75 void BrowserChildProcessCrashed( |
58 const content::ChildProcessData& data, | 76 const content::ChildProcessData& data, |
59 int exit_code) override; | 77 int exit_code) override; |
60 | 78 |
61 // NotificationObserver implementation: | 79 // NotificationObserver implementation: |
62 void Observe(int type, | 80 void Observe(int type, |
63 const content::NotificationSource& source, | 81 const content::NotificationSource& source, |
64 const content::NotificationDetails& details) override; | 82 const content::NotificationDetails& details) override; |
65 | 83 |
66 // Called on child process exit (including crash). | 84 // Called on child process exit (including crash). |
67 void OnChildExit(int child_process_id, base::ProcessHandle pid); | 85 void OnChildExit(int child_process_id, |
| 86 base::ProcessHandle pid, |
| 87 content::ProcessType process_type, |
| 88 base::TerminationStatus exit_status, |
| 89 base::android::ApplicationState app_state); |
68 | 90 |
69 content::NotificationRegistrar notification_registrar_; | 91 content::NotificationRegistrar notification_registrar_; |
70 | 92 |
71 // This map should only be accessed with its lock aquired as it is accessed | 93 // This map should only be accessed with its lock aquired as it is accessed |
72 // from the PROCESS_LAUNCHER and UI threads. | 94 // from the PROCESS_LAUNCHER and UI threads. |
73 base::Lock child_process_id_to_minidump_path_lock_; | 95 base::Lock child_process_id_to_minidump_path_lock_; |
74 ChildProcessIDToMinidumpPath child_process_id_to_minidump_path_; | 96 ChildProcessIDToMinidumpPath child_process_id_to_minidump_path_; |
75 | 97 |
76 base::FilePath crash_dump_dir_; | 98 base::FilePath crash_dump_dir_; |
77 | 99 |
78 static CrashDumpManager* instance_; | 100 static CrashDumpManager* instance_; |
79 | 101 |
80 DISALLOW_COPY_AND_ASSIGN(CrashDumpManager); | 102 DISALLOW_COPY_AND_ASSIGN(CrashDumpManager); |
81 }; | 103 }; |
82 | 104 |
83 } // namespace breakpad | 105 } // namespace breakpad |
84 | 106 |
85 #endif // COMPONENTS_CRASH_CONTENT_BROWSER_CRASH_DUMP_MANAGER_ANDROID_H_ | 107 #endif // COMPONENTS_CRASH_CONTENT_BROWSER_CRASH_DUMP_MANAGER_ANDROID_H_ |
OLD | NEW |