Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a web API clearCrashpadDatabase #4790

Merged
merged 1 commit into from
Jan 31, 2025
Merged

Conversation

yuying-y
Copy link
Contributor

@yuying-y yuying-y commented Jan 29, 2025

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.

Verified on Linux: Crashpad DB is purged after caling the API. After app restarts, crash upload works as expected.

b/332895679

Change-Id: I0b104a64dbd156de6df817800c972042e810e654

@yuying-y yuying-y assigned yuying-y, y4vor and hlwarriner and unassigned yuying-y Jan 30, 2025
Copy link
Contributor

@yell0wd0g yell0wd0g left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Happy to see this getting traction.

Comment on lines +435 to +439
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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we use std::string?

   std::string cache_folder(kSbFileMaxPath, 0);
   SbSystemGetPath(..., cache_folder.data(),..);
   
   base::FilePath crashpad_db_folder(cache_folder);
   crashpad_db_folder.Append(kCrashpadDBName);

Try to avoid using acronyms or shortenings: s/dir/directory/ or s/dir/folder/. Maybe also expand s/db/database/.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the suggestion. Same as above. I followed the existing style for consistency, including the name "cache_dir". If all reviewers think they should be fixed all together, I'll make another PR.

std::vector<char> cache_dir(kSbFileMaxPath + 1, 0);
SbSystemGetPath(kSbSystemPathCacheDirectory, cache_dir.data(),
kSbFileMaxPath);
base::FilePath crashpad_db_dir =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Declaring and initializing crashpad_db_dir in one line: I don't see a strong reason to have it the way it's presented vs the suggested alternative below unless it's to make this variable const.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the comment. There're 4 existing references of initializing file path and appending another segment in h5vcc_storage.cc. I followed the existing style for consistency. I don't see which way is significantly better or more correct. I prefer to make this PR focused on adding the API, rather than fixing existing styles. I don't think it's absolutely necessary to fix the styles of this file at the moment, as this style is present in many files in the code base. What's the point of fixing one file without fixing all the files? IMO it's not a priority for the team at the moment.

I'll submit this PR as is since all reviewers approved. But if all the reviewers think it's absolutely necessary to fix this style in this file, I'll make another PR to fix this one and the other 4 references, just to make this PR focused. @y4vor @hlwarriner

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with keeping the existing style. Thanks for checking.

Copy link
Contributor

@hlwarriner hlwarriner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left one comment but otherwise lgtm! Thanks for taking this.

@@ -31,4 +31,6 @@ interface H5vccStorage {
void clearCache();
void clearCacheOfType(octet type_index);
void clearServiceWorkerCache();

void clearCrashpadDatabase();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may be a good idea to just add a quick comment explaining that this API is only meant to be called from tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

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
@yuying-y yuying-y enabled auto-merge (squash) January 31, 2025 04:20
@yuying-y yuying-y merged commit ad55351 into youtube:25.lts.1+ Jan 31, 2025
282 of 291 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants