blob: 8da3e47487968413c5b0463fbfa1db50ad423668 [file] [log] [blame]
brettwbd8214bf2017-06-20 03:47:031// Copyright 2017 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef CHROME_PROFILING_MEMLOG_CONNECTION_MANAGER_H_
6#define CHROME_PROFILING_MEMLOG_CONNECTION_MANAGER_H_
7
8#include <string>
Erik Chene266c732017-08-12 02:27:199#include <vector>
brettwbd8214bf2017-06-20 03:47:0310
11#include "base/containers/flat_map.h"
12#include "base/macros.h"
Erik Chene2d064472017-10-07 03:34:0713#include "base/memory/ref_counted.h"
erikchena4d19192017-08-23 17:33:1614#include "base/memory/weak_ptr.h"
Albert J. Wong59d85acb2017-08-10 00:50:5715#include "base/process/process_handle.h"
erikchen66af0162017-08-02 19:53:1916#include "base/synchronization/lock.h"
erikchena6f3feb2018-02-14 16:21:5617#include "base/threading/thread.h"
erikchen21a2cab2017-08-21 20:50:4418#include "base/values.h"
brettwbd8214bf2017-06-20 03:47:0319#include "build/build_config.h"
Brett Wilson40a6bb502017-10-10 20:36:1520#include "chrome/common/profiling/profiling_service.mojom.h"
Erik Chene2d064472017-10-07 03:34:0721#include "chrome/profiling/allocation_event.h"
22#include "chrome/profiling/allocation_tracker.h"
brettwbd8214bf2017-06-20 03:47:0323#include "chrome/profiling/backtrace_storage.h"
Erik Chene2d064472017-10-07 03:34:0724#include "mojo/edk/embedder/scoped_platform_handle.h"
Ken Rockot95c888a42018-02-11 05:54:1125#include "services/resource_coordinator/public/mojom/memory_instrumentation/memory_instrumentation.mojom.h"
brettwbd8214bf2017-06-20 03:47:0326
27namespace base {
Erik Chene266c732017-08-12 02:27:1928
Albert J. Wong3432f462017-08-02 02:47:2429class SequencedTaskRunner;
Erik Chene266c732017-08-12 02:27:1930
31} // namespace base
brettwbd8214bf2017-06-20 03:47:0332
33namespace profiling {
34
erikchen53cddfe62018-02-14 23:31:2935using VmRegions =
36 std::unordered_map<base::ProcessId,
37 std::vector<memory_instrumentation::mojom::VmRegionPtr>>;
38
brettwbd8214bf2017-06-20 03:47:0339// Manages all connections and logging for each process. Pipes are supplied by
40// the pipe server and this class will connect them to a parser and logger.
Albert J. Wong3432f462017-08-02 02:47:2441//
42// Note |backtrace_storage| must outlive MemlogConnectionManager.
43//
44// This object is constructed on the UI thread, but the rest of the usage
45// (including deletion) is on the IO thread.
46class MemlogConnectionManager {
erikchen67fff822018-02-21 18:53:4347 using DumpProcessesForTracingCallback = memory_instrumentation::mojom::
48 HeapProfiler::DumpProcessesForTracingCallback;
49
brettwbd8214bf2017-06-20 03:47:0350 public:
erikchena4d19192017-08-23 17:33:1651 MemlogConnectionManager();
Albert J. Wong3432f462017-08-02 02:47:24