Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(455)

Side by Side Diff: chrome/browser/crash_upload_list/crash_upload_list_crashpad.cc

Issue 2325713002: Manual crash uploads for mac and win (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 typedef void (*GetCrashReportsPointer)( 18 typedef void (*GetCrashReportsPointer)(
19 const crash_reporter::Report** reports, 19 const crash_reporter::Report** reports,
20 size_t* report_count); 20 size_t* report_count);
21 typedef void (*RequestSingleCrashUploadPointer)(const std::string& local_id);
21 22
22 void GetReportsThunk( 23 void GetReportsThunk(
23 std::vector<crash_reporter::Report>* reports) { 24 std::vector<crash_reporter::Report>* reports) {
24 static GetCrashReportsPointer get_crash_reports = []() { 25 static GetCrashReportsPointer get_crash_reports = []() {
25 // The crash reporting is handled by chrome_elf.dll which loads early in 26 // The crash reporting is handled by chrome_elf.dll which loads early in
26 // the chrome process. 27 // the chrome process.
27 HMODULE elf_module = GetModuleHandle(chrome::kChromeElfDllName); 28 HMODULE elf_module = GetModuleHandle(chrome::kChromeElfDllName);
28 return reinterpret_cast<GetCrashReportsPointer>( 29 return reinterpret_cast<GetCrashReportsPointer>(
29 elf_module ? GetProcAddress(elf_module, "GetCrashReportsImpl") 30 elf_module ? GetProcAddress(elf_module, "GetCrashReportsImpl")
30 : nullptr); 31 : nullptr);
31 }(); 32 }();
32 33
33 if (get_crash_reports) { 34 if (get_crash_reports) {
34 const crash_reporter::Report* reports_pointer; 35 const crash_reporter::Report* reports_pointer;
35 size_t report_count; 36 size_t report_count;
36 get_crash_reports(&reports_pointer, &report_count); 37 get_crash_reports(&reports_pointer, &report_count);
37 *reports = std::vector<crash_reporter::Report>( 38 *reports = std::vector<crash_reporter::Report>(
38 reports_pointer, reports_pointer + report_count); 39 reports_pointer, reports_pointer + report_count);
39 } 40 }
40 } 41 }
42
43 void RequestSingleCrashUploadThunk(const std::string& local_id) {
44 static RequestSingleCrashUploadPointer request_single_crash_upload = []() {
45 // The crash reporting is handled by chrome_elf.dll which loads early in
46 // the chrome process.
47 HMODULE elf_module = GetModuleHandle(chrome::kChromeElfDllName);
48 return reinterpret_cast<RequestSingleCrashUploadPointer>(
49 elf_module ? GetProcAddress(elf_module, "RequestSingleCrashUploadImpl")
50 : nullptr);
51 }();
52
53 if (request_single_crash_upload)
54 request_single_crash_upload(local_id);
55 }
56
41 #endif // OS_WIN 57 #endif // OS_WIN
42 58
43 UploadList::UploadInfo::State ReportUploadStateToUploadInfoState( 59 UploadList::UploadInfo::State ReportUploadStateToUploadInfoState(
44 crash_reporter::ReportUploadState state) { 60 crash_reporter::ReportUploadState state) {
45 switch (state) { 61 switch (state) {
46 case crash_reporter::ReportUploadState::NotUploaded: 62 case crash_reporter::ReportUploadState::NotUploaded:
47 return UploadList::UploadInfo::State::NotUploaded; 63 return UploadList::UploadInfo::State::NotUploaded;
48 64
49 case crash_reporter::ReportUploadState::Pending: 65 case crash_reporter::ReportUploadState::Pending:
50 return UploadList::UploadInfo::State::Pending; 66 return UploadList::UploadInfo::State::Pending;
51 67
68 case crash_reporter::ReportUploadState::Pending_UserRequested:
69 return UploadList::UploadInfo::State::Pending_UserRequested;
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;
54 } 73 }
55 74
56 NOTREACHED(); 75 NOTREACHED();
57 return UploadList::UploadInfo::State::Uploaded; 76 return UploadList::UploadInfo::State::Uploaded;
58 } 77 }
59 78
60 } // namespace 79 } // namespace
61 80
(...skipping 17 matching lines...) Expand all
79 crash_reporter::GetReports(&reports); 98 crash_reporter::GetReports(&reports);
80 #endif 99 #endif
81 100
82 for (const crash_reporter::Report& report : reports) { 101 for (const crash_reporter::Report& report : reports) {
83 uploads->push_back( 102 uploads->push_back(
84 UploadInfo(report.remote_id, base::Time::FromTimeT(report.upload_time), 103 UploadInfo(report.remote_id, base::Time::FromTimeT(report.upload_time),
85 report.local_id, base::Time::FromTimeT(report.capture_time), 104 report.local_id, base::Time::FromTimeT(report.capture_time),
86 ReportUploadStateToUploadInfoState(report.state))); 105 ReportUploadStateToUploadInfoState(report.state)));
87 } 106 }
88 } 107 }
108
109 void CrashUploadListCrashpad::RequestSingleCrashUpload(
110 const std::string& local_id) {
111 #if defined(OS_WIN)
112 // On Windows, crash reporting is handled by chrome_elf.dll, that's why we
113 // can't call crash_reporter::RequestSingleCrashUpload directly.
114 RequestSingleCrashUploadThunk(local_id);
115 #else
116 crash_reporter::RequestSingleCrashUpload(local_id);
117 #endif
118 }
OLDNEW
« no previous file with comments | « chrome/browser/crash_upload_list/crash_upload_list_crashpad.h ('k') | chrome/browser/ui/webui/crashes_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698