OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2012 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 #ifndef CHROME_BROWSER_ANDROID_CRASH_DUMP_MANAGER_H_ |
| 6 #define CHROME_BROWSER_ANDROID_CRASH_DUMP_MANAGER_H_ |
| 7 |
| 8 #include <map> |
| 9 |
| 10 #include "base/file_path.h" |
| 11 #include "base/platform_file.h" |
| 12 #include "base/synchronization/lock.h" |
| 13 #include "content/public/browser/notification_observer.h" |
| 14 #include "content/public/browser/notification_registrar.h" |
| 15 |
| 16 namespace content { |
| 17 class RenderProcessHost; |
| 18 } |
| 19 |
| 20 // This class manages the crash minidumps. |
| 21 // On Android, because of process isolation, each renderer process runs with a |
| 22 // different UID. As a result, we cannot generate the minidumps in the browser |
| 23 // (as the browser process does not have access to some system files for the |
| 24 // crashed process). So the minidump is generated in the renderer process. |
| 25 // Since the isolated process cannot open files, we provide it on creation with |
| 26 // a file descriptor where to write the minidump in the event of a crash. |
| 27 // This class creates these file descriptors and associates them with render |
| 28 // processes and take the appropriate action when the render process terminates. |
| 29 class CrashDumpManager : public content::NotificationObserver { |
| 30 public: |
| 31 // Should be created on the UI thread. |
| 32 CrashDumpManager(); |
| 33 virtual ~CrashDumpManager(); |
| 34 |
| 35 // Returns a file descriptor that should be used to generate a minidump for |
| 36 // the process |child_process_id|. |
| 37 int CreateMinidumpFile(int child_process_id); |
| 38 |
| 39 private: |
| 40 struct MinidumpInfo { |
| 41 MinidumpInfo() : file(base::kInvalidPlatformFileValue) {} |
| 42 base::PlatformFile file; |
| 43 FilePath path; |
| 44 int pid; |
| 45 }; |
| 46 |
| 47 typedef std::map<int, MinidumpInfo> ChildProcessIDToMinidumpInfo; |
| 48 |
| 49 static void ProcessMinidump(const MinidumpInfo& minidump); |
| 50 |
| 51 // NotificationObserver implementation: |
| 52 virtual void Observe(int type, |
| 53 const content::NotificationSource& source, |
| 54 const content::NotificationDetails& details) OVERRIDE; |
| 55 |
| 56 content::NotificationRegistrar notification_registrar_; |
| 57 |
| 58 // This map should only be accessed with its lock aquired as it is accessed |
| 59 // from the PROCESS_LAUNCHER and UI threads. |
| 60 base::Lock child_process_id_to_minidump_info_lock_; |
| 61 ChildProcessIDToMinidumpInfo child_process_id_to_minidump_info_; |
| 62 |
| 63 DISALLOW_COPY_AND_ASSIGN(CrashDumpManager); |
| 64 }; |
| 65 |
| 66 #endif // CHROME_BROWSER_ANDROID_CRASH_DUMP_MANAGER_H_ |
OLD | NEW |