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/crash_upload_list_crashpad.h" | 5 #include "chrome/browser/crash_upload_list/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 // The name of the function used for reuqesting single crash upload through | |
| 19 // chrome_elf dll. | |
|
jwd
2016/08/24 15:09:20
Can you mention where the function is located too
gayane -on leave until 09-2017
2016/08/24 23:12:34
Done.
| |
| 20 const char kRequestSingleCrashUploadFunc[] = "RequestSingleCrashUploadImpl"; | |
| 21 | |
| 18 typedef void (*GetCrashReportsPointer)( | 22 typedef void (*GetCrashReportsPointer)( |
| 19 const crash_reporter::Report** reports, | 23 const crash_reporter::Report** reports, |
| 20 size_t* report_count); | 24 size_t* report_count); |
| 21 | 25 |
| 22 void GetReportsThunk( | 26 void GetReportsThunk( |
| 23 std::vector<crash_reporter::Report>* reports) { | 27 std::vector<crash_reporter::Report>* reports) { |
| 24 static GetCrashReportsPointer get_crash_reports = []() { | 28 static GetCrashReportsPointer get_crash_reports = []() { |
| 25 // The crash reporting is handled by chrome_elf.dll which loads early in | 29 // The crash reporting is handled by chrome_elf.dll which loads early in |
| 26 // the chrome process. | 30 // the chrome process. |
| 27 HMODULE elf_module = GetModuleHandle(chrome::kChromeElfDllName); | 31 HMODULE elf_module = GetModuleHandle(chrome::kChromeElfDllName); |
| 28 return reinterpret_cast<GetCrashReportsPointer>( | 32 return reinterpret_cast<GetCrashReportsPointer>( |
| 29 elf_module ? GetProcAddress(elf_module, "GetCrashReportsImpl") | 33 elf_module ? GetProcAddress(elf_module, "GetCrashReportsImpl") |
| 30 : nullptr); | 34 : nullptr); |
| 31 }(); | 35 }(); |
| 32 | 36 |
| 33 if (get_crash_reports) { | 37 if (get_crash_reports) { |
| 34 const crash_reporter::Report* reports_pointer; | 38 const crash_reporter::Report* reports_pointer; |
| 35 size_t report_count; | 39 size_t report_count; |
| 36 get_crash_reports(&reports_pointer, &report_count); | 40 get_crash_reports(&reports_pointer, &report_count); |
| 37 *reports = std::vector<crash_reporter::Report>( | 41 *reports = std::vector<crash_reporter::Report>( |
| 38 reports_pointer, reports_pointer + report_count); | 42 reports_pointer, reports_pointer + report_count); |
| 39 } | 43 } |
| 40 } | 44 } |
| 45 | |
| 46 void RequestSingleCrashUploadThunk(const std::string& local_id) { | |
| 47 // The crash reporting is handled by chrome_elf.dll which loads early in | |
| 48 // the chrome process. | |
| 49 HMODULE elf_module = GetModuleHandle(chrome::kChromeElfDllName); | |
| 50 if (elf_module) { | |
| 51 static RequestSingleCrashUploadPointer request_single_crash_upload = | |
| 52 reinterpret_cast<RequestSingleCrashUploadPointer>( | |
| 53 GetProcAddress(elf_module, kRequestSingleCrashUploadFunc); | |
| 54 | |
| 55 if (request_single_crash_upload) | |
| 56 request_single_crash_upload(local_id); | |
| 57 } | |
| 58 } | |
| 59 | |
| 41 #endif // OS_WIN | 60 #endif // OS_WIN |
| 42 | 61 |
| 43 UploadList::UploadInfo::State ReportUploadStateToUploadInfoState( | 62 UploadList::UploadInfo::State ReportUploadStateToUploadInfoState( |
| 44 crash_reporter::ReportUploadState state) { | 63 crash_reporter::ReportUploadState state) { |
| 45 switch (state) { | 64 switch (state) { |
| 46 case crash_reporter::ReportUploadState::NotUploaded: | 65 case crash_reporter::ReportUploadState::NotUploaded: |
| 47 return UploadList::UploadInfo::State::NotUploaded; | 66 return UploadList::UploadInfo::State::NotUploaded; |
| 48 | 67 |
| 49 case crash_reporter::ReportUploadState::Pending: | 68 case crash_reporter::ReportUploadState::Pending: |
| 50 return UploadList::UploadInfo::State::Pending; | 69 return UploadList::UploadInfo::State::Pending; |
| 51 | 70 |
| 52 case crash_reporter::ReportUploadState::Uploaded: | 71 case crash_reporter::ReportUploadState::Uploaded: |
| 53 return UploadList::UploadInfo::State::Uploaded; | 72 return UploadList::UploadInfo::State::Uploaded; |
| 73 | |
| 74 case crash_reporter::ReportUploadState::UserRequested: | |
| 75 return UploadList::UploadInfo::State::UserRequested; | |
| 54 } | 76 } |
| 55 | 77 |
| 56 NOTREACHED(); | 78 NOTREACHED(); |
| 57 return UploadList::UploadInfo::State::Uploaded; | 79 return UploadList::UploadInfo::State::Uploaded; |
| 58 } | 80 } |
| 59 | 81 |
| 60 } // namespace | 82 } // namespace |
| 61 | 83 |
| 62 CrashUploadListCrashpad::CrashUploadListCrashpad( | 84 CrashUploadListCrashpad::CrashUploadListCrashpad( |
| 63 Delegate* delegate, | 85 Delegate* delegate, |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 79 crash_reporter::GetReports(&reports); | 101 crash_reporter::GetReports(&reports); |
| 80 #endif | 102 #endif |
| 81 | 103 |
| 82 for (const crash_reporter::Report& report : reports) { | 104 for (const crash_reporter::Report& report : reports) { |
| 83 uploads->push_back( | 105 uploads->push_back( |
| 84 UploadInfo(report.remote_id, base::Time::FromTimeT(report.upload_time), | 106 UploadInfo(report.remote_id, base::Time::FromTimeT(report.upload_time), |
| 85 report.local_id, base::Time::FromTimeT(report.capture_time), | 107 report.local_id, base::Time::FromTimeT(report.capture_time), |
| 86 ReportUploadStateToUploadInfoState(report.state))); | 108 ReportUploadStateToUploadInfoState(report.state))); |
| 87 } | 109 } |
| 88 } | 110 } |
| 111 | |
| 112 void CrashUploadListCrashpad::RequestSingleCrashUpload( | |
| 113 const std::string& local_id) { | |
| 114 #if defined(OS_WIN) | |
| 115 // On Windows, crash reporting is handled by chrome_elf.dll, thats why we | |
| 116 // can't call crash_reporter::RequestSingleCrashUpload directly. | |
| 117 RequestSingleCrashUploadThunk(local_id); | |
| 118 #else | |
| 119 crash_reporter::RequestSingleCrashUpload(local_id); | |
| 120 #endif | |
| 121 } | |
| OLD | NEW |