1diff --git third_party/crashpad/crashpad/client/prune_crash_reports.cc third_party/crashpad/crashpad/client/prune_crash_reports.cc 2index 492d466239d1a..a1df635870ede 100644 3--- third_party/crashpad/crashpad/client/prune_crash_reports.cc 4+++ third_party/crashpad/crashpad/client/prune_crash_reports.cc 5@@ -73,13 +73,19 @@ size_t PruneCrashReportDatabase(CrashReportDatabase* database, 6 } 7 8 // static 9-std::unique_ptr<PruneCondition> PruneCondition::GetDefault() { 10+std::unique_ptr<PruneCondition> PruneCondition::GetDefault( 11+ int max_size_in_mb, 12+ int max_age_in_days) { 13 // DatabaseSizePruneCondition must be the LHS so that it is always evaluated, 14 // due to the short-circuting behavior of BinaryPruneCondition. 15+ if (max_size_in_mb <= 0) 16+ max_size_in_mb = 128; 17+ if (max_age_in_days <= 0) 18+ max_age_in_days = 365; 19 return std::make_unique<BinaryPruneCondition>( 20 BinaryPruneCondition::OR, 21- new DatabaseSizePruneCondition(1024 * 128), 22- new AgePruneCondition(365)); 23+ new DatabaseSizePruneCondition(1024 * max_size_in_mb), 24+ new AgePruneCondition(max_age_in_days)); 25 } 26 27 static const time_t kSecondsInDay = 60 * 60 * 24; 28diff --git third_party/crashpad/crashpad/client/prune_crash_reports.h third_party/crashpad/crashpad/client/prune_crash_reports.h 29index b80cf7a59103b..6318dd05e6eef 100644 30--- third_party/crashpad/crashpad/client/prune_crash_reports.h 31+++ third_party/crashpad/crashpad/client/prune_crash_reports.h 32@@ -58,7 +58,8 @@ class PruneCondition { 33 //! of 128 MB. 34 //! 35 //! \return A PruneCondition for use with PruneCrashReportDatabase(). 36- static std::unique_ptr<PruneCondition> GetDefault(); 37+ static std::unique_ptr<PruneCondition> GetDefault(int max_size_in_mb, 38+ int max_age_in_days); 39 40 virtual ~PruneCondition() {} 41 42diff --git third_party/crashpad/crashpad/client/settings.cc third_party/crashpad/crashpad/client/settings.cc 43index 966481d6284e4..e0fa8394cb045 100644 44--- third_party/crashpad/crashpad/client/settings.cc 45+++ third_party/crashpad/crashpad/client/settings.cc 46@@ -87,7 +87,7 @@ void ScopedLockedFileHandleTraits::Free(FileHandle handle) { 47 48 struct Settings::Data { 49 static constexpr uint32_t kSettingsMagic = 'CPds'; 50- static constexpr uint32_t kSettingsVersion = 1; 51+ static constexpr uint32_t kSettingsVersion = 2; 52 53 enum Options : uint32_t { 54 kUploadsEnabled = 1 << 0, 55@@ -98,6 +98,9 @@ struct Settings::Data { 56 options(0), 57 padding_0(0), 58 last_upload_attempt_time(0), 59+ next_upload_attempt_time(0), 60+ backoff_step(0), 61+ padding_1(0), 62 client_id() {} 63 64 uint32_t magic; 65@@ -105,6 +108,9 @@ struct Settings::Data { 66 uint32_t options; 67 uint32_t padding_0; 68 int64_t last_upload_attempt_time; // time_t 69+ int64_t next_upload_attempt_time; // time_t 70+ uint32_t backoff_step; 71+ uint32_t padding_1; 72 UUID client_id; 73 }; 74 75@@ -188,6 +194,56 @@ bool Settings::SetLastUploadAttemptTime(time_t time) { 76 return WriteSettings(handle.get(), settings); 77 } 78 79+bool Settings::GetNextUploadAttemptTime(time_t* time) { 80+ DCHECK(initialized_.is_valid()); 81+ 82+ Data settings; 83+ if (!OpenAndReadSettings(&settings)) 84+ return false; 85+ 86+ *time = InRangeCast<time_t>(settings.next_upload_attempt_time, 87+ std::numeric_limits<time_t>::max()); 88+ return true; 89+} 90+ 91+bool Settings::SetNextUploadAttemptTime(time_t time) { 92+ DCHECK(initialized_.is_valid()); 93+ 94+ Data settings; 95+ ScopedLockedFileHandle handle = OpenForWritingAndReadSettings(&settings); 96+ if (!handle.is_valid()) 97+ return false; 98+ 99+ settings.next_upload_attempt_time = InRangeCast<int64_t>(time, 0); 100+ 101+ return WriteSettings(handle.get(), settings); 102+} 103+ 104+bool Settings::GetBackoffStep(int* step) { 105+ DCHECK(initialized_.is_valid()); 106+ 107+ Data settings; 108+ if (!OpenAndReadSettings(&settings)) 109+ return false; 110+ 111+ *step = InRangeCast<int>(settings.backoff_step, 112+ std::numeric_limits<int>::max()); 113+ return true; 114+} 115+ 116+bool Settings::SetBackoffStep(int step) { 117+ DCHECK(initialized_.is_valid()); 118+ 119+ Data settings; 120+ ScopedLockedFileHandle handle = OpenForWritingAndReadSettings(&settings); 121+ if (!handle.is_valid()) 122+ return false; 123+ 124+ settings.backoff_step = InRangeCast<uint32_t>(step, 0); 125+ 126+ return WriteSettings(handle.get(), settings); 127+} 128+ 129 // static 130 Settings::ScopedLockedFileHandle Settings::MakeScopedLockedFileHandle( 131 FileHandle file, 132diff --git third_party/crashpad/crashpad/client/settings.h third_party/crashpad/crashpad/client/settings.h 133index e476c60c3ba6b..ce8256c9f6d25 100644 134--- third_party/crashpad/crashpad/client/settings.h 135+++ third_party/crashpad/crashpad/client/settings.h 136@@ -116,6 +116,11 @@ class Settings { 137 //! error logged. 138 bool SetLastUploadAttemptTime(time_t time); 139 140+ bool GetNextUploadAttemptTime(time_t* time); 141+ bool SetNextUploadAttemptTime(time_t time); 142+ bool GetBackoffStep(int* step); 143+ bool SetBackoffStep(int step); 144+ 145 private: 146 struct Data; 147 148diff --git third_party/crashpad/crashpad/handler/BUILD.gn third_party/crashpad/crashpad/handler/BUILD.gn 149index 0fe4760db7fe2..042af7247712c 100644 150--- third_party/crashpad/crashpad/handler/BUILD.gn 151+++ third_party/crashpad/crashpad/handler/BUILD.gn 152@@ -12,6 +12,7 @@ 153 # See the License for the specific language governing permissions and 154 # limitations under the License. 155 156+import("//cef/libcef/features/features.gni") 157 import("../build/crashpad_buildconfig.gni") 158 159 static_library("handler") { 160@@ -58,6 +59,17 @@ static_library("handler") { 161 ] 162 } 163 164+ if (enable_cef) { 165+ sources += [ 166+ "//cef/libcef/common/cef_crash_report_upload_thread.cc", 167+ "//cef/libcef/common/cef_crash_report_upload_thread.h", 168+ "//cef/libcef/common/cef_crash_report_utils.cc", 169+ "//cef/libcef/common/cef_crash_report_utils.h", 170+ ] 171+ 172+ configs += [ "//cef/libcef/features:config" ] 173+ } 174+ 175 public_configs = [ "..:crashpad_config" ] 176 177 public_deps = [ 178@@ -73,6 +85,7 @@ static_library("handler") { 179 "../snapshot", 180 "../third_party/mini_chromium:chromeos_buildflags", 181 "../tools:tool_support", 182+ "//cef/libcef/features", 183 ] 184 185 if (crashpad_is_win) { 186diff --git third_party/crashpad/crashpad/handler/crash_report_upload_thread.cc third_party/crashpad/crashpad/handler/crash_report_upload_thread.cc 187index c691361494b16..c2a2a9059c5ca 100644 188--- third_party/crashpad/crashpad/handler/crash_report_upload_thread.cc 189+++ third_party/crashpad/crashpad/handler/crash_report_upload_thread.cc 190@@ -261,6 +261,8 @@ CrashReportUploadThread::UploadResult CrashReportUploadThread::UploadReport( 191 if (minidump_process_snapshot.Initialize(reader)) { 192 parameters = 193 BreakpadHTTPFormParametersFromMinidump(&minidump_process_snapshot); 194+ if (!parameters.empty()) 195+ parameters = FilterParameters(parameters); 196 } 197 198 if (!reader->SeekSet(start_offset)) { 199diff --git third_party/crashpad/crashpad/handler/crash_report_upload_thread.h third_party/crashpad/crashpad/handler/crash_report_upload_thread.h 200index 70f1628354455..cd043a821e96d 100644 201--- third_party/crashpad/crashpad/handler/crash_report_upload_thread.h 202+++ third_party/crashpad/crashpad/handler/crash_report_upload_thread.h 203@@ -15,6 +15,7 @@ 204 #ifndef CRASHPAD_HANDLER_CRASH_REPORT_UPLOAD_THREAD_H_ 205 #define CRASHPAD_HANDLER_CRASH_REPORT_UPLOAD_THREAD_H_ 206 207+#include <map> 208 #include <memory> 209 #include <string> 210 #include <unordered_map> 211@@ -108,7 +109,7 @@ class CrashReportUploadThread : public WorkerThread::Delegate, 212 //! It is expected to only be called from the same thread that called Start(). 213 void Stop() override; 214 215- private: 216+ protected: 217 //! \brief The result code from UploadReport(). 218 enum class UploadResult { 219 //! \brief The crash report was uploaded successfully. 220@@ -136,7 +137,7 @@ class CrashReportUploadThread : public WorkerThread::Delegate, 221 //! object was constructed with \a watch_pending_reports, it will also scan 222 //! the crash report database for other pending reports, and process those as 223 //! well. 224- void ProcessPendingReports(); 225+ virtual void ProcessPendingReports(); 226 227 //! \brief Processes a single pending report from the database. 228 //! 229@@ -150,7 +151,7 @@ class CrashReportUploadThread : public WorkerThread::Delegate, 230 //! remain in the “pending” state. If the upload fails and no more retries are 231 //! desired, or report upload is disabled, it will be marked as “completed” in 232 //! the database without ever having been uploaded. 233- void ProcessPendingReport(const CrashReportDatabase::Report& report); 234+ virtual void ProcessPendingReport(const CrashReportDatabase::Report& report); 235 236 //! \brief Attempts to upload a crash report. 237 //! 238@@ -167,6 +168,11 @@ class CrashReportUploadThread : public WorkerThread::Delegate, 239 UploadResult UploadReport(const CrashReportDatabase::UploadReport* report, 240 std::string* response_body); 241 242+ using ParameterMap = std::map<std::string, std::string>; 243+ virtual ParameterMap FilterParameters(const ParameterMap& parameters) { 244+ return parameters; 245+ } 246+ 247 // WorkerThread::Delegate: 248 //! \brief Calls ProcessPendingReports() in response to ReportPending() having 249 //! been called on any thread, as well as periodically on a timer. 250diff --git third_party/crashpad/crashpad/handler/handler_main.cc third_party/crashpad/crashpad/handler/handler_main.cc 251index cb78aa1680aec..d50ddc7ae3c56 100644 252--- third_party/crashpad/crashpad/handler/handler_main.cc 253+++ third_party/crashpad/crashpad/handler/handler_main.cc 254@@ -38,6 +38,7 @@ 255 #include "base/strings/utf_string_conversions.h" 256 #include "build/build_config.h" 257 #include "build/chromeos_buildflags.h" 258+#include "cef/libcef/features/features.h" 259 #include "client/crash_report_database.h" 260 #include "client/crashpad_client.h" 261 #include "client/crashpad_info.h" 262@@ -88,6 +89,10 @@ 263 #include "util/win/session_end_watcher.h" 264 #endif // BUILDFLAG(IS_APPLE) 265 266+#if BUILDFLAG(ENABLE_CEF) 267+#include "cef/libcef/common/cef_crash_report_upload_thread.h" 268+#endif 269+ 270 namespace crashpad { 271 272 namespace { 273@@ -247,6 +252,9 @@ struct Options { 274 bool periodic_tasks; 275 bool rate_limit; 276 bool upload_gzip; 277+ int max_uploads; 278+ int max_database_size; 279+ int max_database_age; 280 #if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS) 281 bool use_cros_crash_reporter = false; 282 base::FilePath minidump_dir_for_tests; 283@@ -616,6 +624,9 @@ int HandlerMain(int argc, 284 kOptionTraceParentWithException, 285 #endif 286 kOptionURL, 287+ kOptionMaxUploads, 288+ kOptionMaxDatabaseSize, 289+ kOptionMaxDatabaseAge, 290 #if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS) 291 kOptionUseCrosCrashReporter, 292 kOptionMinidumpDirForTests, 293@@ -716,6 +727,9 @@ int HandlerMain(int argc, 294 #endif // BUILDFLAG(IS_ANDROID) 295 {"help", no_argument, nullptr, kOptionHelp}, 296 {"version", no_argument, nullptr, kOptionVersion}, 297+ {"max-uploads", required_argument, nullptr, kOptionMaxUploads}, 298+ {"max-db-size", required_argument, nullptr, kOptionMaxDatabaseSize}, 299+ {"max-db-age", required_argument, nullptr, kOptionMaxDatabaseAge}, 300 {nullptr, 0, nullptr, 0}, 301 }; 302 303@@ -873,6 +887,27 @@ int HandlerMain(int argc, 304 options.url = optarg; 305 break; 306 } 307+ case kOptionMaxUploads: { 308+ if (base::StringToInt(optarg, &options.max_uploads)) { 309+ if (options.max_uploads < 0) 310+ options.max_uploads = 0; 311+ } 312+ break; 313+ } 314+ case kOptionMaxDatabaseSize: { 315+ if (base::StringToInt(optarg, &options.max_database_size)) { 316+ if (options.max_database_size < 0) 317+ options.max_database_size = 0; 318+ } 319+ break; 320+ } 321+ case kOptionMaxDatabaseAge: { 322+ if (base::StringToInt(optarg, &options.max_database_age)) { 323+ if (options.max_database_age < 0) 324+ options.max_database_age = 0; 325+ } 326+ break; 327+ } 328 #if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS) 329 case kOptionUseCrosCrashReporter: { 330 options.use_cros_crash_reporter = true; 331@@ -1022,8 +1057,14 @@ int HandlerMain(int argc, 332 upload_thread_options.upload_gzip = options.upload_gzip; 333 upload_thread_options.watch_pending_reports = options.periodic_tasks; 334 335+#if BUILDFLAG(ENABLE_CEF) 336+ upload_thread.Reset(new CefCrashReportUploadThread( 337+ database.get(), options.url, upload_thread_options, 338+ options.max_uploads)); 339+#else 340 upload_thread.Reset(new CrashReportUploadThread( 341 database.get(), options.url, upload_thread_options)); 342+#endif 343 upload_thread.Get()->Start(); 344 } 345 346@@ -1094,7 +1135,8 @@ int HandlerMain(int argc, 347 ScopedStoppable prune_thread; 348 if (options.periodic_tasks) { 349 prune_thread.Reset(new PruneCrashReportThread( 350- database.get(), PruneCondition::GetDefault())); 351+ database.get(), PruneCondition::GetDefault(options.max_database_size, 352+ options.max_database_age))); 353 prune_thread.Get()->Start(); 354 } 355 356