| 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_CRASH_HANDLER_HOST_LINUX_H_ | |
| 6 #define CHROME_BROWSER_CRASH_HANDLER_HOST_LINUX_H_ | |
| 7 | |
| 8 #include <sys/types.h> | |
| 9 | |
| 10 #include <string> | |
| 11 | |
| 12 #include "base/compiler_specific.h" | |
| 13 #include "base/files/file_path.h" | |
| 14 #include "base/memory/scoped_ptr.h" | |
| 15 #include "base/message_loop/message_loop.h" | |
| 16 #include "base/threading/sequenced_worker_pool.h" | |
| 17 | |
| 18 struct BreakpadInfo; | |
| 19 | |
| 20 namespace base { | |
| 21 class Thread; | |
| 22 } | |
| 23 | |
| 24 // This is the host for processes which run breakpad inside the sandbox on | |
| 25 // Linux or Android. We perform the crash dump from the browser because it | |
| 26 // allows us to be outside the sandbox. | |
| 27 // | |
| 28 // Processes signal that they need to be dumped by sending a datagram over a | |
| 29 // UNIX domain socket. All processes of the same type share the client end of | |
| 30 // this socket which is installed in their descriptor table before exec. | |
| 31 class CrashHandlerHostLinux : public base::MessageLoopForIO::Watcher, | |
| 32 public base::MessageLoop::DestructionObserver { | |
| 33 public: | |
| 34 CrashHandlerHostLinux(const std::string& process_type, | |
| 35 const base::FilePath& dumps_path, | |
| 36 bool upload); | |
| 37 virtual ~CrashHandlerHostLinux(); | |
| 38 | |
| 39 // Starts the uploader thread. Must be called immediately after creating the | |
| 40 // class. | |
| 41 void StartUploaderThread(); | |
| 42 | |
| 43 // Get the file descriptor which processes should be given in order to signal | |
| 44 // crashes to the browser. | |
| 45 int GetDeathSignalSocket() const { | |
| 46 return process_socket_; | |
| 47 } | |
| 48 | |
| 49 // MessagePumbLibevent::Watcher impl: | |
| 50 virtual void OnFileCanWriteWithoutBlocking(int fd) OVERRIDE; | |
| 51 virtual void OnFileCanReadWithoutBlocking(int fd) OVERRIDE; | |
| 52 | |
| 53 // MessageLoop::DestructionObserver impl: | |
| 54 virtual void WillDestroyCurrentMessageLoop() OVERRIDE; | |
| 55 | |
| 56 // Whether we are shutting down or not. | |
| 57 bool IsShuttingDown() const; | |
| 58 | |
| 59 private: | |
| 60 void Init(); | |
| 61 | |
| 62 // Do work on the FILE thread for OnFileCanReadWithoutBlocking(). | |
| 63 void WriteDumpFile(BreakpadInfo* info, | |
| 64 pid_t crashing_pid, | |
| 65 char* crash_context, | |
| 66 int signal_fd); | |
| 67 | |
| 68 // Continue OnFileCanReadWithoutBlocking()'s work on the IO thread. | |
| 69 void QueueCrashDumpTask(BreakpadInfo* info, int signal_fd); | |
| 70 | |
| 71 std::string process_type_; | |
| 72 base::FilePath dumps_path_; | |
| 73 bool upload_; | |
| 74 | |
| 75 int process_socket_; | |
| 76 int browser_socket_; | |
| 77 | |
| 78 base::MessageLoopForIO::FileDescriptorWatcher file_descriptor_watcher_; | |
| 79 scoped_ptr<base::Thread> uploader_thread_; | |
| 80 bool shutting_down_; | |
| 81 | |
| 82 // Unique sequence token so that writing crash dump won't be blocked | |
| 83 // by other tasks. | |
| 84 base::SequencedWorkerPool::SequenceToken worker_pool_token_; | |
| 85 | |
| 86 #if defined(ADDRESS_SANITIZER) | |
| 87 char* asan_report_str_; | |
| 88 #endif | |
| 89 | |
| 90 DISALLOW_COPY_AND_ASSIGN(CrashHandlerHostLinux); | |
| 91 }; | |
| 92 | |
| 93 #endif // CHROME_BROWSER_CRASH_HANDLER_HOST_LINUX_H_ | |
| OLD | NEW |