| 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 17 matching lines...) Expand all Loading... |
| 28 #include "base/mac/scoped_nsautorelease_pool.h" | 28 #include "base/mac/scoped_nsautorelease_pool.h" |
| 29 #include "base/posix/eintr_wrapper.h" | 29 #include "base/posix/eintr_wrapper.h" |
| 30 #include "base/scoped_generic.h" | 30 #include "base/scoped_generic.h" |
| 31 #include "base/strings/string_piece.h" | 31 #include "base/strings/string_piece.h" |
| 32 #include "base/strings/stringprintf.h" | 32 #include "base/strings/stringprintf.h" |
| 33 #include "base/strings/sys_string_conversions.h" | 33 #include "base/strings/sys_string_conversions.h" |
| 34 #include "client/settings.h" | 34 #include "client/settings.h" |
| 35 #include "util/file/file_io.h" | 35 #include "util/file/file_io.h" |
| 36 #include "util/mac/xattr.h" | 36 #include "util/mac/xattr.h" |
| 37 #include "util/misc/initialization_state_dcheck.h" | 37 #include "util/misc/initialization_state_dcheck.h" |
| 38 #include "util/misc/metrics.h" |
| 38 | 39 |
| 39 namespace crashpad { | 40 namespace crashpad { |
| 40 | 41 |
| 41 namespace { | 42 namespace { |
| 42 | 43 |
| 43 const char kWriteDirectory[] = "new"; | 44 const char kWriteDirectory[] = "new"; |
| 44 const char kUploadPendingDirectory[] = "pending"; | 45 const char kUploadPendingDirectory[] = "pending"; |
| 45 const char kCompletedDirectory[] = "completed"; | 46 const char kCompletedDirectory[] = "completed"; |
| 46 | 47 |
| 47 const char kSettings[] = "settings.dat"; | 48 const char kSettings[] = "settings.dat"; |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 | 352 |
| 352 // Move the report to its new location for uploading. | 353 // Move the report to its new location for uploading. |
| 353 base::FilePath new_path = | 354 base::FilePath new_path = |
| 354 base_dir_.Append(kUploadPendingDirectory).Append(report->path.BaseName()); | 355 base_dir_.Append(kUploadPendingDirectory).Append(report->path.BaseName()); |
| 355 if (rename(report->path.value().c_str(), new_path.value().c_str()) != 0) { | 356 if (rename(report->path.value().c_str(), new_path.value().c_str()) != 0) { |
| 356 PLOG(ERROR) << "rename " << report->path.value() << " to " | 357 PLOG(ERROR) << "rename " << report->path.value() << " to " |
| 357 << new_path.value(); | 358 << new_path.value(); |
| 358 return kFileSystemError; | 359 return kFileSystemError; |
| 359 } | 360 } |
| 360 | 361 |
| 362 Metrics::CrashReportSize(report->handle); |
| 363 |
| 361 return kNoError; | 364 return kNoError; |
| 362 } | 365 } |
| 363 | 366 |
| 364 CrashReportDatabase::OperationStatus | 367 CrashReportDatabase::OperationStatus |
| 365 CrashReportDatabaseMac::ErrorWritingCrashReport(NewReport* report) { | 368 CrashReportDatabaseMac::ErrorWritingCrashReport(NewReport* report) { |
| 366 INITIALIZATION_STATE_DCHECK_VALID(initialized_); | 369 INITIALIZATION_STATE_DCHECK_VALID(initialized_); |
| 367 | 370 |
| 368 // Takes ownership of the |handle| and the O_EXLOCK. | 371 // Takes ownership of the |handle| and the O_EXLOCK. |
| 369 base::ScopedFD lock(report->handle); | 372 base::ScopedFD lock(report->handle); |
| 370 | 373 |
| (...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 737 return InitializeInternal(path, true); | 740 return InitializeInternal(path, true); |
| 738 } | 741 } |
| 739 | 742 |
| 740 // static | 743 // static |
| 741 std::unique_ptr<CrashReportDatabase> | 744 std::unique_ptr<CrashReportDatabase> |
| 742 CrashReportDatabase::InitializeWithoutCreating(const base::FilePath& path) { | 745 CrashReportDatabase::InitializeWithoutCreating(const base::FilePath& path) { |
| 743 return InitializeInternal(path, false); | 746 return InitializeInternal(path, false); |
| 744 } | 747 } |
| 745 | 748 |
| 746 } // namespace crashpad | 749 } // namespace crashpad |
| OLD | NEW |