diff options
author | thestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-09 04:21:51 +0000 |
---|---|---|
committer | thestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-09 04:21:51 +0000 |
commit | 2456c5732fe85109c39dbdd3dbbb8262589a847e (patch) | |
tree | 2c80c90ee30afb95428903c267e0eebe028d73f5 /chrome/browser/crash_handler_host_linux.h | |
parent | 22dac03746590ef7367c8af21ace424b77cae16d (diff) | |
download | chromium_src-2456c5732fe85109c39dbdd3dbbb8262589a847e.zip chromium_src-2456c5732fe85109c39dbdd3dbbb8262589a847e.tar.gz chromium_src-2456c5732fe85109c39dbdd3dbbb8262589a847e.tar.bz2 |
Linux: Catch plugin crashes.
BUG=25964
TEST=none
Review URL: http://codereview.chromium.org/371015
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31416 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/crash_handler_host_linux.h')
-rw-r--r-- | chrome/browser/crash_handler_host_linux.h | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/chrome/browser/crash_handler_host_linux.h b/chrome/browser/crash_handler_host_linux.h new file mode 100644 index 0000000..3f1ea2e --- /dev/null +++ b/chrome/browser/crash_handler_host_linux.h @@ -0,0 +1,87 @@ +// Copyright (c) 2009 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_LINUX_H_ +#define CHROME_BROWSER_CRASH_HANDLER_HOST_LINUX_H_ + +#include <string> + +#include "base/singleton.h" +#include "base/message_loop.h" + +// This is the base class for singleton objects which crash dump renderers and +// plugins on Linux. 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); + virtual void OnFileCanReadWithoutBlocking(int fd); + + // MessageLoop::DestructionObserver impl: + virtual void WillDestroyCurrentMessageLoop(); + + protected: + CrashHandlerHostLinux(); + ~CrashHandlerHostLinux(); + // This is here on purpose to make CrashHandlerHostLinux abstract. + virtual void SetProcessType() = 0; + + std::string process_type_; + + private: + void Init(); + + int process_socket_; + int browser_socket_; + MessageLoopForIO::FileDescriptorWatcher file_descriptor_watcher_; + + DISALLOW_COPY_AND_ASSIGN(CrashHandlerHostLinux); +}; + +class PluginCrashHandlerHostLinux : public CrashHandlerHostLinux { + private: + friend struct DefaultSingletonTraits<PluginCrashHandlerHostLinux>; + PluginCrashHandlerHostLinux() { + SetProcessType(); + } + ~PluginCrashHandlerHostLinux() {} + + virtual void SetProcessType() { + process_type_ = "plugin"; + } + + DISALLOW_COPY_AND_ASSIGN(PluginCrashHandlerHostLinux); +}; + +class RendererCrashHandlerHostLinux : public CrashHandlerHostLinux { + private: + friend struct DefaultSingletonTraits<RendererCrashHandlerHostLinux>; + RendererCrashHandlerHostLinux() { + SetProcessType(); + } + ~RendererCrashHandlerHostLinux() {} + + virtual void SetProcessType() { + process_type_ = "renderer"; + } + + DISALLOW_COPY_AND_ASSIGN(RendererCrashHandlerHostLinux); +}; + +#endif // CHROME_BROWSER_CRASH_HANDLER_HOST_LINUX_H_ |