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

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

Issue 2070993002: List all crashes in chrome://crashes, including those not uploaded (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixes Created 4 years, 6 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_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,
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) {
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
Mark Mentovai 2016/06/20 21:14:56 Lose the blank line.
scottmg 2016/06/20 21:20:05 Done.
45 case crash_reporter::ReportUploadState::NotUploaded:
46 return UploadList::UploadInfo::State::NotUploaded;
47
48 case crash_reporter::ReportUploadState::Pending:
49 return UploadList::UploadInfo::State::Pending;
50
51 case crash_reporter::ReportUploadState::Uploaded:
52 return UploadList::UploadInfo::State::Uploaded;
53 }
54
55 NOTREACHED();
56 return UploadList::UploadInfo::State::Uploaded;
57 }
58
41 } // namespace 59 } // namespace
42 60
43 CrashUploadListCrashpad::CrashUploadListCrashpad( 61 CrashUploadListCrashpad::CrashUploadListCrashpad(
44 Delegate* delegate, 62 Delegate* delegate,
45 const scoped_refptr<base::SequencedWorkerPool>& worker_pool) 63 const scoped_refptr<base::SequencedWorkerPool>& worker_pool)
46 : CrashUploadList(delegate, base::FilePath(), worker_pool) {} 64 : CrashUploadList(delegate, base::FilePath(), worker_pool) {}
47 65
48 CrashUploadListCrashpad::~CrashUploadListCrashpad() {} 66 CrashUploadListCrashpad::~CrashUploadListCrashpad() {}
49 67
50 void CrashUploadListCrashpad::LoadUploadList( 68 void CrashUploadListCrashpad::LoadUploadList(
51 std::vector<UploadList::UploadInfo>* uploads) { 69 std::vector<UploadList::UploadInfo>* uploads) {
52 std::vector<crash_reporter::UploadedReport> uploaded_reports; 70 std::vector<crash_reporter::Report> reports;
53 #if defined(OS_WIN) 71 #if defined(OS_WIN)
54 // On Windows, we only link crash client into chrome.exe (not the dlls), and 72 // 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 73 // 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 74 // 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. 75 // exe to get our reports list.
58 GetUploadedReportsThunk(&uploaded_reports); 76 GetReportsThunk(&reports);
59 #else 77 #else
60 crash_reporter::GetUploadedReports(&uploaded_reports); 78 crash_reporter::GetReports(&reports);
61 #endif 79 #endif
62 80
63 for (const crash_reporter::UploadedReport& uploaded_report : 81 for (const crash_reporter::Report& report : reports) {
64 uploaded_reports) {
65 uploads->push_back( 82 uploads->push_back(
66 UploadInfo(uploaded_report.remote_id, 83 UploadInfo(report.remote_id, base::Time::FromTimeT(report.upload_time),
67 base::Time::FromTimeT(uploaded_report.creation_time), 84 report.local_id, base::Time::FromTimeT(report.capture_time),
68 uploaded_report.local_id, base::Time())); 85 ReportUploadStateToUploadInfoState(report.state)));
69 } 86 }
70 } 87 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698