Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2015 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 COMPONENTS_CRASH_CONTENT_BROWSER_CRASH_MICRO_DUMP_MANAGER_ANDROID_H_ | |
| 6 #define COMPONENTS_CRASH_CONTENT_BROWSER_CRASH_MICRO_DUMP_MANAGER_ANDROID_H_ | |
| 7 | |
| 8 #include <map> | |
| 9 | |
| 10 #include "base/files/file.h" | |
| 11 #include "base/process/kill.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 breakpad { | |
| 17 | |
| 18 // This class manages behavior of the browser on renderer crashes when | |
| 19 // microdumps are used for capturing the crash stack. Normally, in this case | |
| 20 // the browser doesn't need to do much, because a microdump is written into | |
| 21 // Android log by the renderer process itself. However, the browser may need to | |
| 22 // crash itself on a renderer crash. Since on Android renderers are not child | |
| 23 // processes of the browser, it can't access the exit code. Instead, the browser | |
| 24 // uses a dedicated pipe in order to receive the information about the renderer | |
| 25 // crash status. | |
| 26 class CrashMicroDumpManager : public content::NotificationObserver { | |
|
Yaron
2016/01/04 22:03:56
should this be in aw/? It only uses content/public
mnaganov (inactive)
2016/01/05 00:06:08
Microdumps are implemented in components/crash, an
| |
| 27 public: | |
| 28 // The embedder should create a single instance of the CrashMicroDumpManager. | |
| 29 static CrashMicroDumpManager* GetInstance(); | |
| 30 | |
| 31 // Should be created on the UI thread. | |
| 32 CrashMicroDumpManager(); | |
| 33 | |
| 34 ~CrashMicroDumpManager() override; | |
| 35 | |
| 36 // Returns a pipe that should be used to transfer termination cause of | |
| 37 // |child_process_id|. | |
| 38 base::File CreateCrashInfoChannel(int child_process_id); | |
| 39 | |
| 40 private: | |
| 41 static void HandleChildTermination( | |
| 42 int pipe_fd, | |
| 43 base::TerminationStatus termination_status); | |
| 44 | |
| 45 // NotificationObserver implementation: | |
| 46 void Observe(int type, | |
| 47 const content::NotificationSource& source, | |
| 48 const content::NotificationDetails& details) override; | |
| 49 | |
| 50 // Called on child process exit (including crash). | |
| 51 void OnChildExit(int child_process_id, | |
| 52 base::TerminationStatus termination_status); | |
| 53 | |
| 54 content::NotificationRegistrar notification_registrar_; | |
| 55 | |
| 56 // This map should only be accessed with its lock aquired as it is accessed | |
| 57 // from the PROCESS_LAUNCHER and UI threads. | |
| 58 base::Lock child_process_id_to_pipe_fd_lock_; | |
| 59 std::map<int, int> child_process_id_to_pipe_fd_; | |
| 60 | |
| 61 static CrashMicroDumpManager* instance_; | |
| 62 | |
| 63 DISALLOW_COPY_AND_ASSIGN(CrashMicroDumpManager); | |
| 64 }; | |
| 65 | |
| 66 } // namespace breakpad | |
| 67 | |
| 68 #endif // COMPONENTS_CRASH_CONTENT_BROWSER_CRASH_MICRO_DUMP_MANAGER_ANDROID_H_ | |
| OLD | NEW |