#include "components/zucchini/main_utils.h"
#include <stddef.h>
#include <memory>
#include <ostream>
#include <string>
#include <string_view>
#include <vector>
#include "base/command_line.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/logging.h"
#include "base/process/process_handle.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "components/zucchini/io_utils.h"
#include "components/zucchini/version_info.h"
#include "components/zucchini/zucchini_commands.h"
#if BUILDFLAG(IS_WIN)
#include <windows.h>
#include <psapi.h>
#endif
namespace {
struct Command { … };
constexpr Command kCommands[] = …;
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
void GetPeakMemoryMetrics(size_t* peak_virtual_memory,
size_t* resident_set_size_hwm) { … }
#endif
#if BUILDFLAG(IS_WIN)
void GetPeakMemoryMetrics(size_t* peak_page_file_usage,
size_t* peak_working_set_size) {
*peak_page_file_usage = 0;
*peak_working_set_size = 0;
PROCESS_MEMORY_COUNTERS pmc;
if (::GetProcessMemoryInfo(::GetCurrentProcess(), &pmc, sizeof(pmc))) {
*peak_page_file_usage = pmc.PeakPagefileUsage;
*peak_working_set_size = pmc.PeakWorkingSetSize;
}
}
#endif
class ScopedResourceUsageTracker { … };
bool CheckAndGetFilePathParams(const base::CommandLine& command_line,
size_t expected_count,
std::vector<base::FilePath>* paths) { … }
void PrintUsage(std::ostream& err) { … }
}
zucchini::status::Code RunZucchiniCommand(const base::CommandLine& command_line,
std::ostream& out,
std::ostream& err) { … }