Index: chrome/browser/crash_handler_host_posix.cc |
diff --git a/chrome/browser/crash_handler_host_linux.cc b/chrome/browser/crash_handler_host_posix.cc |
similarity index 83% |
rename from chrome/browser/crash_handler_host_linux.cc |
rename to chrome/browser/crash_handler_host_posix.cc |
index 2d1ac2f21fcbad3a656cdb8f45c3187bc44d5f2c..0fe91114ef389f9ecc933d633fff0388ac612a58 100644 |
--- a/chrome/browser/crash_handler_host_linux.cc |
+++ b/chrome/browser/crash_handler_host_posix.cc |
@@ -2,7 +2,7 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#include "chrome/browser/crash_handler_host_linux.h" |
+#include "chrome/browser/crash_handler_host_posix.h" |
#include <stdint.h> |
#include <stdlib.h> |
@@ -27,11 +27,17 @@ |
#include "breakpad/src/client/linux/handler/exception_handler.h" |
#include "breakpad/src/client/linux/minidump_writer/linux_dumper.h" |
#include "breakpad/src/client/linux/minidump_writer/minidump_writer.h" |
-#include "chrome/app/breakpad_linux.h" |
+#include "chrome/app/breakpad_posix.h" |
#include "chrome/common/chrome_paths.h" |
#include "chrome/common/env_vars.h" |
#include "content/public/browser/browser_thread.h" |
+#if defined(OS_ANDROID) |
+#include <sys/linux-syscalls.h> |
+ |
+#define SYS_read __NR_read |
+#endif |
+ |
using content::BrowserThread; |
using google_breakpad::ExceptionHandler; |
@@ -44,7 +50,7 @@ const unsigned kControlMsgSize = |
const unsigned kCrashContextSize = sizeof(ExceptionHandler::CrashContext); |
// Handles the crash dump and frees the allocated BreakpadInfo struct. |
-void CrashDumpTask(CrashHandlerHostLinux* handler, BreakpadInfo* info) { |
+void CrashDumpTask(CrashHandlerHostPosix* handler, BreakpadInfo* info) { |
if (handler->IsShuttingDown()) |
return; |
@@ -59,12 +65,12 @@ void CrashDumpTask(CrashHandlerHostLinux* handler, BreakpadInfo* info) { |
} // namespace |
-// Since classes derived from CrashHandlerHostLinux are singletons, it's only |
+// Since classes derived from CrashHandlerHostPosix are singletons, it's only |
// destroyed at the end of the processes lifetime, which is greater in span than |
// the lifetime of the IO message loop. Thus, all calls to base::Bind() use |
// non-refcounted pointers. |
-CrashHandlerHostLinux::CrashHandlerHostLinux() |
+CrashHandlerHostPosix::CrashHandlerHostPosix() |
: shutting_down_(false) { |
int fds[2]; |
// We use SOCK_SEQPACKET rather than SOCK_DGRAM to prevent the process from |
@@ -84,15 +90,15 @@ CrashHandlerHostLinux::CrashHandlerHostLinux() |
BrowserThread::PostTask( |
BrowserThread::IO, FROM_HERE, |
- base::Bind(&CrashHandlerHostLinux::Init, base::Unretained(this))); |
+ base::Bind(&CrashHandlerHostPosix::Init, base::Unretained(this))); |
} |
-CrashHandlerHostLinux::~CrashHandlerHostLinux() { |
+CrashHandlerHostPosix::~CrashHandlerHostPosix() { |
HANDLE_EINTR(close(process_socket_)); |
HANDLE_EINTR(close(browser_socket_)); |
} |
-void CrashHandlerHostLinux::Init() { |
+void CrashHandlerHostPosix::Init() { |
MessageLoopForIO* ml = MessageLoopForIO::current(); |
CHECK(ml->WatchFileDescriptor( |
browser_socket_, true /* persistent */, |
@@ -101,18 +107,18 @@ void CrashHandlerHostLinux::Init() { |
ml->AddDestructionObserver(this); |
} |
-void CrashHandlerHostLinux::InitCrashUploaderThread() { |
+void CrashHandlerHostPosix::InitCrashUploaderThread() { |
SetProcessType(); |
uploader_thread_.reset( |
new base::Thread(std::string(process_type_ + "_crash_uploader").c_str())); |
uploader_thread_->Start(); |
} |
-void CrashHandlerHostLinux::OnFileCanWriteWithoutBlocking(int fd) { |
+void CrashHandlerHostPosix::OnFileCanWriteWithoutBlocking(int fd) { |
DCHECK(false); |
} |
-void CrashHandlerHostLinux::OnFileCanReadWithoutBlocking(int fd) { |
+void CrashHandlerHostPosix::OnFileCanReadWithoutBlocking(int fd) { |
DCHECK_EQ(fd, browser_socket_); |
// A process has crashed and has signaled us by writing a datagram |
@@ -312,13 +318,17 @@ void CrashHandlerHostLinux::OnFileCanReadWithoutBlocking(int fd) { |
info->distro_length = strlen(distro); |
info->distro = distro; |
- |
+#if defined(OS_ANDROID) |
+ // Nothing gets uploaded in android. |
+ info->upload = false; |
+#else |
info->upload = (getenv(env_vars::kHeadless) == NULL); |
+#endif |
info->process_start_time = uptime; |
BrowserThread::PostTask( |
BrowserThread::FILE, FROM_HERE, |
- base::Bind(&CrashHandlerHostLinux::WriteDumpFile, |
+ base::Bind(&CrashHandlerHostPosix::WriteDumpFile, |
base::Unretained(this), |
info, |
crashing_pid, |
@@ -326,7 +336,7 @@ void CrashHandlerHostLinux::OnFileCanReadWithoutBlocking(int fd) { |
signal_fd)); |
} |
-void CrashHandlerHostLinux::WriteDumpFile(BreakpadInfo* info, |
+void CrashHandlerHostPosix::WriteDumpFile(BreakpadInfo* info, |
pid_t crashing_pid, |
char* crash_context, |
int signal_fd) { |
@@ -350,20 +360,23 @@ void CrashHandlerHostLinux::WriteDumpFile(BreakpadInfo* info, |
delete[] crash_context; |
// Freed in CrashDumpTask(); |
- char* minidump_filename_str = new char[minidump_filename.length() + 1]; |
+ unsigned minidump_filename_str_len = minidump_filename.length() + 1; |
+ char* minidump_filename_str = new char[minidump_filename_str_len]; |
minidump_filename.copy(minidump_filename_str, minidump_filename.length()); |
minidump_filename_str[minidump_filename.length()] = '\0'; |
info->filename = minidump_filename_str; |
+ info->filename_length = minidump_filename_str_len; |
+ info->pid = crashing_pid; |
BrowserThread::PostTask( |
BrowserThread::IO, FROM_HERE, |
- base::Bind(&CrashHandlerHostLinux::QueueCrashDumpTask, |
+ base::Bind(&CrashHandlerHostPosix::QueueCrashDumpTask, |
base::Unretained(this), |
info, |
signal_fd)); |
} |
-void CrashHandlerHostLinux::QueueCrashDumpTask(BreakpadInfo* info, |
+void CrashHandlerHostPosix::QueueCrashDumpTask(BreakpadInfo* info, |
int signal_fd) { |
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
@@ -383,7 +396,7 @@ void CrashHandlerHostLinux::QueueCrashDumpTask(BreakpadInfo* info, |
base::Bind(&CrashDumpTask, base::Unretained(this), info)); |
} |
-void CrashHandlerHostLinux::WillDestroyCurrentMessageLoop() { |
+void CrashHandlerHostPosix::WillDestroyCurrentMessageLoop() { |
file_descriptor_watcher_.StopWatchingFileDescriptor(); |
// If we are quitting and there are crash dumps in the queue, turn them into |
@@ -392,86 +405,86 @@ void CrashHandlerHostLinux::WillDestroyCurrentMessageLoop() { |
uploader_thread_->Stop(); |
} |
-bool CrashHandlerHostLinux::IsShuttingDown() const { |
+bool CrashHandlerHostPosix::IsShuttingDown() const { |
return shutting_down_; |
} |
-ExtensionCrashHandlerHostLinux::ExtensionCrashHandlerHostLinux() { |
+ExtensionCrashHandlerHostPosix::ExtensionCrashHandlerHostPosix() { |
InitCrashUploaderThread(); |
} |
-ExtensionCrashHandlerHostLinux::~ExtensionCrashHandlerHostLinux() { |
+ExtensionCrashHandlerHostPosix::~ExtensionCrashHandlerHostPosix() { |
} |
-void ExtensionCrashHandlerHostLinux::SetProcessType() { |
+void ExtensionCrashHandlerHostPosix::SetProcessType() { |
process_type_ = "extension"; |
} |
// static |
-ExtensionCrashHandlerHostLinux* ExtensionCrashHandlerHostLinux::GetInstance() { |
- return Singleton<ExtensionCrashHandlerHostLinux>::get(); |
+ExtensionCrashHandlerHostPosix* ExtensionCrashHandlerHostPosix::GetInstance() { |
+ return Singleton<ExtensionCrashHandlerHostPosix>::get(); |
} |
-GpuCrashHandlerHostLinux::GpuCrashHandlerHostLinux() { |
+GpuCrashHandlerHostPosix::GpuCrashHandlerHostPosix() { |
InitCrashUploaderThread(); |
} |
-GpuCrashHandlerHostLinux::~GpuCrashHandlerHostLinux() { |
+GpuCrashHandlerHostPosix::~GpuCrashHandlerHostPosix() { |
} |
-void GpuCrashHandlerHostLinux::SetProcessType() { |
+void GpuCrashHandlerHostPosix::SetProcessType() { |
process_type_ = "gpu-process"; |
} |
// static |
-GpuCrashHandlerHostLinux* GpuCrashHandlerHostLinux::GetInstance() { |
- return Singleton<GpuCrashHandlerHostLinux>::get(); |
+GpuCrashHandlerHostPosix* GpuCrashHandlerHostPosix::GetInstance() { |
+ return Singleton<GpuCrashHandlerHostPosix>::get(); |
} |
-PluginCrashHandlerHostLinux::PluginCrashHandlerHostLinux() { |
+PluginCrashHandlerHostPosix::PluginCrashHandlerHostPosix() { |
InitCrashUploaderThread(); |
} |
-PluginCrashHandlerHostLinux::~PluginCrashHandlerHostLinux() { |
+PluginCrashHandlerHostPosix::~PluginCrashHandlerHostPosix() { |
} |
-void PluginCrashHandlerHostLinux::SetProcessType() { |
+void PluginCrashHandlerHostPosix::SetProcessType() { |
process_type_ = "plugin"; |
} |
// static |
-PluginCrashHandlerHostLinux* PluginCrashHandlerHostLinux::GetInstance() { |
- return Singleton<PluginCrashHandlerHostLinux>::get(); |
+PluginCrashHandlerHostPosix* PluginCrashHandlerHostPosix::GetInstance() { |
+ return Singleton<PluginCrashHandlerHostPosix>::get(); |
} |
-PpapiCrashHandlerHostLinux::PpapiCrashHandlerHostLinux() { |
+PpapiCrashHandlerHostPosix::PpapiCrashHandlerHostPosix() { |
InitCrashUploaderThread(); |
} |
-PpapiCrashHandlerHostLinux::~PpapiCrashHandlerHostLinux() { |
+PpapiCrashHandlerHostPosix::~PpapiCrashHandlerHostPosix() { |
} |
-void PpapiCrashHandlerHostLinux::SetProcessType() { |
+void PpapiCrashHandlerHostPosix::SetProcessType() { |
process_type_ = "ppapi"; |
} |
// static |
-PpapiCrashHandlerHostLinux* PpapiCrashHandlerHostLinux::GetInstance() { |
- return Singleton<PpapiCrashHandlerHostLinux>::get(); |
+PpapiCrashHandlerHostPosix* PpapiCrashHandlerHostPosix::GetInstance() { |
+ return Singleton<PpapiCrashHandlerHostPosix>::get(); |
} |
-RendererCrashHandlerHostLinux::RendererCrashHandlerHostLinux() { |
+RendererCrashHandlerHostPosix::RendererCrashHandlerHostPosix() { |
InitCrashUploaderThread(); |
} |
-RendererCrashHandlerHostLinux::~RendererCrashHandlerHostLinux() { |
+RendererCrashHandlerHostPosix::~RendererCrashHandlerHostPosix() { |
} |
-void RendererCrashHandlerHostLinux::SetProcessType() { |
+void RendererCrashHandlerHostPosix::SetProcessType() { |
process_type_ = "renderer"; |
} |
// static |
-RendererCrashHandlerHostLinux* RendererCrashHandlerHostLinux::GetInstance() { |
- return Singleton<RendererCrashHandlerHostLinux>::get(); |
+RendererCrashHandlerHostPosix* RendererCrashHandlerHostPosix::GetInstance() { |
+ return Singleton<RendererCrashHandlerHostPosix>::get(); |
} |