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