brettw | bd8214bf | 2017-06-20 03:47:03 | [diff] [blame] | 1 | // 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 Chen | e266c73 | 2017-08-12 02:27:19 | [diff] [blame] | 9 | #include <vector> |
brettw | bd8214bf | 2017-06-20 03:47:03 | [diff] [blame] | 10 | |
| 11 | #include "base/containers/flat_map.h" |
| 12 | #include "base/macros.h" |
Erik Chen | e2d06447 | 2017-10-07 03:34:07 | [diff] [blame] | 13 | #include "base/memory/ref_counted.h" |
erikchen | a4d1919 | 2017-08-23 17:33:16 | [diff] [blame] | 14 | #include "base/memory/weak_ptr.h" |
Albert J. Wong | 59d85acb | 2017-08-10 00:50:57 | [diff] [blame] | 15 | #include "base/process/process_handle.h" |
erikchen | 66af016 | 2017-08-02 19:53:19 | [diff] [blame] | 16 | #include "base/synchronization/lock.h" |
erikchen | a6f3feb | 2018-02-14 16:21:56 | [diff] [blame] | 17 | #include "base/threading/thread.h" |
erikchen | 21a2cab | 2017-08-21 20:50:44 | [diff] [blame] | 18 | #include "base/values.h" |
brettw | bd8214bf | 2017-06-20 03:47:03 | [diff] [blame] | 19 | #include "build/build_config.h" |
Brett Wilson | 40a6bb50 | 2017-10-10 20:36:15 | [diff] [blame] | 20 | #include "chrome/common/profiling/profiling_service.mojom.h" |
Erik Chen | e2d06447 | 2017-10-07 03:34:07 | [diff] [blame] | 21 | #include "chrome/profiling/allocation_event.h" |
| 22 | #include "chrome/profiling/allocation_tracker.h" |
brettw | bd8214bf | 2017-06-20 03:47:03 | [diff] [blame] | 23 | #include "chrome/profiling/backtrace_storage.h" |
Erik Chen | e2d06447 | 2017-10-07 03:34:07 | [diff] [blame] | 24 | #include "mojo/edk/embedder/scoped_platform_handle.h" |
Ken Rockot | 95c888a4 | 2018-02-11 05:54:11 | [diff] [blame] | 25 | #include "services/resource_coordinator/public/mojom/memory_instrumentation/memory_instrumentation.mojom.h" |
brettw | bd8214bf | 2017-06-20 03:47:03 | [diff] [blame] | 26 | |
| 27 | namespace base { |
Erik Chen | e266c73 | 2017-08-12 02:27:19 | [diff] [blame] | 28 | |
Albert J. Wong | 3432f46 | 2017-08-02 02:47:24 | [diff] [blame] | 29 | class SequencedTaskRunner; |
Erik Chen | e266c73 | 2017-08-12 02:27:19 | [diff] [blame] | 30 | |
| 31 | } // namespace base |
brettw | bd8214bf | 2017-06-20 03:47:03 | [diff] [blame] | 32 | |
| 33 | namespace profiling { |
| 34 | |
erikchen | 53cddfe6 | 2018-02-14 23:31:29 | [diff] [blame] | 35 | using VmRegions = |
| 36 | std::unordered_map<base::ProcessId, |
| 37 | std::vector<memory_instrumentation::mojom::VmRegionPtr>>; |
| 38 | |
brettw | bd8214bf | 2017-06-20 03:47:03 | [diff] [blame] | 39 | // 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. Wong | 3432f46 | 2017-08-02 02:47:24 | [diff] [blame] | 41 | // |
| 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. |
| 46 | class MemlogConnectionManager { |
erikchen | 67fff82 | 2018-02-21 18:53:43 | [diff] [blame^] | 47 | using DumpProcessesForTracingCallback = memory_instrumentation::mojom:: |
| 48 | HeapProfiler::DumpProcessesForTracingCallback; |
| 49 | |
brettw | bd8214bf | 2017-06-20 03:47:03 | [diff] [blame] | 50 | public: |
erikchen | a4d1919 | 2017-08-23 17:33:16 | [diff] [blame] | 51 | MemlogConnectionManager(); |
Albert J. Wong | 3432f46 | 2017-08-02 02:47:24 | [diff] [
|