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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 public: | 102 public: |
103 explicit CrashReportDatabaseMac(const base::FilePath& path); | 103 explicit CrashReportDatabaseMac(const base::FilePath& path); |
104 virtual ~CrashReportDatabaseMac(); | 104 virtual ~CrashReportDatabaseMac(); |
105 | 105 |
106 bool Initialize(); | 106 bool Initialize(); |
107 | 107 |
108 // CrashReportDatabase: | 108 // CrashReportDatabase: |
109 OperationStatus PrepareNewCrashReport(NewReport** report) override; | 109 OperationStatus PrepareNewCrashReport(NewReport** report) override; |
110 OperationStatus FinishedWritingCrashReport(NewReport* report, | 110 OperationStatus FinishedWritingCrashReport(NewReport* report, |
111 UUID* uuid) override; | 111 UUID* uuid) override; |
| 112 OperationStatus ErrorWritingCrashReport(NewReport* report) override; |
112 OperationStatus LookUpCrashReport(const UUID& uuid, | 113 OperationStatus LookUpCrashReport(const UUID& uuid, |
113 Report* report) override; | 114 Report* report) override; |
114 OperationStatus GetPendingReports( | 115 OperationStatus GetPendingReports( |
115 std::vector<const Report>* reports) override; | 116 std::vector<const Report>* reports) override; |
116 OperationStatus GetCompletedReports( | 117 OperationStatus GetCompletedReports( |
117 std::vector<const Report>* reports) override; | 118 std::vector<const Report>* reports) override; |
118 OperationStatus GetReportForUploading(const UUID& uuid, | 119 OperationStatus GetReportForUploading(const UUID& uuid, |
119 const Report** report) override; | 120 const Report** report) override; |
120 OperationStatus RecordUploadAttempt(const Report* report, | 121 OperationStatus RecordUploadAttempt(const Report* report, |
121 bool successful, | 122 bool successful, |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 if (rename(report->path.value().c_str(), new_path.value().c_str()) != 0) { | 274 if (rename(report->path.value().c_str(), new_path.value().c_str()) != 0) { |
274 PLOG(ERROR) << "rename " << report->path.value() << " to " | 275 PLOG(ERROR) << "rename " << report->path.value() << " to " |
275 << new_path.value(); | 276 << new_path.value(); |
276 return kFileSystemError; | 277 return kFileSystemError; |
277 } | 278 } |
278 | 279 |
279 return kNoError; | 280 return kNoError; |
280 } | 281 } |
281 | 282 |
282 CrashReportDatabase::OperationStatus | 283 CrashReportDatabase::OperationStatus |
| 284 CrashReportDatabaseMac::ErrorWritingCrashReport(NewReport* report) { |
| 285 // Takes ownership of the |handle| and the O_EXLOCK. |
| 286 base::ScopedFD lock(report->handle); |
| 287 |
| 288 // Take ownership of the report. |
| 289 scoped_ptr<NewReport> scoped_report(report); |
| 290 |
| 291 // Remove the file that the report would have been written to had no error |
| 292 // occurred. |
| 293 if (unlink(report->path.value().c_str()) != 0) { |
| 294 PLOG(ERROR) << "unlink " << report->path.value(); |
| 295 return kFileSystemError; |
| 296 } |
| 297 |
| 298 return kNoError; |
| 299 } |
| 300 |
| 301 CrashReportDatabase::OperationStatus |
283 CrashReportDatabaseMac::LookUpCrashReport(const UUID& uuid, | 302 CrashReportDatabaseMac::LookUpCrashReport(const UUID& uuid, |
284 CrashReportDatabase::Report* report) { | 303 CrashReportDatabase::Report* report) { |
285 base::FilePath path = LocateCrashReport(uuid); | 304 base::FilePath path = LocateCrashReport(uuid); |
286 if (path.empty()) | 305 if (path.empty()) |
287 return kReportNotFound; | 306 return kReportNotFound; |
288 | 307 |
289 base::ScopedFD lock(ObtainReportLock(path)); | 308 base::ScopedFD lock(ObtainReportLock(path)); |
290 if (!lock.is_valid()) | 309 if (!lock.is_valid()) |
291 return kBusyError; | 310 return kBusyError; |
292 | 311 |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
532 const base::FilePath& path) { | 551 const base::FilePath& path) { |
533 scoped_ptr<CrashReportDatabaseMac> database_mac( | 552 scoped_ptr<CrashReportDatabaseMac> database_mac( |
534 new CrashReportDatabaseMac(path.Append(kDatabaseDirectoryName))); | 553 new CrashReportDatabaseMac(path.Append(kDatabaseDirectoryName))); |
535 if (!database_mac->Initialize()) | 554 if (!database_mac->Initialize()) |
536 database_mac.reset(); | 555 database_mac.reset(); |
537 | 556 |
538 return scoped_ptr<CrashReportDatabase>(database_mac.release()); | 557 return scoped_ptr<CrashReportDatabase>(database_mac.release()); |
539 } | 558 } |
540 | 559 |
541 } // namespace crashpad | 560 } // namespace crashpad |
OLD | NEW |