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

Side by Side Diff: chrome/tools/crash_service/crash_service.h

Issue 26688006: Move CrashService class 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
« no previous file with comments | « chrome/tools/DEPS ('k') | chrome/tools/crash_service/crash_service.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2011 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.
4
5 #ifndef CHROME_TOOLS_CRASH_SERVICE_CRASH_SERVICE_H_
6 #define CHROME_TOOLS_CRASH_SERVICE_CRASH_SERVICE_H_
7
8 #include <string>
9
10 #include "base/basictypes.h"
11 #include "base/files/file_path.h"
12 #include "base/synchronization/lock.h"
13
14 namespace google_breakpad {
15
16 class CrashReportSender;
17 class CrashGenerationServer;
18 class ClientInfo;
19
20 }
21
22 // This class implements an out-of-process crash server. It uses breakpad's
23 // CrashGenerationServer and CrashReportSender to generate and then send the
24 // crash dumps. Internally, it uses OS specific pipe to allow applications to
25 // register for crash dumps and later on when a registered application crashes
26 // it will signal an event that causes this code to wake up and perform a
27 // crash dump on the signaling process. The dump is then stored on disk and
28 // possibly sent to the crash2 servers.
29 class CrashService {
30 public:
31 // The ctor takes a directory that needs to be writable and will create
32 // a subdirectory inside to keep logs, crashes and checkpoint files.
33 explicit CrashService(const std::wstring& report_dir);
34 ~CrashService();
35
36 // Starts servicing crash dumps. The command_line specifies various behaviors,
37 // see below for more information. Returns false if it failed. Do not use
38 // other members in that case.
39 bool Initialize(const std::wstring& command_line);
40
41 // Command line switches:
42 //
43 // --max-reports=<number>
44 // Allows to override the maximum number for reports per day. Normally
45 // the crash dumps are never sent so if you want to send any you must
46 // specify a positive number here.
47 static const char kMaxReports[];
48 // --no-window
49 // Does not create a visible window on the desktop. The window does not have
50 // any other functionality other than allowing the crash service to be
51 // gracefully closed.
52 static const char kNoWindow[];
53 // --reporter=<string>
54 // Allows to specify a custom string that appears on the detail crash report
55 // page in the crash server. This should be a 25 chars or less string.
56 // The default tag if not specified is 'crash svc'.
57 static const char kReporterTag[];
58 // --dumps-dir=<directory-path>
59 // Override the directory to which crash dump files will be written.
60 static const char kDumpsDir[];
61 // --pipe-name=<string>
62 // Override the name of the Windows named pipe on which we will
63 // listen for crash dump request messages.
64 static const char kPipeName[];
65
66 // Returns number of crash dumps handled.
67 int requests_handled() const {
68 return requests_handled_;
69 }
70 // Returns number of crash clients registered.
71 int clients_connected() const {
72 return clients_connected_;
73 }
74 // Returns number of crash clients terminated.
75 int clients_terminated() const {
76 return clients_terminated_;
77 }
78
79 // Starts the processing loop. This function does not return unless the
80 // user is logging off or the user closes the crash service window. The
81 // return value is a good number to pass in ExitProcess().
82 int ProcessingLoop();
83
84 private:
85 static void OnClientConnected(void* context,
86 const google_breakpad::ClientInfo* client_info);
87
88 static void OnClientDumpRequest(
89 void* context,
90 const google_breakpad::ClientInfo* client_info,
91 const std::wstring* file_path);
92
93 static void OnClientExited(void* context,
94 const google_breakpad::ClientInfo* client_info);
95
96 // This routine sends the crash dump to the server. It takes the sending_
97 // lock when it is performing the send.
98 static unsigned long __stdcall AsyncSendDump(void* context);
99
100 // Returns the security descriptor which access to low integrity processes
101 // The caller is supposed to free the security descriptor by calling
102 // LocalFree.
103 PSECURITY_DESCRIPTOR GetSecurityDescriptorForLowIntegrity();
104
105 google_breakpad::CrashGenerationServer* dumper_;
106 google_breakpad::CrashReportSender* sender_;
107
108 // the path to dumps and logs directory.
109 base::FilePath report_path_;
110 // the extra tag sent to the server with each dump.
111 std::wstring reporter_tag_;
112
113 // clients serviced statistics:
114 int requests_handled_;
115 int requests_sent_;
116 volatile long clients_connected_;
117 volatile long clients_terminated_;
118 base::Lock sending_;
119
120 DISALLOW_COPY_AND_ASSIGN(CrashService);
121 };
122
123 #endif // CHROME_TOOLS_CRASH_SERVICE_CRASH_SERVICE_H_
OLDNEW
« no previous file with comments | « chrome/tools/DEPS ('k') | chrome/tools/crash_service/crash_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698