| OLD | NEW |
| 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 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 439 } | 439 } |
| 440 | 440 |
| 441 // Build the records and string table we're going to write. | 441 // Build the records and string table we're going to write. |
| 442 std::string string_table; | 442 std::string string_table; |
| 443 std::vector<MetadataFileReportRecord> records; | 443 std::vector<MetadataFileReportRecord> records; |
| 444 records.reserve(num_records); | 444 records.reserve(num_records); |
| 445 for (const auto& report : reports_) { | 445 for (const auto& report : reports_) { |
| 446 const base::FilePath& path = report.file_path; | 446 const base::FilePath& path = report.file_path; |
| 447 if (path.DirName() != report_dir_) { | 447 if (path.DirName() != report_dir_) { |
| 448 LOG(ERROR) << path.value().c_str() << " expected to start with " | 448 LOG(ERROR) << path.value().c_str() << " expected to start with " |
| 449 << report_dir_.value().c_str(); | 449 << base::UTF16ToUTF8(report_dir_.value()); |
| 450 return; | 450 return; |
| 451 } | 451 } |
| 452 records.push_back(MetadataFileReportRecord(report, &string_table)); | 452 records.push_back(MetadataFileReportRecord(report, &string_table)); |
| 453 } | 453 } |
| 454 | 454 |
| 455 if (!LoggingWriteFile(handle_.get(), | 455 if (!LoggingWriteFile(handle_.get(), |
| 456 &records[0], | 456 &records[0], |
| 457 records.size() * sizeof(MetadataFileReportRecord))) { | 457 records.size() * sizeof(MetadataFileReportRecord))) { |
| 458 LOG(ERROR) << "failed to write records"; | 458 LOG(ERROR) << "failed to write records"; |
| 459 return; | 459 return; |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 619 | 619 |
| 620 // Take ownership of the report. | 620 // Take ownership of the report. |
| 621 scoped_ptr<NewReport> scoped_report(report); | 621 scoped_ptr<NewReport> scoped_report(report); |
| 622 | 622 |
| 623 // Close the outstanding handle. | 623 // Close the outstanding handle. |
| 624 LoggingCloseFile(report->handle); | 624 LoggingCloseFile(report->handle); |
| 625 | 625 |
| 626 // We failed to write, so remove the dump file. There's no entry in the | 626 // We failed to write, so remove the dump file. There's no entry in the |
| 627 // metadata table yet. | 627 // metadata table yet. |
| 628 if (!DeleteFile(scoped_report->path.value().c_str())) { | 628 if (!DeleteFile(scoped_report->path.value().c_str())) { |
| 629 PLOG(ERROR) << "DeleteFile " << scoped_report->path.value().c_str(); | 629 PLOG(ERROR) << "DeleteFile " |
| 630 << base::UTF16ToUTF8(scoped_report->path.value()); |
| 630 return CrashReportDatabase::kFileSystemError; | 631 return CrashReportDatabase::kFileSystemError; |
| 631 } | 632 } |
| 632 | 633 |
| 633 return kNoError; | 634 return kNoError; |
| 634 } | 635 } |
| 635 | 636 |
| 636 OperationStatus CrashReportDatabaseWin::LookUpCrashReport(const UUID& uuid, | 637 OperationStatus CrashReportDatabaseWin::LookUpCrashReport(const UUID& uuid, |
| 637 Report* report) { | 638 Report* report) { |
| 638 INITIALIZATION_STATE_DCHECK_VALID(initialized_); | 639 INITIALIZATION_STATE_DCHECK_VALID(initialized_); |
| 639 | 640 |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 749 // static | 750 // static |
| 750 scoped_ptr<CrashReportDatabase> CrashReportDatabase::Initialize( | 751 scoped_ptr<CrashReportDatabase> CrashReportDatabase::Initialize( |
| 751 const base::FilePath& path) { | 752 const base::FilePath& path) { |
| 752 scoped_ptr<CrashReportDatabaseWin> database_win( | 753 scoped_ptr<CrashReportDatabaseWin> database_win( |
| 753 new CrashReportDatabaseWin(path)); | 754 new CrashReportDatabaseWin(path)); |
| 754 return database_win->Initialize() ? database_win.Pass() | 755 return database_win->Initialize() ? database_win.Pass() |
| 755 : scoped_ptr<CrashReportDatabaseWin>(); | 756 : scoped_ptr<CrashReportDatabaseWin>(); |
| 756 } | 757 } |
| 757 | 758 |
| 758 } // namespace crashpad | 759 } // namespace crashpad |
| OLD | NEW |