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