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

Side by Side Diff: client/crash_report_database_mac.mm

Issue 1000263003: Add MinidumpCrashpadInfo::report_id (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Created 5 years, 9 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
« no previous file with comments | « client/crash_report_database.h ('k') | client/crash_report_database_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Crashpad Authors. All rights reserved. 1 // Copyright 2015 The Crashpad Authors. All rights reserved.
2 // 2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); 3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License. 4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at 5 // You may obtain a copy of the License at
6 // 6 //
7 // http://www.apache.org/licenses/LICENSE-2.0 7 // http://www.apache.org/licenses/LICENSE-2.0
8 // 8 //
9 // Unless required by applicable law or agreed to in writing, software 9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, 10 // distributed under the License is distributed on an "AS IS" BASIS,
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 231
232 Settings* CrashReportDatabaseMac::GetSettings() { 232 Settings* CrashReportDatabaseMac::GetSettings() {
233 INITIALIZATION_STATE_DCHECK_VALID(initialized_); 233 INITIALIZATION_STATE_DCHECK_VALID(initialized_);
234 return &settings_; 234 return &settings_;
235 } 235 }
236 236
237 CrashReportDatabase::OperationStatus 237 CrashReportDatabase::OperationStatus
238 CrashReportDatabaseMac::PrepareNewCrashReport(NewReport** out_report) { 238 CrashReportDatabaseMac::PrepareNewCrashReport(NewReport** out_report) {
239 INITIALIZATION_STATE_DCHECK_VALID(initialized_); 239 INITIALIZATION_STATE_DCHECK_VALID(initialized_);
240 240
241 scoped_ptr<NewReport> report(new NewReport());
242
241 uuid_t uuid_gen; 243 uuid_t uuid_gen;
242 uuid_generate(uuid_gen); 244 uuid_generate(uuid_gen);
243 UUID uuid(uuid_gen); 245 report->uuid.InitializeFromBytes(uuid_gen);
244
245 scoped_ptr<NewReport> report(new NewReport());
246 246
247 report->path = 247 report->path =
248 base_dir_.Append(kWriteDirectory) 248 base_dir_.Append(kWriteDirectory)
249 .Append(uuid.ToString() + "." + kCrashReportFileExtension); 249 .Append(report->uuid.ToString() + "." + kCrashReportFileExtension);
250 250
251 report->handle = HANDLE_EINTR(open(report->path.value().c_str(), 251 report->handle = HANDLE_EINTR(open(report->path.value().c_str(),
252 O_CREAT | O_WRONLY | O_EXCL | O_EXLOCK, 252 O_CREAT | O_WRONLY | O_EXCL | O_EXLOCK,
253 0600)); 253 0600));
254 if (report->handle < 0) { 254 if (report->handle < 0) {
255 PLOG(ERROR) << "open " << report->path.value(); 255 PLOG(ERROR) << "open " << report->path.value();
256 return kFileSystemError; 256 return kFileSystemError;
257 } 257 }
258 258
259 // TODO(rsesek): Potentially use an fsetxattr() here instead. 259 // TODO(rsesek): Potentially use an fsetxattr() here instead.
260 if (!WriteXattr(report->path, XattrName(kXattrUUID), uuid.ToString())) { 260 if (!WriteXattr(
261 report->path, XattrName(kXattrUUID), report->uuid.ToString())) {
261 PLOG_IF(ERROR, IGNORE_EINTR(close(report->handle)) != 0) << "close"; 262 PLOG_IF(ERROR, IGNORE_EINTR(close(report->handle)) != 0) << "close";
262 return kDatabaseError; 263 return kDatabaseError;
263 } 264 }
264 265
265 *out_report = report.release(); 266 *out_report = report.release();
266 267
267 return kNoError; 268 return kNoError;
268 } 269 }
269 270
270 CrashReportDatabase::OperationStatus 271 CrashReportDatabase::OperationStatus
(...skipping 10 matching lines...) Expand all
281 // Get the report's UUID to return. 282 // Get the report's UUID to return.
282 std::string uuid_string; 283 std::string uuid_string;
283 if (ReadXattr(report->path, XattrName(kXattrUUID), 284 if (ReadXattr(report->path, XattrName(kXattrUUID),
284 &uuid_string) != XattrStatus::kOK || 285 &uuid_string) != XattrStatus::kOK ||
285 !uuid->InitializeFromString(uuid_string)) { 286 !uuid->InitializeFromString(uuid_string)) {
286 LOG(ERROR) << "Failed to read UUID for crash report " 287 LOG(ERROR) << "Failed to read UUID for crash report "
287 << report->path.value(); 288 << report->path.value();
288 return kDatabaseError; 289 return kDatabaseError;
289 } 290 }
290 291
292 if (*uuid != report->uuid) {
293 LOG(ERROR) << "UUID mismatch for crash report " << report->path.value();
294 return kDatabaseError;
295 }
296
291 // Record the creation time of this report. 297 // Record the creation time of this report.
292 if (!WriteXattrTimeT(report->path, XattrName(kXattrCreationTime), 298 if (!WriteXattrTimeT(report->path, XattrName(kXattrCreationTime),
293 time(nullptr))) { 299 time(nullptr))) {
294 return kDatabaseError; 300 return kDatabaseError;
295 } 301 }
296 302
297 // Move the report to its new location for uploading. 303 // Move the report to its new location for uploading.
298 base::FilePath new_path = 304 base::FilePath new_path =
299 base_dir_.Append(kUploadPendingDirectory).Append(report->path.BaseName()); 305 base_dir_.Append(kUploadPendingDirectory).Append(report->path.BaseName());
300 if (rename(report->path.value().c_str(), new_path.value().c_str()) != 0) { 306 if (rename(report->path.value().c_str(), new_path.value().c_str()) != 0) {
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
596 const base::FilePath& path) { 602 const base::FilePath& path) {
597 scoped_ptr<CrashReportDatabaseMac> database_mac( 603 scoped_ptr<CrashReportDatabaseMac> database_mac(
598 new CrashReportDatabaseMac(path)); 604 new CrashReportDatabaseMac(path));
599 if (!database_mac->Initialize()) 605 if (!database_mac->Initialize())
600 database_mac.reset(); 606 database_mac.reset();
601 607
602 return scoped_ptr<CrashReportDatabase>(database_mac.release()); 608 return scoped_ptr<CrashReportDatabase>(database_mac.release());
603 } 609 }
604 610
605 } // namespace crashpad 611 } // namespace crashpad
OLDNEW
« no previous file with comments | « client/crash_report_database.h ('k') | client/crash_report_database_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698