#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "components/metrics/file_metrics_provider.h"
#include <memory>
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/files/memory_mapped_file.h"
#include "base/files/scoped_temp_dir.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/memory/raw_ptr.h"
#include "base/metrics/histogram.h"
#include "base/metrics/histogram_base.h"
#include "base/metrics/histogram_flattener.h"
#include "base/metrics/histogram_snapshot_manager.h"
#include "base/metrics/persistent_histogram_allocator.h"
#include "base/metrics/persistent_memory_allocator.h"
#include "base/metrics/sparse_histogram.h"
#include "base/metrics/statistics_recorder.h"
#include "base/strings/stringprintf.h"
#include "base/synchronization/waitable_event.h"
#include "base/test/bind.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/task_environment.h"
#include "base/time/time.h"
#include "components/metrics/metrics_log.h"
#include "components/metrics/metrics_pref_names.h"
#include "components/metrics/persistent_system_profile.h"
#include "components/prefs/pref_registry_simple.h"
#include "components/prefs/testing_pref_service.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/metrics_proto/chrome_user_metrics_extension.pb.h"
#include "third_party/metrics_proto/system_profile.pb.h"
namespace {
const char kMetricsName[] = …;
const char kMergedCountHistogramName[] = …;
const char kMetricsFilename[] = …;
void WriteSystemProfileToAllocator(
base::PersistentHistogramAllocator* allocator) { … }
}
namespace metrics {
class HistogramFlattenerDeltaRecorder : public base::HistogramFlattener { … };
class TestFileMetricsProvider : public FileMetricsProvider { … };
class FileMetricsProviderTest : public testing::TestWithParam<bool> { … };
INSTANTIATE_TEST_SUITE_P(…);
TEST_P(FileMetricsProviderTest, AccessMetrics) { … }
TEST_P(FileMetricsProviderTest, AccessTimeLimitedFile) { … }
TEST_P(FileMetricsProviderTest, FilterDelaysFile) { … }
TEST_P(FileMetricsProviderTest, FilterSkipsFile) { … }
TEST_P(FileMetricsProviderTest, AccessDirectory) { … }
TEST_P(FileMetricsProviderTest, AccessDirectoryWithInvalidFiles) { … }
TEST_P(FileMetricsProviderTest, AccessTimeLimitedDirectory) { … }
TEST_P(FileMetricsProviderTest, AccessCountLimitedDirectory) { … }
TEST_P(FileMetricsProviderTest, AccessSizeLimitedDirectory) { … }
TEST_P(FileMetricsProviderTest, AccessFilteredDirectory) { … }
TEST_P(FileMetricsProviderTest, AccessReadWriteMetrics) { … }
TEST_P(FileMetricsProviderTest, AccessInitialMetrics) { … }
TEST_P(FileMetricsProviderTest, AccessEmbeddedProfileMetricsWithoutProfile) { … }
TEST_P(FileMetricsProviderTest, AccessEmbeddedProfileMetricsWithProfile) { … }
TEST_P(FileMetricsProviderTest, AccessEmbeddedFallbackMetricsWithoutProfile) { … }
TEST_P(FileMetricsProviderTest, AccessEmbeddedFallbackMetricsWithProfile) { … }
TEST_P(FileMetricsProviderTest, AccessEmbeddedProfileMetricsFromDir) { … }
TEST_P(FileMetricsProviderTest,
RecordInitialHistogramSnapshotsStabilityHistograms) { … }
TEST_P(FileMetricsProviderTest, IndependentLogContainsUmaHistograms) { … }
TEST_P(FileMetricsProviderTest, EmbeddedProfileWithoutClientUuid) { … }
TEST_P(FileMetricsProviderTest, EmbeddedProfileWithClientUuid) { … }
TEST_P(FileMetricsProviderTest, MetricsDisabledRegisterAtomicFile) { … }
TEST_P(FileMetricsProviderTest, MetricsDisabledRegisterAtomicDir) { … }
TEST_P(FileMetricsProviderTest, MetricsDisabledRegisterActiveFile) { … }
}