| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/crash/content/app/crashpad.h" | 5 #include "components/crash/content/app/crashpad.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <string.h> | 8 #include <string.h> |
| 9 | 9 |
| 10 #if BUILDFLAG(ENABLE_KASKO) | 10 #if BUILDFLAG(ENABLE_KASKO) |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 crashpad::Settings* settings = g_database->GetSettings(); | 262 crashpad::Settings* settings = g_database->GetSettings(); |
| 263 bool enable_uploads; | 263 bool enable_uploads; |
| 264 if (settings->GetUploadsEnabled(&enable_uploads)) { | 264 if (settings->GetUploadsEnabled(&enable_uploads)) { |
| 265 return enable_uploads; | 265 return enable_uploads; |
| 266 } | 266 } |
| 267 } | 267 } |
| 268 | 268 |
| 269 return false; | 269 return false; |
| 270 } | 270 } |
| 271 | 271 |
| 272 void GetUploadedReports(std::vector<UploadedReport>* uploaded_reports) { | 272 void GetReports(std::vector<Report>* reports) { |
| 273 uploaded_reports->clear(); | 273 reports->clear(); |
| 274 | 274 |
| 275 if (!g_database) { | 275 if (!g_database) { |
| 276 return; | 276 return; |
| 277 } | 277 } |
| 278 | 278 |
| 279 std::vector<crashpad::CrashReportDatabase::Report> completed_reports; | 279 std::vector<crashpad::CrashReportDatabase::Report> completed_reports; |
| 280 crashpad::CrashReportDatabase::OperationStatus status = | 280 crashpad::CrashReportDatabase::OperationStatus status = |
| 281 g_database->GetCompletedReports(&completed_reports); | 281 g_database->GetCompletedReports(&completed_reports); |
| 282 if (status != crashpad::CrashReportDatabase::kNoError) { | 282 if (status != crashpad::CrashReportDatabase::kNoError) { |
| 283 return; | 283 return; |
| 284 } | 284 } |
| 285 | 285 |
| 286 std::vector<crashpad::CrashReportDatabase::Report> pending_reports; |
| 287 status = g_database->GetPendingReports(&pending_reports); |
| 288 if (status != crashpad::CrashReportDatabase::kNoError) { |
| 289 return; |
| 290 } |
| 291 |
| 286 for (const crashpad::CrashReportDatabase::Report& completed_report : | 292 for (const crashpad::CrashReportDatabase::Report& completed_report : |
| 287 completed_reports) { | 293 completed_reports) { |
| 294 Report report; |
| 295 report.local_id = completed_report.uuid.ToString(); |
| 296 report.capture_time = completed_report.creation_time; |
| 297 report.remote_id = completed_report.id; |
| 288 if (completed_report.uploaded) { | 298 if (completed_report.uploaded) { |
| 289 UploadedReport uploaded_report; | 299 report.upload_time = completed_report.last_upload_attempt_time; |
| 290 uploaded_report.local_id = completed_report.uuid.ToString(); | 300 report.state = ReportUploadState::Uploaded; |
| 291 uploaded_report.remote_id = completed_report.id; | 301 } else { |
| 292 uploaded_report.creation_time = completed_report.creation_time; | 302 report.upload_time = 0; |
| 293 | 303 report.state = ReportUploadState::NotUploaded; |
| 294 uploaded_reports->push_back(uploaded_report); | |
| 295 } | 304 } |
| 305 reports->push_back(report); |
| 296 } | 306 } |
| 297 | 307 |
| 298 std::sort(uploaded_reports->begin(), uploaded_reports->end(), | 308 for (const crashpad::CrashReportDatabase::Report& pending_report : |
| 299 [](const UploadedReport& a, const UploadedReport& b) { | 309 pending_reports) { |
| 300 return a.creation_time > b.creation_time; | 310 Report report; |
| 311 report.local_id = pending_report.uuid.ToString(); |
| 312 report.capture_time = pending_report.creation_time; |
| 313 report.upload_time = 0; |
| 314 report.state = ReportUploadState::Pending; |
| 315 reports->push_back(report); |
| 316 } |
| 317 |
| 318 std::sort(reports->begin(), reports->end(), |
| 319 [](const Report& a, const Report& b) { |
| 320 return a.capture_time > b.capture_time; |
| 301 }); | 321 }); |
| 302 } | 322 } |
| 303 | 323 |
| 304 #if BUILDFLAG(ENABLE_KASKO) | 324 #if BUILDFLAG(ENABLE_KASKO) |
| 305 | 325 |
| 306 void GetCrashKeysForKasko(std::vector<kasko::api::CrashKey>* crash_keys) { | 326 void GetCrashKeysForKasko(std::vector<kasko::api::CrashKey>* crash_keys) { |
| 307 // Get the platform annotations. | 327 // Get the platform annotations. |
| 308 std::map<std::string, std::string> annotations; | 328 std::map<std::string, std::string> annotations; |
| 309 internal::GetPlatformCrashpadAnnotations(&annotations); | 329 internal::GetPlatformCrashpadAnnotations(&annotations); |
| 310 | 330 |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 base::UTF16ToUTF8(value)); | 425 base::UTF16ToUTF8(value)); |
| 406 } | 426 } |
| 407 | 427 |
| 408 void __declspec(dllexport) __cdecl ClearCrashKeyValueImpl(const wchar_t* key) { | 428 void __declspec(dllexport) __cdecl ClearCrashKeyValueImpl(const wchar_t* key) { |
| 409 crash_reporter::ClearCrashKey(base::UTF16ToUTF8(key)); | 429 crash_reporter::ClearCrashKey(base::UTF16ToUTF8(key)); |
| 410 } | 430 } |
| 411 | 431 |
| 412 } // extern "C" | 432 } // extern "C" |
| 413 | 433 |
| 414 #endif // OS_WIN | 434 #endif // OS_WIN |
| OLD | NEW |