Skip to content

Commit

Permalink
Add a web API clearCrashpadDatabase
Browse files Browse the repository at this point in the history
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
  • Loading branch information
yuying-y committed Jan 31, 2025
1 parent 1a3c49f commit 66179c9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
11 changes: 11 additions & 0 deletions cobalt/h5vcc/h5vcc_storage.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -429,6 +431,15 @@ void H5vccStorage::ClearServiceWorkerCache() {
base::DeleteFile(service_worker_file_path);
}

void H5vccStorage::ClearCrashpadDatabase() {
std::vector<char> 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;
Expand Down
2 changes: 2 additions & 0 deletions cobalt/h5vcc/h5vcc_storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ class H5vccStorage : public script::Wrappable {

void ClearServiceWorkerCache();

void ClearCrashpadDatabase();

DEFINE_WRAPPABLE_TYPE(H5vccStorage);

private:
Expand Down
3 changes: 3 additions & 0 deletions cobalt/h5vcc/h5vcc_storage.idl
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,7 @@ interface H5vccStorage {
void clearCache();
void clearCacheOfType(octet type_index);
void clearServiceWorkerCache();

// Only intended to be used by tests
void clearCrashpadDatabase();
};

0 comments on commit 66179c9

Please sign in to comment.