Chromium Code Reviews| 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 "chrome/browser/crash_upload_list_crashpad.h" | 5 #include "chrome/browser/crash_upload_list_crashpad.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/threading/sequenced_worker_pool.h" | 9 #include "base/threading/sequenced_worker_pool.h" |
| 10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
| 11 #include "build/build_config.h" | 11 #include "build/build_config.h" |
| 12 #include "chrome/common/chrome_constants.h" | 12 #include "chrome/common/chrome_constants.h" |
| 13 #include "components/crash/content/app/crashpad.h" | 13 #include "components/crash/content/app/crashpad.h" |
| 14 | 14 |
| 15 namespace { | 15 namespace { |
| 16 | 16 |
| 17 #if defined(OS_WIN) | 17 #if defined(OS_WIN) |
| 18 typedef void (*GetUploadedReportsPointer)( | 18 typedef void (*GetCrashReportsPointer)( |
| 19 const crash_reporter::UploadedReport** reports, | 19 const crash_reporter::Report** reports, |
|
grt (UTC plus 2)
2016/06/20 23:26:08
const betwixt the two stars? The caller of this sh
scottmg
2016/06/21 00:06:30
My const placement cdecl skillz are crud, but does
grt (UTC plus 2)
2016/06/21 01:32:50
Ooops, you're right. I was thinking that the other
| |
| 20 size_t* report_count); | 20 size_t* report_count); |
| 21 | 21 |
| 22 void GetUploadedReportsThunk( | 22 void GetReportsThunk( |
| 23 std::vector<crash_reporter::UploadedReport>* uploaded_reports) { | 23 std::vector<crash_reporter::Report>* reports) { |
| 24 static GetUploadedReportsPointer get_uploaded_reports = []() { | 24 static GetCrashReportsPointer get_crash_reports = []() { |
| 25 HMODULE exe_module = GetModuleHandle(chrome::kBrowserProcessExecutableName); | 25 HMODULE exe_module = GetModuleHandle(chrome::kBrowserProcessExecutableName); |
| 26 return reinterpret_cast<GetUploadedReportsPointer>( | 26 return reinterpret_cast<GetCrashReportsPointer>( |
| 27 exe_module ? GetProcAddress(exe_module, "GetUploadedReportsImpl") | 27 exe_module ? GetProcAddress(exe_module, "GetCrashReportsImpl") |
| 28 : nullptr); | 28 : nullptr); |
| 29 }(); | 29 }(); |
| 30 | 30 |
| 31 if (get_uploaded_reports) { | 31 if (get_crash_reports) { |
|
grt (UTC plus 2)
2016/06/20 23:26:08
I don't follow this. Apologies if this is a an uni
scottmg
2016/06/21 00:06:29
Just once; the sneaky part is the () after the clo
grt (UTC plus 2)
2016/06/21 01:32:50
Ah, very clever indeed. I shouldn't review on phon
| |
| 32 const crash_reporter::UploadedReport* reports; | 32 const crash_reporter::Report* reports_pointer; |
| 33 size_t report_count; | 33 size_t report_count; |
| 34 get_uploaded_reports(&reports, &report_count); | 34 get_crash_reports(&reports_pointer, &report_count); |
| 35 *uploaded_reports = std::vector<crash_reporter::UploadedReport>( | 35 *reports = std::vector<crash_reporter::Report>( |
| 36 reports, reports + report_count); | 36 reports_pointer, reports_pointer + report_count); |
| 37 } | 37 } |
| 38 } | 38 } |
| 39 #endif // OS_WIN | 39 #endif // OS_WIN |
| 40 | 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; | |
|
Lei Zhang
2016/06/20 21:49:30
Shouldn't our compilers know all the enum values a
scottmg
2016/06/20 22:00:50
No such luck. https://codereview.chromium.org/2070
| |
| 56 } | |
| 57 | |
| 41 } // namespace | 58 } // namespace |
| 42 | 59 |
| 43 CrashUploadListCrashpad::CrashUploadListCrashpad( | 60 CrashUploadListCrashpad::CrashUploadListCrashpad( |
| 44 Delegate* delegate, | 61 Delegate* delegate, |
| 45 const scoped_refptr<base::SequencedWorkerPool>& worker_pool) | 62 const scoped_refptr<base::SequencedWorkerPool>& worker_pool) |
| 46 : CrashUploadList(delegate, base::FilePath(), worker_pool) {} | 63 : CrashUploadList(delegate, base::FilePath(), worker_pool) {} |
| 47 | 64 |
| 48 CrashUploadListCrashpad::~CrashUploadListCrashpad() {} | 65 CrashUploadListCrashpad::~CrashUploadListCrashpad() {} |
| 49 | 66 |
| 50 void CrashUploadListCrashpad::LoadUploadList( | 67 void CrashUploadListCrashpad::LoadUploadList( |
| 51 std::vector<UploadList::UploadInfo>* uploads) { | 68 std::vector<UploadList::UploadInfo>* uploads) { |
| 52 std::vector<crash_reporter::UploadedReport> uploaded_reports; | 69 std::vector<crash_reporter::Report> reports; |
| 53 #if defined(OS_WIN) | 70 #if defined(OS_WIN) |
| 54 // On Windows, we only link crash client into chrome.exe (not the dlls), and | 71 // On Windows, we only link crash client into chrome.exe (not the dlls), and |
| 55 // it does the registration. That means the global that holds the crash report | 72 // it does the registration. That means the global that holds the crash report |
| 56 // database lives in the .exe, so we need to grab a pointer to a helper in the | 73 // database lives in the .exe, so we need to grab a pointer to a helper in the |
| 57 // exe to get our uploaded reports list. | 74 // exe to get our reports list. |
| 58 GetUploadedReportsThunk(&uploaded_reports); | 75 GetReportsThunk(&reports); |
| 59 #else | 76 #else |
| 60 crash_reporter::GetUploadedReports(&uploaded_reports); | 77 crash_reporter::GetReports(&reports); |
| 61 #endif | 78 #endif |
| 62 | 79 |
| 63 for (const crash_reporter::UploadedReport& uploaded_report : | 80 for (const crash_reporter::Report& report : reports) { |
| 64 uploaded_reports) { | |
| 65 uploads->push_back( | 81 uploads->push_back( |
| 66 UploadInfo(uploaded_report.remote_id, | 82 UploadInfo(report.remote_id, base::Time::FromTimeT(report.upload_time), |
| 67 base::Time::FromTimeT(uploaded_report.creation_time), | 83 report.local_id, base::Time::FromTimeT(report.capture_time), |
| 68 uploaded_report.local_id, base::Time())); | 84 ReportUploadStateToUploadInfoState(report.state))); |
| 69 } | 85 } |
| 70 } | 86 } |
| OLD | NEW |