From 66179c9b6c585e6de3c2ddefd97c5d88b74802de Mon Sep 17 00:00:00 2001 From: Ying Yu Date: Wed, 29 Jan 2025 14:32:57 -0800 Subject: [PATCH] Add a web API clearCrashpadDatabase This API will be used in crashpad handler test to clear up the previous states to work around the upload throttling that causes the tests to fail frequently for partner certification. b/332895679 Change-Id: I0b104a64dbd156de6df817800c972042e810e654 --- cobalt/h5vcc/h5vcc_storage.cc | 11 +++++++++++ cobalt/h5vcc/h5vcc_storage.h | 2 ++ cobalt/h5vcc/h5vcc_storage.idl | 3 +++ 3 files changed, 16 insertions(+) diff --git a/cobalt/h5vcc/h5vcc_storage.cc b/cobalt/h5vcc/h5vcc_storage.cc index 9b6c095b8845..fb6ba6e9b739 100644 --- a/cobalt/h5vcc/h5vcc_storage.cc +++ b/cobalt/h5vcc/h5vcc_storage.cc @@ -38,6 +38,8 @@ namespace h5vcc { namespace { +const char kCrashpadDBName[] = "crashpad_database"; + const char kTestFileName[] = "cache_test_file.json"; const uint32 kBufferSize = 16384; // 16 KB @@ -429,6 +431,15 @@ void H5vccStorage::ClearServiceWorkerCache() { base::DeleteFile(service_worker_file_path); } +void H5vccStorage::ClearCrashpadDatabase() { + std::vector cache_dir(kSbFileMaxPath + 1, 0); + SbSystemGetPath(kSbSystemPathCacheDirectory, cache_dir.data(), + kSbFileMaxPath); + base::FilePath crashpad_db_dir = + base::FilePath(cache_dir.data()).Append(kCrashpadDBName); + ClearDirectory(crashpad_db_dir); +} + bool H5vccStorage::ValidatedCacheBackend() { if (!http_cache_) { return false; diff --git a/cobalt/h5vcc/h5vcc_storage.h b/cobalt/h5vcc/h5vcc_storage.h index ae1569e86709..36622442504d 100644 --- a/cobalt/h5vcc/h5vcc_storage.h +++ b/cobalt/h5vcc/h5vcc_storage.h @@ -71,6 +71,8 @@ class H5vccStorage : public script::Wrappable { void ClearServiceWorkerCache(); + void ClearCrashpadDatabase(); + DEFINE_WRAPPABLE_TYPE(H5vccStorage); private: diff --git a/cobalt/h5vcc/h5vcc_storage.idl b/cobalt/h5vcc/h5vcc_storage.idl index 9d4b1aadad24..0815bd8f0b51 100644 --- a/cobalt/h5vcc/h5vcc_storage.idl +++ b/cobalt/h5vcc/h5vcc_storage.idl @@ -31,4 +31,7 @@ interface H5vccStorage { void clearCache(); void clearCacheOfType(octet type_index); void clearServiceWorkerCache(); + + // Only intended to be used by tests + void clearCrashpadDatabase(); };