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 555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
566 contentsOfDirectoryAtPath:base::SysUTF8ToNSString(path.value()) | 566 contentsOfDirectoryAtPath:base::SysUTF8ToNSString(path.value()) |
567 error:&error]; | 567 error:&error]; |
568 if (error) { | 568 if (error) { |
569 LOG(ERROR) << "Failed to enumerate reports in directory " << path.value() | 569 LOG(ERROR) << "Failed to enumerate reports in directory " << path.value() |
570 << ": " << [[error description] UTF8String]; | 570 << ": " << [[error description] UTF8String]; |
571 return kFileSystemError; | 571 return kFileSystemError; |
572 } | 572 } |
573 | 573 |
574 reports->reserve([paths count]); | 574 reports->reserve([paths count]); |
575 for (NSString* entry in paths) { | 575 for (NSString* entry in paths) { |
576 base::FilePath report_path = path.Append([entry fileSystemRepresentation]); | 576 Report report; |
577 base::ScopedFD lock(ObtainReportLock(report_path)); | 577 report.file_path = path.Append([entry fileSystemRepresentation]); |
| 578 base::ScopedFD lock(ObtainReportLock(report.file_path)); |
578 if (!lock.is_valid()) | 579 if (!lock.is_valid()) |
579 continue; | 580 continue; |
580 | 581 |
581 Report report; | 582 if (!ReadReportMetadataLocked(report.file_path, &report)) { |
582 if (!ReadReportMetadataLocked(report_path, &report)) { | |
583 LOG(WARNING) << "Failed to read report metadata for " | 583 LOG(WARNING) << "Failed to read report metadata for " |
584 << report_path.value(); | 584 << report.file_path.value(); |
585 continue; | 585 continue; |
586 } | 586 } |
587 reports->push_back(report); | 587 reports->push_back(report); |
588 } | 588 } |
589 | 589 |
590 return kNoError; | 590 return kNoError; |
591 } | 591 } |
592 | 592 |
593 // static | 593 // static |
594 std::string CrashReportDatabaseMac::XattrName(const base::StringPiece& name) { | 594 std::string CrashReportDatabaseMac::XattrName(const base::StringPiece& name) { |
595 return base::StringPrintf("com.googlecode.crashpad.%s", name.data()); | 595 return base::StringPrintf("com.googlecode.crashpad.%s", name.data()); |
596 } | 596 } |
597 | 597 |
598 } // namespace | 598 } // namespace |
599 | 599 |
600 // static | 600 // static |
601 scoped_ptr<CrashReportDatabase> CrashReportDatabase::Initialize( | 601 scoped_ptr<CrashReportDatabase> CrashReportDatabase::Initialize( |
602 const base::FilePath& path) { | 602 const base::FilePath& path) { |
603 scoped_ptr<CrashReportDatabaseMac> database_mac( | 603 scoped_ptr<CrashReportDatabaseMac> database_mac( |
604 new CrashReportDatabaseMac(path)); | 604 new CrashReportDatabaseMac(path)); |
605 if (!database_mac->Initialize()) | 605 if (!database_mac->Initialize()) |
606 database_mac.reset(); | 606 database_mac.reset(); |
607 | 607 |
608 return scoped_ptr<CrashReportDatabase>(database_mac.release()); | 608 return scoped_ptr<CrashReportDatabase>(database_mac.release()); |
609 } | 609 } |
610 | 610 |
611 } // namespace crashpad | 611 } // namespace crashpad |
OLD | NEW |