| 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/browser_child_process_observer.h" | 
|  | 14 #include "content/public/browser/notification_observer.h" | 
|  | 15 #include "content/public/browser/notification_registrar.h" | 
|  | 16 | 
|  | 17 namespace breakpad { | 
|  | 18 | 
|  | 19 // This class manages behavior of the browser on renderer crashes when | 
|  | 20 // microdumps are used for capturing the crash stack.  Normally, in this case | 
|  | 21 // the browser doesn't need to do much, because a microdump is written into | 
|  | 22 // Android log by the renderer process itself.  However, the browser may need to | 
|  | 23 // crash itself on a renderer crash.  Since on Android renderers are not child | 
|  | 24 // processes of the browser, it can't access the exit code. Instead, the browser | 
|  | 25 // uses a dedicated pipe in order to receive the information about the renderer | 
|  | 26 // crash status. | 
|  | 27 class CrashMicroDumpManager : public content::BrowserChildProcessObserver, | 
|  | 28                               public content::NotificationObserver { | 
|  | 29  public: | 
|  | 30   // The embedder should create a single instance of the CrashMicroDumpManager. | 
|  | 31   static CrashMicroDumpManager* GetInstance(); | 
|  | 32 | 
|  | 33   // Should be created on the UI thread. | 
|  | 34   CrashMicroDumpManager(); | 
|  | 35 | 
|  | 36   ~CrashMicroDumpManager() override; | 
|  | 37 | 
|  | 38   // Returns a pipe that should be used to transfer termination cause of | 
|  | 39   // |child_process_id|. | 
|  | 40   base::File CreateCrashInfoChannel(int child_process_id); | 
|  | 41 | 
|  | 42  private: | 
|  | 43   static void HandleChildTermination( | 
|  | 44       int pipe_fd, | 
|  | 45       base::TerminationStatus termination_status); | 
|  | 46 | 
|  | 47   // content::BrowserChildProcessObserver implementation: | 
|  | 48   void BrowserChildProcessHostDisconnected( | 
|  | 49       const content::ChildProcessData& data) override; | 
|  | 50   void BrowserChildProcessCrashed( | 
|  | 51       const content::ChildProcessData& data, | 
|  | 52       int exit_code) override; | 
|  | 53 | 
|  | 54   // NotificationObserver implementation: | 
|  | 55   void Observe(int type, | 
|  | 56                const content::NotificationSource& source, | 
|  | 57                const content::NotificationDetails& details) override; | 
|  | 58 | 
|  | 59   // Called on child process exit (including crash). | 
|  | 60   void OnChildExit(int child_process_id, | 
|  | 61                    base::TerminationStatus termination_status); | 
|  | 62 | 
|  | 63   content::NotificationRegistrar notification_registrar_; | 
|  | 64 | 
|  | 65   // This map should only be accessed with its lock aquired as it is accessed | 
|  | 66   // from the PROCESS_LAUNCHER and UI threads. | 
|  | 67   base::Lock child_process_id_to_pipe_fd_lock_; | 
|  | 68   std::map<int, int> child_process_id_to_pipe_fd_; | 
|  | 69 | 
|  | 70   static CrashMicroDumpManager* instance_; | 
|  | 71 | 
|  | 72   DISALLOW_COPY_AND_ASSIGN(CrashMicroDumpManager); | 
|  | 73 }; | 
|  | 74 | 
|  | 75 }  // namespace breakpad | 
|  | 76 | 
|  | 77 #endif  // COMPONENTS_CRASH_CONTENT_BROWSER_CRASH_MICRO_DUMP_MANAGER_ANDROID_H_ | 
| OLD | NEW | 
|---|