// Copyright 2021 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef COMPONENTS_METRICS_PSI_MEMORY_PARSER_H_ #define COMPONENTS_METRICS_PSI_MEMORY_PARSER_H_ #include <cstdint> #include <string> #include <string_view> #include "base/gtest_prod_util.h" namespace metrics { // Items in internal are - as the name implies - NOT for outside consumption. // Defined here to allow access to unit test. namespace internal { // Finds the bounds for a substring of |content| which is sandwiched between // the given |prefix| and |suffix| indices. Search only considers // the portion of the string starting from |search_start|. // Returns false if the prefix and/or suffix are not found, true otherwise. // |start| and |end| are output parameters populated with the indices // for the middle string. bool FindMiddleString(std::string_view content, size_t search_start, std::string_view prefix, std::string_view suffix, size_t* start, size_t* end); } // namespace internal // Values as logged in the histogram for memory pressure. constexpr int kMemPressureMin = …; // As 0 is for underflow. constexpr int kMemPressureExclusiveMax = …; constexpr int kMemPressureHistogramBuckets = …; // Enumeration representing success and various failure modes for parsing PSI // memory data. These values are persisted to logs. Entries should not be // renumbered and numeric values should never be reused. enum class ParsePSIMemStatus { … }; // PSIMemoryParser has logic to parse results from /proc/memory/pressure // in Linux, which can be used for memory pressure metrics. class PSIMemoryParser { … }; } // namespace metrics #endif // COMPONENTS_METRICS_PSI_MEMORY_PARSER_H_