| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/crash_upload_list_crashpad.h" | |
| 6 | |
| 7 #include <stddef.h> | |
| 8 | |
| 9 #include "base/threading/sequenced_worker_pool.h" | |
| 10 #include "base/time/time.h" | |
| 11 #include "build/build_config.h" | |
| 12 #include "chrome/common/chrome_constants.h" | |
| 13 #include "components/crash/content/app/crashpad.h" | |
| 14 | |
| 15 namespace { | |
| 16 | |
| 17 #if defined(OS_WIN) | |
| 18 typedef void (*GetCrashReportsPointer)( | |
| 19 const crash_reporter::Report** reports, | |
| 20 size_t* report_count); | |
| 21 | |
| 22 void GetReportsThunk( | |
| 23 std::vector<crash_reporter::Report>* reports) { | |
| 24 static GetCrashReportsPointer get_crash_reports = []() { | |
| 25 HMODULE exe_module = GetModuleHandle(chrome::kBrowserProcessExecutableName); | |
| 26 return reinterpret_cast<GetCrashReportsPointer>( | |
| 27 exe_module ? GetProcAddress(exe_module, "GetCrashReportsImpl") | |
| 28 : nullptr); | |
| 29 }(); | |
| 30 | |
| 31 if (get_crash_reports) { | |
| 32 const crash_reporter::Report* reports_pointer; | |
| 33 size_t report_count; | |
| 34 get_crash_reports(&reports_pointer, &report_count); | |
| 35 *reports = std::vector<crash_reporter::Report>( | |
| 36 reports_pointer, reports_pointer + report_count); | |
| 37 } | |
| 38 } | |
| 39 #endif // OS_WIN | |
| 40 | |
| 41 UploadList::UploadInfo::State ReportUploadStateToUploadInfoState( | |
| 42 crash_reporter::ReportUploadState state) { | |
| 43 switch (state) { | |
| 44 case crash_reporter::ReportUploadState::NotUploaded: | |
| 45 return UploadList::UploadInfo::State::NotUploaded; | |
| 46 | |
| 47 case crash_reporter::ReportUploadState::Pending: | |
| 48 return UploadList::UploadInfo::State::Pending; | |
| 49 | |
| 50 case crash_reporter::ReportUploadState::Uploaded: | |
| 51 return UploadList::UploadInfo::State::Uploaded; | |
| 52 } | |
| 53 | |
| 54 NOTREACHED(); | |
| 55 return UploadList::UploadInfo::State::Uploaded; | |
| 56 } | |
| 57 | |
| 58 } // namespace | |
| 59 | |
| 60 CrashUploadListCrashpad::CrashUploadListCrashpad( | |
| 61 Delegate* delegate, | |
| 62 const scoped_refptr<base::SequencedWorkerPool>& worker_pool) | |
| 63 : CrashUploadList(delegate, base::FilePath(), worker_pool) {} | |
| 64 | |
| 65 CrashUploadListCrashpad::~CrashUploadListCrashpad() {} | |
| 66 | |
| 67 void CrashUploadListCrashpad::LoadUploadList( | |
| 68 std::vector<UploadList::UploadInfo>* uploads) { | |
| 69 std::vector<crash_reporter::Report> reports; | |
| 70 #if defined(OS_WIN) | |
| 71 // On Windows, we only link crash client into chrome.exe (not the dlls), and | |
| 72 // it does the registration. That means the global that holds the crash report | |
| 73 // database lives in the .exe, so we need to grab a pointer to a helper in the | |
| 74 // exe to get our reports list. | |
| 75 GetReportsThunk(&reports); | |
| 76 #else | |
| 77 crash_reporter::GetReports(&reports); | |
| 78 #endif | |
| 79 | |
| 80 for (const crash_reporter::Report& report : reports) { | |
| 81 uploads->push_back( | |
| 82 UploadInfo(report.remote_id, base::Time::FromTimeT(report.upload_time), | |
| 83 report.local_id, base::Time::FromTimeT(report.capture_time), | |
| 84 ReportUploadStateToUploadInfoState(report.state))); | |
| 85 } | |
| 86 } | |
| OLD | NEW |