Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(194)

Side by Side Diff: base/trace_event/memory_dump_manager.h

Issue 1417003003: [tracing] Dump child processes' memory metrics in browser (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@web_cache2_base
Patch Set: Nits. Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef BASE_TRACE_EVENT_MEMORY_DUMP_MANAGER_H_ 5 #ifndef BASE_TRACE_EVENT_MEMORY_DUMP_MANAGER_H_
6 #define BASE_TRACE_EVENT_MEMORY_DUMP_MANAGER_H_ 6 #define BASE_TRACE_EVENT_MEMORY_DUMP_MANAGER_H_
7 7
8 #include <set> 8 #include <set>
9 9
10 #include "base/atomicops.h" 10 #include "base/atomicops.h"
11 #include "base/containers/hash_tables.h" 11 #include "base/containers/hash_tables.h"
12 #include "base/containers/scoped_ptr_map.h" 12 #include "base/containers/scoped_ptr_map.h"
13 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
14 #include "base/memory/singleton.h" 14 #include "base/memory/singleton.h"
15 #include "base/synchronization/lock.h" 15 #include "base/synchronization/lock.h"
16 #include "base/timer/timer.h" 16 #include "base/timer/timer.h"
17 #include "base/trace_event/memory_dump_request_args.h" 17 #include "base/trace_event/memory_dump_request_args.h"
18 #include "base/trace_event/process_memory_dump.h" 18 #include "base/trace_event/process_memory_dump.h"
19 #include "base/trace_event/process_memory_maps_dump_provider.h"
20 #include "base/trace_event/process_memory_totals_dump_provider.h"
19 #include "base/trace_event/trace_event.h" 21 #include "base/trace_event/trace_event.h"
20 22
21 namespace base { 23 namespace base {
22 24
23 class SingleThreadTaskRunner; 25 class SingleThreadTaskRunner;
24 class Thread; 26 class Thread;
25 27
26 namespace trace_event { 28 namespace trace_event {
27 29
28 class MemoryDumpManagerDelegate; 30 class MemoryDumpManagerDelegate;
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 const MemoryDumpCallback& callback); 92 const MemoryDumpCallback& callback);
91 93
92 // Same as above (still asynchronous), but without callback. 94 // Same as above (still asynchronous), but without callback.
93 void RequestGlobalDump(MemoryDumpType dump_type, 95 void RequestGlobalDump(MemoryDumpType dump_type,
94 MemoryDumpLevelOfDetail level_of_detail); 96 MemoryDumpLevelOfDetail level_of_detail);
95 97
96 // TraceLog::EnabledStateObserver implementation. 98 // TraceLog::EnabledStateObserver implementation.
97 void OnTraceLogEnabled() override; 99 void OnTraceLogEnabled() override;
98 void OnTraceLogDisabled() override; 100 void OnTraceLogDisabled() override;
99 101
102 // Registers and unregisters the process metrics dump providers for the
103 // |process|. Some processes cannot access metrics due to sandbox. To
104 // workaround the issue the coordinator process dumps statistics about the
Primiano Tucci (use gerrit) 2015/11/03 15:14:08 the manager should not need to know about all this
105 // associated processes.
106 void RegisterProcessMetricsProvidersFor(ProcessHandle process);
107 void UnregisterProcessMetricsProvidersFor(ProcessHandle process);
108
100 // Returns the MemoryDumpSessionState object, which is shared by all the 109 // Returns the MemoryDumpSessionState object, which is shared by all the
101 // ProcessMemoryDump and MemoryAllocatorDump instances through all the tracing 110 // ProcessMemoryDump and MemoryAllocatorDump instances through all the tracing
102 // session lifetime. 111 // session lifetime.
103 const scoped_refptr<MemoryDumpSessionState>& session_state() const { 112 const scoped_refptr<MemoryDumpSessionState>& session_state() const {
104 return session_state_; 113 return session_state_;
105 } 114 }
106 115
107 // Returns a unique id for identifying the processes. The id can be 116 // Returns a unique id for identifying the processes. The id can be
108 // retrieved by child processes only when tracing is enabled. This is 117 // retrieved by child processes only when tracing is enabled. This is
109 // intended to express cross-process sharing of memory dumps on the 118 // intended to express cross-process sharing of memory dumps on the
(...skipping 12 matching lines...) Expand all
122 void set_dumper_registrations_ignored_for_testing(bool ignored) { 131 void set_dumper_registrations_ignored_for_testing(bool ignored) {
123 dumper_registrations_ignored_for_testing_ = ignored; 132 dumper_registrations_ignored_for_testing_ = ignored;
124 } 133 }
125 134
126 private: 135 private:
127 friend struct DefaultDeleter<MemoryDumpManager>; // For the testing instance. 136 friend struct DefaultDeleter<MemoryDumpManager>; // For the testing instance.
128 friend struct DefaultSingletonTraits<MemoryDumpManager>; 137 friend struct DefaultSingletonTraits<MemoryDumpManager>;
129 friend class MemoryDumpManagerDelegate; 138 friend class MemoryDumpManagerDelegate;
130 friend class MemoryDumpManagerTest; 139 friend class MemoryDumpManagerTest;
131 140
141 using ProcessTotalsDumpProvidersMap =
142 ScopedPtrMap<ProcessHandle, scoped_ptr<ProcessMemoryTotalsDumpProvider>>;
143 using ProcessMapsDumpProvidersMap =
144 ScopedPtrMap<ProcessHandle, scoped_ptr<ProcessMemoryMapsDumpProvider>>;
145
132 // Descriptor struct used to hold information about registered MDPs. It is 146 // Descriptor struct used to hold information about registered MDPs. It is
133 // deliberately copyable, in order to allow it to be used as std::set value. 147 // deliberately copyable, in order to allow it to be used as std::set value.
134 struct MemoryDumpProviderInfo { 148 struct MemoryDumpProviderInfo {
135 MemoryDumpProviderInfo( 149 MemoryDumpProviderInfo(
136 MemoryDumpProvider* dump_provider, 150 MemoryDumpProvider* dump_provider,
137 const char* name, 151 const char* name,
138 const scoped_refptr<SingleThreadTaskRunner>& task_runner, 152 const scoped_refptr<SingleThreadTaskRunner>& task_runner,
139 const MemoryDumpProvider::Options& options); 153 const MemoryDumpProvider::Options& options);
140 ~MemoryDumpProviderInfo(); 154 ~MemoryDumpProviderInfo();
141 155
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 247
234 // Continues the ProcessMemoryDump started by CreateProcessDump(), hopping 248 // Continues the ProcessMemoryDump started by CreateProcessDump(), hopping
235 // across threads as needed as specified by MDPs in RegisterDumpProvider(). 249 // across threads as needed as specified by MDPs in RegisterDumpProvider().
236 void ContinueAsyncProcessDump( 250 void ContinueAsyncProcessDump(
237 scoped_ptr<ProcessMemoryDumpAsyncState> pmd_async_state); 251 scoped_ptr<ProcessMemoryDumpAsyncState> pmd_async_state);
238 252
239 // An ordererd set of registered MemoryDumpProviderInfo(s), sorted by thread 253 // An ordererd set of registered MemoryDumpProviderInfo(s), sorted by thread
240 // affinity (MDPs belonging to the same thread are adjacent). 254 // affinity (MDPs belonging to the same thread are adjacent).
241 MemoryDumpProviderInfoSet dump_providers_; 255 MemoryDumpProviderInfoSet dump_providers_;
242 256
257 // MemoryDumpManager owns the memory maps and totals providers for all the
258 // associated processes.
259 ProcessTotalsDumpProvidersMap process_totals_providers_map_;
260 ProcessMapsDumpProvidersMap process_mmaps_providers_map_;
261
243 // Shared among all the PMDs to keep state scoped to the tracing session. 262 // Shared among all the PMDs to keep state scoped to the tracing session.
244 scoped_refptr<MemoryDumpSessionState> session_state_; 263 scoped_refptr<MemoryDumpSessionState> session_state_;
245 264
246 MemoryDumpManagerDelegate* delegate_; // Not owned. 265 MemoryDumpManagerDelegate* delegate_; // Not owned.
247 266
248 // When true, this instance is in charge of coordinating periodic dumps. 267 // When true, this instance is in charge of coordinating periodic dumps.
249 bool is_coordinator_; 268 bool is_coordinator_;
250 269
251 // Protects from concurrent accesses to the |dump_providers_*| and |delegate_| 270 // Protects from concurrent accesses to the |dump_providers_*| and |delegate_|
252 // to guard against disabling logging while dumping on another thread. 271 // to guard against disabling logging while dumping on another thread.
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 } 315 }
297 316
298 private: 317 private:
299 DISALLOW_COPY_AND_ASSIGN(MemoryDumpManagerDelegate); 318 DISALLOW_COPY_AND_ASSIGN(MemoryDumpManagerDelegate);
300 }; 319 };
301 320
302 } // namespace trace_event 321 } // namespace trace_event
303 } // namespace base 322 } // namespace base
304 323
305 #endif // BASE_TRACE_EVENT_MEMORY_DUMP_MANAGER_H_ 324 #endif // BASE_TRACE_EVENT_MEMORY_DUMP_MANAGER_H_
OLDNEW
« no previous file with comments | « no previous file | base/trace_event/memory_dump_manager.cc » ('j') | base/trace_event/process_memory_maps_dump_provider.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698