| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_RENDERER_HOST_RENDER_CRASH_HANDLER_HOST_LINUX_H_ | 5 #ifndef CHROME_BROWSER_CRASH_HANDLER_HOST_LINUX_H_ |
| 6 #define CHROME_BROWSER_RENDERER_HOST_RENDER_CRASH_HANDLER_HOST_LINUX_H_ | 6 #define CHROME_BROWSER_CRASH_HANDLER_HOST_LINUX_H_ |
| 7 |
| 8 #include <string> |
| 7 | 9 |
| 8 #include "base/singleton.h" | 10 #include "base/singleton.h" |
| 9 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
| 10 | 12 |
| 11 // This is a singleton object which crash dumps renderers on Linux. We perform | 13 // This is the base class for singleton objects which crash dumps renderers and |
| 12 // the crash dump from the browser because it allows us to be outside the | 14 // plugins on Linux. We perform the crash dump from the browser because it |
| 13 // sandbox. | 15 // allows us to be outside the sandbox. |
| 14 // | 16 // |
| 15 // Renderers signal that they need to be dumped by sending a datagram over a | 17 // PluginCrashHandlerHostLinux and RendererCrashHandlerHostLinux are singletons |
| 16 // UNIX domain socket. All renderers share the client end of this socket which | 18 // that handle plugin and renderer crashes, respectively. |
| 17 // is installed in their descriptor table before exec. | 19 // |
| 18 class RenderCrashHandlerHostLinux : public MessageLoopForIO::Watcher, | 20 // Processes signal that they need to be dumped by sending a datagram over a |
| 19 public MessageLoop::DestructionObserver { | 21 // UNIX domain socket. All processes of the same type share the client end of |
| 22 // this socket which is installed in their descriptor table before exec. |
| 23 class CrashHandlerHostLinux : public MessageLoopForIO::Watcher, |
| 24 public MessageLoop::DestructionObserver { |
| 20 public: | 25 public: |
| 21 // Get the file descriptor which renderers should be given in order to signal | 26 // Get the file descriptor which processes should be given in order to signal |
| 22 // crashes to the browser. | 27 // crashes to the browser. |
| 23 int GetDeathSignalSocket() const { | 28 int GetDeathSignalSocket() const { |
| 24 return renderer_socket_; | 29 return process_socket_; |
| 25 } | 30 } |
| 26 | 31 |
| 27 // MessagePumbLibevent::Watcher impl: | 32 // MessagePumbLibevent::Watcher impl: |
| 28 virtual void OnFileCanWriteWithoutBlocking(int fd); | 33 virtual void OnFileCanWriteWithoutBlocking(int fd); |
| 29 virtual void OnFileCanReadWithoutBlocking(int fd); | 34 virtual void OnFileCanReadWithoutBlocking(int fd); |
| 30 | 35 |
| 31 // MessageLoop::DestructionObserver impl: | 36 // MessageLoop::DestructionObserver impl: |
| 32 virtual void WillDestroyCurrentMessageLoop(); | 37 virtual void WillDestroyCurrentMessageLoop(); |
| 33 | 38 |
| 39 protected: |
| 40 CrashHandlerHostLinux(); |
| 41 ~CrashHandlerHostLinux(); |
| 42 // This is here on purpose to make CrashHandlerHostLinux abstract. |
| 43 virtual void SetProcessType() = 0; |
| 44 |
| 45 std::string process_type_; |
| 46 |
| 34 private: | 47 private: |
| 35 friend struct DefaultSingletonTraits<RenderCrashHandlerHostLinux>; | |
| 36 RenderCrashHandlerHostLinux(); | |
| 37 ~RenderCrashHandlerHostLinux(); | |
| 38 void Init(); | 48 void Init(); |
| 39 | 49 |
| 40 int renderer_socket_; | 50 int process_socket_; |
| 41 int browser_socket_; | 51 int browser_socket_; |
| 42 MessageLoopForIO::FileDescriptorWatcher file_descriptor_watcher_; | 52 MessageLoopForIO::FileDescriptorWatcher file_descriptor_watcher_; |
| 43 | 53 |
| 44 DISALLOW_EVIL_CONSTRUCTORS(RenderCrashHandlerHostLinux); | 54 DISALLOW_COPY_AND_ASSIGN(CrashHandlerHostLinux); |
| 45 }; | 55 }; |
| 46 | 56 |
| 47 #endif // CHROME_BROWSER_RENDERER_HOST_RENDER_CRASH_HANDLER_HOST_LINUX_H_ | 57 class PluginCrashHandlerHostLinux : public CrashHandlerHostLinux { |
| 58 private: |
| 59 friend struct DefaultSingletonTraits<PluginCrashHandlerHostLinux>; |
| 60 PluginCrashHandlerHostLinux() { |
| 61 SetProcessType(); |
| 62 } |
| 63 ~PluginCrashHandlerHostLinux() {} |
| 64 |
| 65 virtual void SetProcessType() { |
| 66 process_type_ = "plugin"; |
| 67 } |
| 68 |
| 69 DISALLOW_COPY_AND_ASSIGN(PluginCrashHandlerHostLinux); |
| 70 }; |
| 71 |
| 72 class RendererCrashHandlerHostLinux : public CrashHandlerHostLinux { |
| 73 private: |
| 74 friend struct DefaultSingletonTraits<RendererCrashHandlerHostLinux>; |
| 75 RendererCrashHandlerHostLinux() { |
| 76 SetProcessType(); |
| 77 } |
| 78 ~RendererCrashHandlerHostLinux() {} |
| 79 |
| 80 virtual void SetProcessType() { |
| 81 process_type_ = "renderer"; |
| 82 } |
| 83 |
| 84 DISALLOW_COPY_AND_ASSIGN(RendererCrashHandlerHostLinux); |
| 85 }; |
| 86 |
| 87 #endif // CHROME_BROWSER_CRASH_HANDLER_HOST_LINUX_H_ |
| OLD | NEW |