Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1014)

Side by Side Diff: chrome/browser/crash_handler_host_linux.h

Issue 29943005: Prepare CrashHandlerHostLinux for move to breakpad component (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: updates Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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_CRASH_HANDLER_HOST_LINUX_H_ 5 #ifndef CHROME_BROWSER_CRASH_HANDLER_HOST_LINUX_H_
6 #define CHROME_BROWSER_CRASH_HANDLER_HOST_LINUX_H_ 6 #define CHROME_BROWSER_CRASH_HANDLER_HOST_LINUX_H_
7 7
8 #include <sys/types.h> 8 #include <sys/types.h>
9 9
10 #include <string> 10 #include <string>
11 11
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/files/file_path.h"
13 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
14 #include "base/message_loop/message_loop.h" 15 #include "base/message_loop/message_loop.h"
15 #include "base/threading/sequenced_worker_pool.h" 16 #include "base/threading/sequenced_worker_pool.h"
16 17
17 struct BreakpadInfo; 18 struct BreakpadInfo;
18 19
19 namespace base { 20 namespace base {
20 class Thread; 21 class Thread;
21 } 22 }
22 23
23 template <typename T> struct DefaultSingletonTraits; 24 // This is the host for processes which run breakpad inside the sandbox on
24 25 // Linux or Android. We perform the crash dump from the browser because it
25 // This is the base class for singleton objects which crash dump renderers and 26 // allows us to be outside the sandbox.
26 // plugins on Linux or Android. We perform the crash dump from the browser
27 // because it allows us to be outside the sandbox.
28 //
29 // PluginCrashHandlerHostLinux and RendererCrashHandlerHostLinux are
30 // singletons that handle plugin and renderer crashes, respectively.
31 // 27 //
32 // Processes signal that they need to be dumped by sending a datagram over a 28 // Processes signal that they need to be dumped by sending a datagram over a
33 // UNIX domain socket. All processes of the same type share the client end of 29 // UNIX domain socket. All processes of the same type share the client end of
34 // this socket which is installed in their descriptor table before exec. 30 // this socket which is installed in their descriptor table before exec.
35 class CrashHandlerHostLinux : public base::MessageLoopForIO::Watcher, 31 class CrashHandlerHostLinux : public base::MessageLoopForIO::Watcher,
36 public base::MessageLoop::DestructionObserver { 32 public base::MessageLoop::DestructionObserver {
37 public: 33 public:
34 CrashHandlerHostLinux(const std::string& process_type,
35 const base::FilePath& dumps_path,
36 bool upload);
37 virtual ~CrashHandlerHostLinux();
38
39 // Starts the uploader thread. Must be called immediately after creating the
40 // class.
41 void StartUploaderThread();
42
38 // Get the file descriptor which processes should be given in order to signal 43 // Get the file descriptor which processes should be given in order to signal
39 // crashes to the browser. 44 // crashes to the browser.
40 int GetDeathSignalSocket() const { 45 int GetDeathSignalSocket() const {
41 return process_socket_; 46 return process_socket_;
42 } 47 }
43 48
44 // MessagePumbLibevent::Watcher impl: 49 // MessagePumbLibevent::Watcher impl:
45 virtual void OnFileCanWriteWithoutBlocking(int fd) OVERRIDE; 50 virtual void OnFileCanWriteWithoutBlocking(int fd) OVERRIDE;
46 virtual void OnFileCanReadWithoutBlocking(int fd) OVERRIDE; 51 virtual void OnFileCanReadWithoutBlocking(int fd) OVERRIDE;
47 52
48 // MessageLoop::DestructionObserver impl: 53 // MessageLoop::DestructionObserver impl:
49 virtual void WillDestroyCurrentMessageLoop() OVERRIDE; 54 virtual void WillDestroyCurrentMessageLoop() OVERRIDE;
50 55
51 // Whether we are shutting down or not. 56 // Whether we are shutting down or not.
52 bool IsShuttingDown() const; 57 bool IsShuttingDown() const;
53 58
54 protected:
55 CrashHandlerHostLinux();
56 virtual ~CrashHandlerHostLinux();
57
58 // Only called in concrete subclasses.
59 void InitCrashUploaderThread();
60
61 std::string process_type_;
62
63 private: 59 private:
64 void Init(); 60 void Init();
65 61
66 // This is here on purpose to make CrashHandlerHostLinux abstract.
67 virtual void SetProcessType() = 0;
68
69 // Do work on the FILE thread for OnFileCanReadWithoutBlocking(). 62 // Do work on the FILE thread for OnFileCanReadWithoutBlocking().
70 void WriteDumpFile(BreakpadInfo* info, 63 void WriteDumpFile(BreakpadInfo* info,
71 pid_t crashing_pid, 64 pid_t crashing_pid,
72 char* crash_context, 65 char* crash_context,
73 int signal_fd); 66 int signal_fd);
74 67
75 // Continue OnFileCanReadWithoutBlocking()'s work on the IO thread. 68 // Continue OnFileCanReadWithoutBlocking()'s work on the IO thread.
76 void QueueCrashDumpTask(BreakpadInfo* info, int signal_fd); 69 void QueueCrashDumpTask(BreakpadInfo* info, int signal_fd);
77 70
71 std::string process_type_;
72 base::FilePath dumps_path_;
73 bool upload_;
74
78 int process_socket_; 75 int process_socket_;
79 int browser_socket_; 76 int browser_socket_;
80 77
81 base::MessageLoopForIO::FileDescriptorWatcher file_descriptor_watcher_; 78 base::MessageLoopForIO::FileDescriptorWatcher file_descriptor_watcher_;
82 scoped_ptr<base::Thread> uploader_thread_; 79 scoped_ptr<base::Thread> uploader_thread_;
83 bool shutting_down_; 80 bool shutting_down_;
84 81
85 // Unique sequence token so that writing crash dump won't be blocked 82 // Unique sequence token so that writing crash dump won't be blocked
86 // by other tasks. 83 // by other tasks.
87 base::SequencedWorkerPool::SequenceToken worker_pool_token_; 84 base::SequencedWorkerPool::SequenceToken worker_pool_token_;
88 85
89 #if defined(ADDRESS_SANITIZER) 86 #if defined(ADDRESS_SANITIZER)
90 char* asan_report_str_; 87 char* asan_report_str_;
91 #endif 88 #endif
92 89
93 DISALLOW_COPY_AND_ASSIGN(CrashHandlerHostLinux); 90 DISALLOW_COPY_AND_ASSIGN(CrashHandlerHostLinux);
94 }; 91 };
95 92
96 class ExtensionCrashHandlerHostLinux : public CrashHandlerHostLinux {
97 public:
98 // Returns the singleton instance.
99 static ExtensionCrashHandlerHostLinux* GetInstance();
100
101 private:
102 friend struct DefaultSingletonTraits<ExtensionCrashHandlerHostLinux>;
103 ExtensionCrashHandlerHostLinux();
104 virtual ~ExtensionCrashHandlerHostLinux();
105
106 virtual void SetProcessType() OVERRIDE;
107
108 DISALLOW_COPY_AND_ASSIGN(ExtensionCrashHandlerHostLinux);
109 };
110
111 class GpuCrashHandlerHostLinux : public CrashHandlerHostLinux {
112 public:
113 // Returns the singleton instance.
114 static GpuCrashHandlerHostLinux* GetInstance();
115
116 private:
117 friend struct DefaultSingletonTraits<GpuCrashHandlerHostLinux>;
118 GpuCrashHandlerHostLinux();
119 virtual ~GpuCrashHandlerHostLinux();
120
121 virtual void SetProcessType() OVERRIDE;
122
123 DISALLOW_COPY_AND_ASSIGN(GpuCrashHandlerHostLinux);
124 };
125
126 class PluginCrashHandlerHostLinux : public CrashHandlerHostLinux {
127 public:
128 // Returns the singleton instance.
129 static PluginCrashHandlerHostLinux* GetInstance();
130
131 private:
132 friend struct DefaultSingletonTraits<PluginCrashHandlerHostLinux>;
133 PluginCrashHandlerHostLinux();
134 virtual ~PluginCrashHandlerHostLinux();
135
136 virtual void SetProcessType() OVERRIDE;
137
138 DISALLOW_COPY_AND_ASSIGN(PluginCrashHandlerHostLinux);
139 };
140
141 class PpapiCrashHandlerHostLinux : public CrashHandlerHostLinux {
142 public:
143 // Returns the singleton instance.
144 static PpapiCrashHandlerHostLinux* GetInstance();
145
146 private:
147 friend struct DefaultSingletonTraits<PpapiCrashHandlerHostLinux>;
148 PpapiCrashHandlerHostLinux();
149 virtual ~PpapiCrashHandlerHostLinux();
150
151 virtual void SetProcessType() OVERRIDE;
152
153 DISALLOW_COPY_AND_ASSIGN(PpapiCrashHandlerHostLinux);
154 };
155
156 class RendererCrashHandlerHostLinux : public CrashHandlerHostLinux {
157 public:
158 // Returns the singleton instance.
159 static RendererCrashHandlerHostLinux* GetInstance();
160
161 private:
162 friend struct DefaultSingletonTraits<RendererCrashHandlerHostLinux>;
163 RendererCrashHandlerHostLinux();
164 virtual ~RendererCrashHandlerHostLinux();
165
166 virtual void SetProcessType() OVERRIDE;
167
168 DISALLOW_COPY_AND_ASSIGN(RendererCrashHandlerHostLinux);
169 };
170
171 #endif // CHROME_BROWSER_CRASH_HANDLER_HOST_LINUX_H_ 93 #endif // CHROME_BROWSER_CRASH_HANDLER_HOST_LINUX_H_
OLDNEW
« no previous file with comments | « chrome/browser/chrome_content_browser_client.cc ('k') | chrome/browser/crash_handler_host_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698