Delay app cache check until flag file indicates that it is ready
[chromium-blink-merge.git] / chrome / browser / crash_handler_host_linux.h
blob345c693cd309e8277ef74ea833b69cb68f3a2f8e
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.
5 #ifndef CHROME_BROWSER_CRASH_HANDLER_HOST_LINUX_H_
6 #define CHROME_BROWSER_CRASH_HANDLER_HOST_LINUX_H_
8 #include <sys/types.h>
10 #include <string>
12 #include "base/compiler_specific.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "base/message_loop/message_loop.h"
16 struct BreakpadInfo;
18 namespace base {
19 class Thread;
22 template <typename T> struct DefaultSingletonTraits;
24 // This is the base class for singleton objects which crash dump renderers and
25 // plugins on Linux or Android. We perform the crash dump from the browser
26 // because it allows us to be outside the sandbox.
28 // PluginCrashHandlerHostLinux and RendererCrashHandlerHostLinux are
29 // singletons that handle plugin and renderer crashes, respectively.
31 // Processes signal that they need to be dumped by sending a datagram over a
32 // UNIX domain socket. All processes of the same type share the client end of
33 // this socket which is installed in their descriptor table before exec.
34 class CrashHandlerHostLinux : public base::MessageLoopForIO::Watcher,
35 public base::MessageLoop::DestructionObserver {
36 public:
37 // Get the file descriptor which processes should be given in order to signal
38 // crashes to the browser.
39 int GetDeathSignalSocket() const {
40 return process_socket_;
43 // MessagePumbLibevent::Watcher impl:
44 virtual void OnFileCanWriteWithoutBlocking(int fd) OVERRIDE;
45 virtual void OnFileCanReadWithoutBlocking(int fd) OVERRIDE;
47 // MessageLoop::DestructionObserver impl:
48 virtual void WillDestroyCurrentMessageLoop() OVERRIDE;
50 // Whether we are shutting down or not.
51 bool IsShuttingDown() const;
53 protected:
54 CrashHandlerHostLinux();
55 virtual ~CrashHandlerHostLinux();
57 // Only called in concrete subclasses.
58 void InitCrashUploaderThread();
60 std::string process_type_;
62 private:
63 void Init();
65 // This is here on purpose to make CrashHandlerHostLinux abstract.
66 virtual void SetProcessType() = 0;
68 // Do work on the FILE thread for OnFileCanReadWithoutBlocking().
69 void WriteDumpFile(BreakpadInfo* info,
70 pid_t crashing_pid,
71 char* crash_context,
72 int signal_fd);
74 // Continue OnFileCanReadWithoutBlocking()'s work on the IO thread.
75 void QueueCrashDumpTask(BreakpadInfo* info, int signal_fd);
77 int process_socket_;
78 int browser_socket_;
80 base::MessageLoopForIO::FileDescriptorWatcher file_descriptor_watcher_;
81 scoped_ptr<base::Thread> uploader_thread_;
82 bool shutting_down_;
84 #if defined(ADDRESS_SANITIZER)
85 char* asan_report_str_;
86 #endif
88 DISALLOW_COPY_AND_ASSIGN(CrashHandlerHostLinux);
91 class ExtensionCrashHandlerHostLinux : public CrashHandlerHostLinux {
92 public:
93 // Returns the singleton instance.
94 static ExtensionCrashHandlerHostLinux* GetInstance();
96 private:
97 friend struct DefaultSingletonTraits<ExtensionCrashHandlerHostLinux>;
98 ExtensionCrashHandlerHostLinux();
99 virtual ~ExtensionCrashHandlerHostLinux();
101 virtual void SetProcessType() OVERRIDE;
103 DISALLOW_COPY_AND_ASSIGN(ExtensionCrashHandlerHostLinux);
106 class GpuCrashHandlerHostLinux : public CrashHandlerHostLinux {
107 public:
108 // Returns the singleton instance.
109 static GpuCrashHandlerHostLinux* GetInstance();
111 private:
112 friend struct DefaultSingletonTraits<GpuCrashHandlerHostLinux>;
113 GpuCrashHandlerHostLinux();
114 virtual ~GpuCrashHandlerHostLinux();
116 virtual void SetProcessType() OVERRIDE;
118 DISALLOW_COPY_AND_ASSIGN(GpuCrashHandlerHostLinux);
121 class PluginCrashHandlerHostLinux : public CrashHandlerHostLinux {
122 public:
123 // Returns the singleton instance.
124 static PluginCrashHandlerHostLinux* GetInstance();
126 private:
127 friend struct DefaultSingletonTraits<PluginCrashHandlerHostLinux>;
128 PluginCrashHandlerHostLinux();
129 virtual ~PluginCrashHandlerHostLinux();
131 virtual void SetProcessType() OVERRIDE;
133 DISALLOW_COPY_AND_ASSIGN(PluginCrashHandlerHostLinux);
136 class PpapiCrashHandlerHostLinux : public CrashHandlerHostLinux {
137 public:
138 // Returns the singleton instance.
139 static PpapiCrashHandlerHostLinux* GetInstance();
141 private:
142 friend struct DefaultSingletonTraits<PpapiCrashHandlerHostLinux>;
143 PpapiCrashHandlerHostLinux();
144 virtual ~PpapiCrashHandlerHostLinux();
146 virtual void SetProcessType() OVERRIDE;
148 DISALLOW_COPY_AND_ASSIGN(PpapiCrashHandlerHostLinux);
151 class RendererCrashHandlerHostLinux : public CrashHandlerHostLinux {
152 public:
153 // Returns the singleton instance.
154 static RendererCrashHandlerHostLinux* GetInstance();
156 private:
157 friend struct DefaultSingletonTraits<RendererCrashHandlerHostLinux>;
158 RendererCrashHandlerHostLinux();
159 virtual ~RendererCrashHandlerHostLinux();
161 virtual void SetProcessType() OVERRIDE;
163 DISALLOW_COPY_AND_ASSIGN(RendererCrashHandlerHostLinux);
166 #endif // CHROME_BROWSER_CRASH_HANDLER_HOST_LINUX_H_