#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "components/metrics/serialization/serialization_utils.h"
#include <errno.h>
#include <stdint.h>
#include <sys/file.h>
#include <unistd.h>
#include <utility>
#include "base/containers/span.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/files/scoped_file.h"
#include "base/logging.h"
#include "base/metrics/histogram_functions.h"
#include "base/numerics/safe_math.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
#include "components/metrics/serialization/metric_sample.h"
#define READ_WRITE_ALL_FILE_FLAGS …
namespace metrics {
namespace {
bool ReadMessage(int fd, std::string* message) { … }
void ReadAndTruncateOrDeleteMetricsFromFile(
const std::string& filename,
bool delete_file,
std::vector<std::unique_ptr<MetricSample>>* metrics) { … }
}
const int SerializationUtils::kMaxMessagesPerRead = …;
std::unique_ptr<MetricSample> SerializationUtils::ParseSample(
const std::string& sample) { … }
void SerializationUtils::ReadAndTruncateMetricsFromFile(
const std::string& filename,
std::vector<std::unique_ptr<MetricSample>>* metrics) { … }
void SerializationUtils::ReadAndDeleteMetricsFromFile(
const std::string& filename,
std::vector<std::unique_ptr<MetricSample>>* metrics) { … }
bool SerializationUtils::WriteMetricToFile(const MetricSample& sample,
const std::string& filename) { … }
}