chromium/services/resource_coordinator/public/cpp/memory_instrumentation/os_metrics.h

// Copyright 2017 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_MEMORY_INSTRUMENTATION_OS_METRICS_H_
#define SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_MEMORY_INSTRUMENTATION_OS_METRICS_H_

#include <vector>

#include "base/component_export.h"
#include "base/gtest_prod_util.h"
#include "base/process/process_handle.h"
#include "base/trace_event/process_memory_dump.h"
#include "build/build_config.h"
#include "services/resource_coordinator/public/mojom/memory_instrumentation/memory_instrumentation.mojom.h"

#if BUILDFLAG(IS_APPLE)
#include <mach/mach.h>
#endif

heap_profiling

namespace memory_instrumentation {

// This class provides synchronous access to memory metrics for a process with a
// given |pid|. These interfaces have platform-specific restrictions:
//  * On Android, due to sandboxing restrictions, processes can only access
//    memory metrics for themselves. Thus |pid| must be equal to getpid().
//  * On Linux, due to sandboxing restrictions, only the privileged browser
//    process has access to memory metrics for sandboxed child processes.
//  * On Fuchsia, due to the API expecting a ProcessId rather than a
//    ProcessHandle, processes can only access memory metrics for themselves or
//    for children of base::GetDefaultJob().
//
// These restrictions mean that any code that wishes to be cross-platform
// compatible cannot synchronously obtain memory metrics for a |pid|. Instead,
// it must use the async MemoryInstrumentation methods.
class COMPONENT_EXPORT(
    RESOURCE_COORDINATOR_PUBLIC_MEMORY_INSTRUMENTATION) OSMetrics {};

}  // namespace memory_instrumentation

#endif  // SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_MEMORY_INSTRUMENTATION_OS_METRICS_H_