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

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

Issue 7538036: Windows Breakpad: Allow the crash dump dir and pipe name to be overridden (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Fix to use W version of GetEnvironmentVariable Created 9 years, 4 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/crash_service/crash_service.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 #include "chrome/tools/crash_service/crash_service.h" 5 #include "chrome/tools/crash_service/crash_service.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 8
9 #include <fstream> 9 #include <fstream>
10 #include <map> 10 #include <map>
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 : pid(process_id), self(service), map(crash_map), dump_path(path) { 142 : pid(process_id), self(service), map(crash_map), dump_path(path) {
143 } 143 }
144 }; 144 };
145 145
146 } // namespace 146 } // namespace
147 147
148 // Command line switches: 148 // Command line switches:
149 const char CrashService::kMaxReports[] = "max-reports"; 149 const char CrashService::kMaxReports[] = "max-reports";
150 const char CrashService::kNoWindow[] = "no-window"; 150 const char CrashService::kNoWindow[] = "no-window";
151 const char CrashService::kReporterTag[] = "reporter"; 151 const char CrashService::kReporterTag[] = "reporter";
152 const char CrashService::kDumpsDir[] = "dumps-dir";
153 const char CrashService::kPipeName[] = "pipe-name";
152 154
153 CrashService::CrashService(const std::wstring& report_dir) 155 CrashService::CrashService(const std::wstring& report_dir)
154 : report_path_(report_dir), 156 : report_path_(report_dir),
155 sender_(NULL), 157 sender_(NULL),
156 dumper_(NULL), 158 dumper_(NULL),
157 requests_handled_(0), 159 requests_handled_(0),
158 requests_sent_(0), 160 requests_sent_(0),
159 clients_connected_(0), 161 clients_connected_(0),
160 clients_terminated_(0) { 162 clients_terminated_(0) {
161 chrome::RegisterPathProvider(); 163 chrome::RegisterPathProvider();
162 } 164 }
163 165
164 CrashService::~CrashService() { 166 CrashService::~CrashService() {
165 base::AutoLock lock(sending_); 167 base::AutoLock lock(sending_);
166 delete dumper_; 168 delete dumper_;
167 delete sender_; 169 delete sender_;
168 } 170 }
169 171
170 172
171 bool CrashService::Initialize(const std::wstring& command_line) { 173 bool CrashService::Initialize(const std::wstring& command_line) {
172 using google_breakpad::CrashReportSender; 174 using google_breakpad::CrashReportSender;
173 using google_breakpad::CrashGenerationServer; 175 using google_breakpad::CrashGenerationServer;
174 176
175 const wchar_t* pipe_name = kTestPipeName; 177 std::wstring pipe_name = kTestPipeName;
176 int max_reports = -1; 178 int max_reports = -1;
177 179
178 // The checkpoint file allows CrashReportSender to enforce the the maximum 180 // The checkpoint file allows CrashReportSender to enforce the the maximum
179 // reports per day quota. Does not seem to serve any other purpose. 181 // reports per day quota. Does not seem to serve any other purpose.
180 FilePath checkpoint_path = report_path_.Append(kCheckPointFile); 182 FilePath checkpoint_path = report_path_.Append(kCheckPointFile);
181 183
182 // The dumps path is typically : '<user profile>\Local settings\ 184 // The dumps path is typically : '<user profile>\Local settings\
183 // Application data\Goggle\Chrome\Crash Reports' and the report path is 185 // Application data\Goggle\Chrome\Crash Reports' and the report path is
184 // Application data\Google\Chrome\Reported Crashes.txt 186 // Application data\Google\Chrome\Reported Crashes.txt
185 FilePath user_data_dir; 187 FilePath user_data_dir;
186 if (!PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)) { 188 if (!PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)) {
187 LOG(ERROR) << "could not get DIR_USER_DATA"; 189 LOG(ERROR) << "could not get DIR_USER_DATA";
188 return false; 190 return false;
189 } 191 }
190 report_path_ = user_data_dir.Append(chrome::kCrashReportLog); 192 report_path_ = user_data_dir.Append(chrome::kCrashReportLog);
191 193
194 CommandLine cmd_line = CommandLine::FromString(command_line);
195
192 FilePath dumps_path; 196 FilePath dumps_path;
193 if (!PathService::Get(chrome::DIR_CRASH_DUMPS, &dumps_path)) { 197 if (cmd_line.HasSwitch(kDumpsDir)) {
194 LOG(ERROR) << "could not get DIR_CRASH_DUMPS"; 198 dumps_path = FilePath(cmd_line.GetSwitchValueNative(kDumpsDir));
195 return false; 199 } else {
200 if (!PathService::Get(chrome::DIR_CRASH_DUMPS, &dumps_path)) {
201 LOG(ERROR) << "could not get DIR_CRASH_DUMPS";
202 return false;
203 }
196 } 204 }
197 205
198 CommandLine cmd_line = CommandLine::FromString(command_line);
199
200 // We can override the send reports quota with a command line switch. 206 // We can override the send reports quota with a command line switch.
201 if (cmd_line.HasSwitch(kMaxReports)) 207 if (cmd_line.HasSwitch(kMaxReports))
202 max_reports = _wtoi(cmd_line.GetSwitchValueNative(kMaxReports).c_str()); 208 max_reports = _wtoi(cmd_line.GetSwitchValueNative(kMaxReports).c_str());
203 209
210 // Allow the global pipe name to be overridden for better testability.
211 if (cmd_line.HasSwitch(kPipeName))
212 pipe_name = cmd_line.GetSwitchValueNative(kPipeName);
213
204 if (max_reports > 0) { 214 if (max_reports > 0) {
205 // Create the http sender object. 215 // Create the http sender object.
206 sender_ = new CrashReportSender(checkpoint_path.value()); 216 sender_ = new CrashReportSender(checkpoint_path.value());
207 if (!sender_) { 217 if (!sender_) {
208 LOG(ERROR) << "could not create sender"; 218 LOG(ERROR) << "could not create sender";
209 return false; 219 return false;
210 } 220 }
211 sender_->set_max_reports_per_day(max_reports); 221 sender_->set_max_reports_per_day(max_reports);
212 } 222 }
213 223
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 SDDL_REVISION, 480 SDDL_REVISION,
471 &sec_desc, NULL)) { 481 &sec_desc, NULL)) {
472 if (::GetSecurityDescriptorSacl(sec_desc, &sacl_present, &sacl, 482 if (::GetSecurityDescriptorSacl(sec_desc, &sacl_present, &sacl,
473 &sacl_defaulted)) { 483 &sacl_defaulted)) {
474 return sec_desc; 484 return sec_desc;
475 } 485 }
476 } 486 }
477 487
478 return NULL; 488 return NULL;
479 } 489 }
OLDNEW
« no previous file with comments | « chrome/tools/crash_service/crash_service.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698