OLD | NEW |
---|---|
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 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 MemoryDumpSessionState object, which is shared by all the |
Primiano Tucci (use gerrit)
2017/05/05 13:38:24
I'd remove this comment and update the one below a
| |
157 // ProcessMemoryDump and MemoryAllocatorDump instances through all the tracing | 154 // ProcessMemoryDump and MemoryAllocatorDump instances through all the tracing |
158 // session lifetime. | 155 // session lifetime. |
159 const scoped_refptr<MemoryDumpSessionState>& session_state_for_testing() | 156 const scoped_refptr<MemoryDumpSessionState>& |
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 Loading... | |
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<MemoryDumpSessionState> heap_profiler_serialization_state, |
201 ProcessMemoryDumpCallback callback, | 198 ProcessMemoryDumpCallback callback, |
202 scoped_refptr<SequencedTaskRunner> dump_thread_task_runner); | 199 scoped_refptr<SequencedTaskRunner> dump_thread_task_runner); |
203 ~ProcessMemoryDumpAsyncState(); | 200 ~ProcessMemoryDumpAsyncState(); |
204 | 201 |
205 // Gets or creates the memory dump container for the given target process. | 202 // Gets or creates the memory dump container for the given target process. |
206 ProcessMemoryDump* GetOrCreateMemoryDumpContainerForProcess( | 203 ProcessMemoryDump* GetOrCreateMemoryDumpContainerForProcess( |
207 ProcessId pid, | 204 ProcessId pid, |
208 const MemoryDumpArgs& dump_args); | 205 const MemoryDumpArgs& dump_args); |
209 | 206 |
210 // A map of ProcessId -> ProcessMemoryDump, one for each target process | 207 // A map of ProcessId -> ProcessMemoryDump, one for each target process |
211 // being dumped from the current process. Typically each process dumps only | 208 // being dumped from the current process. Typically each process dumps only |
212 // for itself, unless dump providers specify a different |target_process| in | 209 // for itself, unless dump providers specify a different |target_process| in |
213 // MemoryDumpProvider::Options. | 210 // MemoryDumpProvider::Options. |
214 std::map<ProcessId, std::unique_ptr<ProcessMemoryDump>> process_dumps; | 211 std::map<ProcessId, std::unique_ptr<ProcessMemoryDump>> process_dumps; |
215 | 212 |
216 // The arguments passed to the initial CreateProcessDump() request. | 213 // The arguments passed to the initial CreateProcessDump() request. |
217 const MemoryDumpRequestArgs req_args; | 214 const MemoryDumpRequestArgs req_args; |
218 | 215 |
219 // An ordered sequence of dump providers that have to be invoked to complete | 216 // 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 | 217 // 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. | 218 // and becomes empty at the end, when all dump providers have been invoked. |
222 std::vector<scoped_refptr<MemoryDumpProviderInfo>> pending_dump_providers; | 219 std::vector<scoped_refptr<MemoryDumpProviderInfo>> pending_dump_providers; |
223 | 220 |
224 // The trace-global session state. | 221 // The trace-global session state. |
225 scoped_refptr<MemoryDumpSessionState> session_state; | 222 scoped_refptr<MemoryDumpSessionState> heap_profiler_serialization_state; |
226 | 223 |
227 // Callback passed to the initial call to CreateProcessDump(). | 224 // Callback passed to the initial call to CreateProcessDump(). |
228 ProcessMemoryDumpCallback callback; | 225 ProcessMemoryDumpCallback callback; |
229 | 226 |
230 // The |success| field that will be passed as argument to the |callback|. | 227 // The |success| field that will be passed as argument to the |callback|. |
231 bool dump_successful; | 228 bool dump_successful; |
232 | 229 |
233 // The thread on which FinalizeDumpAndAddToTrace() (and hence |callback|) | 230 // The thread on which FinalizeDumpAndAddToTrace() (and hence |callback|) |
234 // should be invoked. This is the thread on which the initial | 231 // should be invoked. This is the thread on which the initial |
235 // CreateProcessDump() request was called. | 232 // CreateProcessDump() request was called. |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
286 // Fills the passed vector with the subset of dump providers which were | 283 // Fills the passed vector with the subset of dump providers which were |
287 // registered with is_fast_polling_supported == true. | 284 // registered with is_fast_polling_supported == true. |
288 void GetDumpProvidersForPolling( | 285 void GetDumpProvidersForPolling( |
289 std::vector<scoped_refptr<MemoryDumpProviderInfo>>*); | 286 std::vector<scoped_refptr<MemoryDumpProviderInfo>>*); |
290 | 287 |
291 // An ordererd set of registered MemoryDumpProviderInfo(s), sorted by task | 288 // An ordererd set of registered MemoryDumpProviderInfo(s), sorted by task |
292 // runner affinity (MDPs belonging to the same task runners are adjacent). | 289 // runner affinity (MDPs belonging to the same task runners are adjacent). |
293 MemoryDumpProviderInfo::OrderedSet dump_providers_; | 290 MemoryDumpProviderInfo::OrderedSet dump_providers_; |
294 | 291 |
295 // Shared among all the PMDs to keep state scoped to the tracing session. | 292 // Shared among all the PMDs to keep state scoped to the tracing session. |
296 scoped_refptr<MemoryDumpSessionState> session_state_; | 293 scoped_refptr<MemoryDumpSessionState> heap_profiler_serialization_state_; |
297 | 294 |
298 std::unique_ptr<MemoryTracingObserver> tracing_observer_; | 295 std::unique_ptr<MemoryTracingObserver> tracing_observer_; |
299 | 296 |
300 // Function provided by the embedder to handle global dump requests. | 297 // Function provided by the embedder to handle global dump requests. |
301 RequestGlobalDumpFunction request_dump_function_; | 298 RequestGlobalDumpFunction request_dump_function_; |
302 | 299 |
303 // True when current process coordinates the periodic dump triggering. | 300 // True when current process coordinates the periodic dump triggering. |
304 bool is_coordinator_; | 301 bool is_coordinator_; |
305 | 302 |
306 // Protects from concurrent accesses to the local state, eg: to guard against | 303 // Protects from concurrent accesses to the local state, eg: to guard against |
(...skipping 18 matching lines...) Expand all Loading... | |
325 // Whether new memory dump providers should be told to enable heap profiling. | 322 // Whether new memory dump providers should be told to enable heap profiling. |
326 bool heap_profiling_enabled_; | 323 bool heap_profiling_enabled_; |
327 | 324 |
328 DISALLOW_COPY_AND_ASSIGN(MemoryDumpManager); | 325 DISALLOW_COPY_AND_ASSIGN(MemoryDumpManager); |
329 }; | 326 }; |
330 | 327 |
331 } // namespace trace_event | 328 } // namespace trace_event |
332 } // namespace base | 329 } // namespace base |
333 | 330 |
334 #endif // BASE_TRACE_EVENT_MEMORY_DUMP_MANAGER_H_ | 331 #endif // BASE_TRACE_EVENT_MEMORY_DUMP_MANAGER_H_ |
OLD | NEW |