Refactor: Improve Structured Metrics Storage Threading
Improves thread safety and performance in Structured Metrics storage,
addressing unsafe multi-threaded access, UI thread blocking, and task
posting issues. Expected to fix a proto encoding crash.
Key changes:
- Made EventStorage::TakeEvents asynchronous with callbacks.
- Moved StorageManagerImpl disk I/O to background threads.
- FlushedMap now initializes asynchronously and deletes files on background threads, deferring operations until initialized.
- Enforced UI thread affinity for StructuredMetricsRecorder.
- StructuredMetricsRecorder is no longer ref counted.
- Simplified StructuredMetricsService by removing ServiceIOHelper and unifying async logic.
- Functional change: If there are no events (either due to none being
logged or structured metrics not enabled), no logs will be generated.
This creates a more robust and thread-safe storage model.
Bug: 339914565, b:443472681
Change-Id: I0b2c578d5c5502ab2ea09c9897f90164ec62ef46
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7499833
Reviewed-by: Luc Nguyen <lucnguyen@google.com>
Commit-Queue: Alexei Svitkine <asvitkine@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1581108}
NOKEYCHECK=True
GitOrigin-RevId: 8f66e3b5d276218f2c5cab12b155c472c338d23b
20 files changed