#include "components/metrics/psi_memory_parser.h"
#include <stddef.h>
#include <cinttypes>
#include <map>
#include <memory>
#include <string>
#include <string_view>
#include "base/metrics/histogram.h"
#include "base/metrics/histogram_functions.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
#include "components/metrics/metrics_log_store.h"
namespace metrics {
namespace {
constexpr uint32_t kMinCollectionInterval = …;
constexpr uint32_t kMidCollectionInterval = …;
constexpr uint32_t kMaxCollectionInterval = …;
constexpr uint32_t kDefaultCollectionInterval = …;
const char kParsePSIMemoryHistogramName[] = …;
constexpr std::string_view kContentPrefixSome = …;
constexpr std::string_view kContentPrefixFull = …;
constexpr std::string_view kContentTerminator = …;
constexpr std::string_view kMetricTerminator = …;
const char kMetricPrefixFormat[] = …;
}
PSIMemoryParser::PSIMemoryParser(uint32_t period)
: … { … }
PSIMemoryParser::~PSIMemoryParser() = default;
uint32_t PSIMemoryParser::GetPeriod() const { … }
int PSIMemoryParser::GetMetricValue(std::string_view content,
size_t start,
size_t end) { … }
void PSIMemoryParser::LogParseStatus(ParsePSIMemStatus stat) { … }
ParsePSIMemStatus PSIMemoryParser::ParseMetrics(std::string_view content,
int* metric_some,
int* metric_full) { … }
namespace internal {
bool FindMiddleString(std::string_view content,
size_t search_start,
std::string_view prefix,
std::string_view suffix,
size_t* start,
size_t* end) { … }
}
}