diff options
author | carlosvaldivia@google.com <carlosvaldivia@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-09 19:27:22 +0000 |
---|---|---|
committer | carlosvaldivia@google.com <carlosvaldivia@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-09 19:27:22 +0000 |
commit | e7aa62a3bf6993369b5adb61028fddb3eb7a58bf (patch) | |
tree | 476e203d6e64f9b350130ecb3d16ff34c6835204 /chrome/browser/crash_handler_host_linuxish.h | |
parent | 6e575772033fb8ad816b805fbaa95bde2ce18985 (diff) | |
download | chromium_src-e7aa62a3bf6993369b5adb61028fddb3eb7a58bf.zip chromium_src-e7aa62a3bf6993369b5adb61028fddb3eb7a58bf.tar.gz chromium_src-e7aa62a3bf6993369b5adb61028fddb3eb7a58bf.tar.bz2 |
Upstream native crash handling changes for Android.
Android native crash handling is almost identical to linux handling with
some differences.
Note that even after this change Chrome on Android will not compile with
the USE_LINUX_BREAKPAD flag. Forthcomming changes in breakpad should
remedy this state of affairs.
BUG=
TEST=
Review URL: http://codereview.chromium.org/9838033
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@131404 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/crash_handler_host_linuxish.h')
-rw-r--r-- | chrome/browser/crash_handler_host_linuxish.h | 184 |
1 files changed, 184 insertions, 0 deletions
diff --git a/chrome/browser/crash_handler_host_linuxish.h b/chrome/browser/crash_handler_host_linuxish.h new file mode 100644 index 0000000..80c06d9 --- /dev/null +++ b/chrome/browser/crash_handler_host_linuxish.h @@ -0,0 +1,184 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_CRASH_HANDLER_HOST_LINUXISH_H_ +#define CHROME_BROWSER_CRASH_HANDLER_HOST_LINUXISH_H_ +#pragma once + +#include "base/compiler_specific.h" +#include "base/message_loop.h" + +#if defined(USE_LINUX_BREAKPAD) +#include <sys/types.h> + +#include <string> + +#include "base/memory/scoped_ptr.h" + +class BreakpadInfo; + +namespace base { +class Thread; +} +#endif // defined(USE_LINUX_BREAKPAD) + +template <typename T> struct DefaultSingletonTraits; + +// This is the base class for singleton objects which crash dump renderers and +// plugins on Linux or Android. We perform the crash dump from the browser +// because it allows us to be outside the sandbox. +// +// PluginCrashHandlerHostLinux and RendererCrashHandlerHostLinux are +// singletons that handle plugin and renderer crashes, respectively. +// +// Processes signal that they need to be dumped by sending a datagram over a +// UNIX domain socket. All processes of the same type share the client end of +// this socket which is installed in their descriptor table before exec. +class CrashHandlerHostLinux : public MessageLoopForIO::Watcher, + public MessageLoop::DestructionObserver { + public: + // Get the file descriptor which processes should be given in order to signal + // crashes to the browser. + int GetDeathSignalSocket() const { + return process_socket_; + } + + // MessagePumbLibevent::Watcher impl: + virtual void OnFileCanWriteWithoutBlocking(int fd) OVERRIDE; + virtual void OnFileCanReadWithoutBlocking(int fd) OVERRIDE; + + // MessageLoop::DestructionObserver impl: + virtual void WillDestroyCurrentMessageLoop() OVERRIDE; + +#if defined(USE_LINUX_BREAKPAD) + // Whether we are shutting down or not. + bool IsShuttingDown() const; +#endif + + protected: + CrashHandlerHostLinux(); + virtual ~CrashHandlerHostLinux(); + +#if defined(USE_LINUX_BREAKPAD) + // Only called in concrete subclasses. + void InitCrashUploaderThread(); + + std::string process_type_; +#endif + + private: + void Init(); + +#if defined(USE_LINUX_BREAKPAD) + // This is here on purpose to make CrashHandlerHostLinux abstract. + virtual void SetProcessType() = 0; + + // Do work on the FILE thread for OnFileCanReadWithoutBlocking(). + void WriteDumpFile(BreakpadInfo* info, + pid_t crashing_pid, + char* crash_context, + int signal_fd); + + // Continue OnFileCanReadWithoutBlocking()'s work on the IO thread. + void QueueCrashDumpTask(BreakpadInfo* info, int signal_fd); +#endif + + int process_socket_; + int browser_socket_; + +#if defined(USE_LINUX_BREAKPAD) + MessageLoopForIO::FileDescriptorWatcher file_descriptor_watcher_; + scoped_ptr<base::Thread> uploader_thread_; + bool shutting_down_; +#endif + + DISALLOW_COPY_AND_ASSIGN(CrashHandlerHostLinux); +}; + +class ExtensionCrashHandlerHostLinux : public CrashHandlerHostLinux { + public: + // Returns the singleton instance. + static ExtensionCrashHandlerHostLinux* GetInstance(); + + private: + friend struct DefaultSingletonTraits<ExtensionCrashHandlerHostLinux>; + ExtensionCrashHandlerHostLinux(); + virtual ~ExtensionCrashHandlerHostLinux(); + +#if defined(USE_LINUX_BREAKPAD) + virtual void SetProcessType() OVERRIDE; +#endif + + DISALLOW_COPY_AND_ASSIGN(ExtensionCrashHandlerHostLinux); +}; + +class GpuCrashHandlerHostLinux : public CrashHandlerHostLinux { + public: + // Returns the singleton instance. + static GpuCrashHandlerHostLinux* GetInstance(); + + private: + friend struct DefaultSingletonTraits<GpuCrashHandlerHostLinux>; + GpuCrashHandlerHostLinux(); + virtual ~GpuCrashHandlerHostLinux(); + +#if defined(USE_LINUX_BREAKPAD) + virtual void SetProcessType() OVERRIDE; +#endif + + DISALLOW_COPY_AND_ASSIGN(GpuCrashHandlerHostLinux); +}; + +class PluginCrashHandlerHostLinux : public CrashHandlerHostLinux { + public: + // Returns the singleton instance. + static PluginCrashHandlerHostLinux* GetInstance(); + + private: + friend struct DefaultSingletonTraits<PluginCrashHandlerHostLinux>; + PluginCrashHandlerHostLinux(); + virtual ~PluginCrashHandlerHostLinux(); + +#if defined(USE_LINUX_BREAKPAD) + virtual void SetProcessType() OVERRIDE; +#endif + + DISALLOW_COPY_AND_ASSIGN(PluginCrashHandlerHostLinux); +}; + +class PpapiCrashHandlerHostLinux : public CrashHandlerHostLinux { + public: + // Returns the singleton instance. + static PpapiCrashHandlerHostLinux* GetInstance(); + + private: + friend struct DefaultSingletonTraits<PpapiCrashHandlerHostLinux>; + PpapiCrashHandlerHostLinux(); + virtual ~PpapiCrashHandlerHostLinux(); + +#if defined(USE_LINUX_BREAKPAD) + virtual void SetProcessType() OVERRIDE; +#endif + + DISALLOW_COPY_AND_ASSIGN(PpapiCrashHandlerHostLinux); +}; + +class RendererCrashHandlerHostLinux : public CrashHandlerHostLinux { + public: + // Returns the singleton instance. + static RendererCrashHandlerHostLinux* GetInstance(); + + private: + friend struct DefaultSingletonTraits<RendererCrashHandlerHostLinux>; + RendererCrashHandlerHostLinux(); + virtual ~RendererCrashHandlerHostLinux(); + +#if defined(USE_LINUX_BREAKPAD) + virtual void SetProcessType() OVERRIDE; +#endif + + DISALLOW_COPY_AND_ASSIGN(RendererCrashHandlerHostLinux); +}; + +#endif // CHROME_BROWSER_CRASH_HANDLER_HOST_LINUXISH_H_ |