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

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

Issue 2861133002: memory-infra: Move dump level check to observer and rename session state (Closed)
Patch Set: rename type Created 3 years, 7 months 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 <stdint.h> 8 #include <stdint.h>
9 9
10 #include <map> 10 #include <map>
(...skipping 24 matching lines...) Expand all
35 namespace base { 35 namespace base {
36 36
37 class SequencedTaskRunner; 37 class SequencedTaskRunner;
38 class SingleThreadTaskRunner; 38 class SingleThreadTaskRunner;
39 class Thread; 39 class Thread;
40 40
41 namespace trace_event { 41 namespace trace_event {
42 42
43 class MemoryTracingObserver; 43 class MemoryTracingObserver;
44 class MemoryDumpProvider; 44 class MemoryDumpProvider;
45 class MemoryDumpSessionState; 45 class HeapProfilerSerializationState;
46 46
47 // This is the interface exposed to the rest of the codebase to deal with 47 // This is the interface exposed to the rest of the codebase to deal with
48 // memory tracing. The main entry point for clients is represented by 48 // memory tracing. The main entry point for clients is represented by
49 // RequestDumpPoint(). The extension by Un(RegisterDumpProvider). 49 // RequestDumpPoint(). The extension by Un(RegisterDumpProvider).
50 class BASE_EXPORT MemoryDumpManager { 50 class BASE_EXPORT MemoryDumpManager {
51 public: 51 public:
52 using RequestGlobalDumpFunction = 52 using RequestGlobalDumpFunction =
53 RepeatingCallback<void(const MemoryDumpRequestArgs& args, 53 RepeatingCallback<void(const MemoryDumpRequestArgs& args,
54 const GlobalMemoryDumpCallback& callback)>; 54 const GlobalMemoryDumpCallback& callback)>;
55 55
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 // for the current process and appends it to the trace. |callback| will be 140 // for the current process and appends it to the trace. |callback| will be
141 // invoked asynchronously upon completion on the same thread on which 141 // invoked asynchronously upon completion on the same thread on which
142 // CreateProcessDump() was called. This method should only be used by the 142 // CreateProcessDump() was called. This method should only be used by the
143 // embedder while creating a global memory dump. 143 // embedder while creating a global memory dump.
144 void CreateProcessDump(const MemoryDumpRequestArgs& args, 144 void CreateProcessDump(const MemoryDumpRequestArgs& args,
145 const ProcessMemoryDumpCallback& callback); 145 const ProcessMemoryDumpCallback& callback);
146 146
147 // Enable heap profiling if kEnableHeapProfiling is specified. 147 // Enable heap profiling if kEnableHeapProfiling is specified.
148 void EnableHeapProfilingIfNeeded(); 148 void EnableHeapProfilingIfNeeded();
149 149
150 // Returns true if the dump mode is allowed for current tracing session.
151 bool IsDumpModeAllowed(MemoryDumpLevelOfDetail dump_mode);
152
153 // Lets tests see if a dump provider is registered. 150 // Lets tests see if a dump provider is registered.
154 bool IsDumpProviderRegisteredForTesting(MemoryDumpProvider*); 151 bool IsDumpProviderRegisteredForTesting(MemoryDumpProvider*);
155 152
156 // Returns the MemoryDumpSessionState object, which is shared by all the 153 // Returns the HeapProfilerSerializationState object, which is shared by all
157 // ProcessMemoryDump and MemoryAllocatorDump instances through all the tracing 154 // the ProcessMemoryDump and MemoryAllocatorDump instances through all the
158 // session lifetime. 155 // tracing session lifetime.
159 const scoped_refptr<MemoryDumpSessionState>& session_state_for_testing() 156 const scoped_refptr<HeapProfilerSerializationState>&
160 const { 157 heap_profiler_serialization_state_for_testing() const {
161 return session_state_; 158 return heap_profiler_serialization_state_;
162 } 159 }
163 160
164 // Returns a unique id for identifying the processes. The id can be 161 // Returns a unique id for identifying the processes. The id can be
165 // retrieved by child processes only when tracing is enabled. This is 162 // retrieved by child processes only when tracing is enabled. This is
166 // intended to express cross-process sharing of memory dumps on the 163 // intended to express cross-process sharing of memory dumps on the
167 // child-process side, without having to know its own child process id. 164 // child-process side, without having to know its own child process id.
168 uint64_t GetTracingProcessId() const { return tracing_process_id_; } 165 uint64_t GetTracingProcessId() const { return tracing_process_id_; }
169 void set_tracing_process_id(uint64_t tracing_process_id) { 166 void set_tracing_process_id(uint64_t tracing_process_id) {
170 tracing_process_id_ = tracing_process_id; 167 tracing_process_id_ = tracing_process_id;
171 } 168 }
(...skipping 18 matching lines...) Expand all
190 friend class memory_instrumentation::ProcessLocalDumpManagerImplTest; 187 friend class memory_instrumentation::ProcessLocalDumpManagerImplTest;
191 188
192 // Holds the state of a process memory dump that needs to be carried over 189 // Holds the state of a process memory dump that needs to be carried over
193 // across task runners in order to fulfil an asynchronous CreateProcessDump() 190 // across task runners in order to fulfil an asynchronous CreateProcessDump()
194 // request. At any time exactly one task runner owns a 191 // request. At any time exactly one task runner owns a
195 // ProcessMemoryDumpAsyncState. 192 // ProcessMemoryDumpAsyncState.
196 struct ProcessMemoryDumpAsyncState { 193 struct ProcessMemoryDumpAsyncState {
197 ProcessMemoryDumpAsyncState( 194 ProcessMemoryDumpAsyncState(
198 MemoryDumpRequestArgs req_args, 195 MemoryDumpRequestArgs req_args,
199 const MemoryDumpProviderInfo::OrderedSet& dump_providers, 196 const MemoryDumpProviderInfo::OrderedSet& dump_providers,
200 scoped_refptr<MemoryDumpSessionState> session_state, 197 scoped_refptr<HeapProfilerSerializationState>
198 heap_profiler_serialization_state,
201 ProcessMemoryDumpCallback callback, 199 ProcessMemoryDumpCallback callback,
202 scoped_refptr<SequencedTaskRunner> dump_thread_task_runner); 200 scoped_refptr<SequencedTaskRunner> dump_thread_task_runner);
203 ~ProcessMemoryDumpAsyncState(); 201 ~ProcessMemoryDumpAsyncState();
204 202
205 // Gets or creates the memory dump container for the given target process. 203 // Gets or creates the memory dump container for the given target process.
206 ProcessMemoryDump* GetOrCreateMemoryDumpContainerForProcess( 204 ProcessMemoryDump* GetOrCreateMemoryDumpContainerForProcess(
207 ProcessId pid, 205 ProcessId pid,
208 const MemoryDumpArgs& dump_args); 206 const MemoryDumpArgs& dump_args);
209 207
210 // A map of ProcessId -> ProcessMemoryDump, one for each target process 208 // A map of ProcessId -> ProcessMemoryDump, one for each target process
211 // being dumped from the current process. Typically each process dumps only 209 // being dumped from the current process. Typically each process dumps only
212 // for itself, unless dump providers specify a different |target_process| in 210 // for itself, unless dump providers specify a different |target_process| in
213 // MemoryDumpProvider::Options. 211 // MemoryDumpProvider::Options.
214 std::map<ProcessId, std::unique_ptr<ProcessMemoryDump>> process_dumps; 212 std::map<ProcessId, std::unique_ptr<ProcessMemoryDump>> process_dumps;
215 213
216 // The arguments passed to the initial CreateProcessDump() request. 214 // The arguments passed to the initial CreateProcessDump() request.
217 const MemoryDumpRequestArgs req_args; 215 const MemoryDumpRequestArgs req_args;
218 216
219 // An ordered sequence of dump providers that have to be invoked to complete 217 // An ordered sequence of dump providers that have to be invoked to complete
220 // the dump. This is a copy of |dump_providers_| at the beginning of a dump 218 // the dump. This is a copy of |dump_providers_| at the beginning of a dump
221 // and becomes empty at the end, when all dump providers have been invoked. 219 // and becomes empty at the end, when all dump providers have been invoked.
222 std::vector<scoped_refptr<MemoryDumpProviderInfo>> pending_dump_providers; 220 std::vector<scoped_refptr<MemoryDumpProviderInfo>> pending_dump_providers;
223 221
224 // The trace-global session state. 222 // The trace-global session state.
Primiano Tucci (use gerrit) 2017/05/05 15:59:23 update this comment (actually just move the one fr
hjd 2017/05/05 16:10:33 Done.
hjd 2017/05/05 16:10:33 Done.
225 scoped_refptr<MemoryDumpSessionState> session_state; 223 scoped_refptr<HeapProfilerSerializationState>
224 heap_profiler_serialization_state;
226 225
227 // Callback passed to the initial call to CreateProcessDump(). 226 // Callback passed to the initial call to CreateProcessDump().
228 ProcessMemoryDumpCallback callback; 227 ProcessMemoryDumpCallback callback;
229 228
230 // The |success| field that will be passed as argument to the |callback|. 229 // The |success| field that will be passed as argument to the |callback|.
231 bool dump_successful; 230 bool dump_successful;
232 231
233 // The thread on which FinalizeDumpAndAddToTrace() (and hence |callback|) 232 // The thread on which FinalizeDumpAndAddToTrace() (and hence |callback|)
234 // should be invoked. This is the thread on which the initial 233 // should be invoked. This is the thread on which the initial
235 // CreateProcessDump() request was called. 234 // CreateProcessDump() request was called.
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 // Fills the passed vector with the subset of dump providers which were 285 // Fills the passed vector with the subset of dump providers which were
287 // registered with is_fast_polling_supported == true. 286 // registered with is_fast_polling_supported == true.
288 void GetDumpProvidersForPolling( 287 void GetDumpProvidersForPolling(
289 std::vector<scoped_refptr<MemoryDumpProviderInfo>>*); 288 std::vector<scoped_refptr<MemoryDumpProviderInfo>>*);
290 289
291 // An ordererd set of registered MemoryDumpProviderInfo(s), sorted by task 290 // An ordererd set of registered MemoryDumpProviderInfo(s), sorted by task
292 // runner affinity (MDPs belonging to the same task runners are adjacent). 291 // runner affinity (MDPs belonging to the same task runners are adjacent).
293 MemoryDumpProviderInfo::OrderedSet dump_providers_; 292 MemoryDumpProviderInfo::OrderedSet dump_providers_;
294 293
295 // Shared among all the PMDs to keep state scoped to the tracing session. 294 // Shared among all the PMDs to keep state scoped to the tracing session.
296 scoped_refptr<MemoryDumpSessionState> session_state_; 295 scoped_refptr<HeapProfilerSerializationState>
296 heap_profiler_serialization_state_;
297 297
298 std::unique_ptr<MemoryTracingObserver> tracing_observer_; 298 std::unique_ptr<MemoryTracingObserver> tracing_observer_;
299 299
300 // Function provided by the embedder to handle global dump requests. 300 // Function provided by the embedder to handle global dump requests.
301 RequestGlobalDumpFunction request_dump_function_; 301 RequestGlobalDumpFunction request_dump_function_;
302 302
303 // True when current process coordinates the periodic dump triggering. 303 // True when current process coordinates the periodic dump triggering.
304 bool is_coordinator_; 304 bool is_coordinator_;
305 305
306 // Protects from concurrent accesses to the local state, eg: to guard against 306 // Protects from concurrent accesses to the local state, eg: to guard against
(...skipping 18 matching lines...) Expand all
325 // Whether new memory dump providers should be told to enable heap profiling. 325 // Whether new memory dump providers should be told to enable heap profiling.
326 bool heap_profiling_enabled_; 326 bool heap_profiling_enabled_;
327 327
328 DISALLOW_COPY_AND_ASSIGN(MemoryDumpManager); 328 DISALLOW_COPY_AND_ASSIGN(MemoryDumpManager);
329 }; 329 };
330 330
331 } // namespace trace_event 331 } // namespace trace_event
332 } // namespace base 332 } // namespace base
333 333
334 #endif // BASE_TRACE_EVENT_MEMORY_DUMP_MANAGER_H_ 334 #endif // BASE_TRACE_EVENT_MEMORY_DUMP_MANAGER_H_
OLDNEW
« no previous file with comments | « base/trace_event/memory_allocator_dump_unittest.cc ('k') | base/trace_event/memory_dump_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698