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 <set> | 8 #include <set> |
9 | 9 |
10 #include "base/atomicops.h" | 10 #include "base/atomicops.h" |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 } | 85 } |
86 | 86 |
87 // Returns a unique id for identifying the processes. The id can be | 87 // Returns a unique id for identifying the processes. The id can be |
88 // retrieved by child processes only when tracing is enabled. This is | 88 // retrieved by child processes only when tracing is enabled. This is |
89 // intended to express cross-process sharing of memory dumps on the | 89 // intended to express cross-process sharing of memory dumps on the |
90 // child-process side, without having to know its own child process id. | 90 // child-process side, without having to know its own child process id. |
91 uint64 GetTracingProcessId() const; | 91 uint64 GetTracingProcessId() const; |
92 | 92 |
93 // Returns the name for a the allocated_objects dump. Use this to declare | 93 // Returns the name for a the allocated_objects dump. Use this to declare |
94 // suballocator dumps from other dump providers. | 94 // suballocator dumps from other dump providers. |
95 // It should not return nullptr after the manager has been initialized. | 95 // It will return nullptr if there is no dump provider for the system |
| 96 // allocator registered (which is currently the case for Mac OS). |
96 const char* system_allocator_pool_name() const { | 97 const char* system_allocator_pool_name() const { |
97 return system_allocator_pool_name_; | 98 return kSystemAllocatorPoolName; |
98 }; | 99 }; |
99 | 100 |
100 // Tells the initialization phase to skip scheduling periodic memory dumps. | 101 // Tells the initialization phase to skip scheduling periodic memory dumps. |
101 void DisablePeriodicDumpsForTesting() { | 102 void DisablePeriodicDumpsForTesting() { |
102 disable_periodic_dumps_for_testing_ = true; | 103 disable_periodic_dumps_for_testing_ = true; |
103 } | 104 } |
104 | 105 |
105 private: | 106 private: |
106 friend struct DefaultDeleter<MemoryDumpManager>; // For the testing instance. | 107 friend struct DefaultDeleter<MemoryDumpManager>; // For the testing instance. |
107 friend struct DefaultSingletonTraits<MemoryDumpManager>; | 108 friend struct DefaultSingletonTraits<MemoryDumpManager>; |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 // The thread on which FinalizeDumpAndAddToTrace() (and hence |callback|) | 168 // The thread on which FinalizeDumpAndAddToTrace() (and hence |callback|) |
168 // should be invoked. This is the thread on which the initial | 169 // should be invoked. This is the thread on which the initial |
169 // CreateProcessDump() request was called. | 170 // CreateProcessDump() request was called. |
170 const scoped_refptr<SingleThreadTaskRunner> task_runner; | 171 const scoped_refptr<SingleThreadTaskRunner> task_runner; |
171 | 172 |
172 private: | 173 private: |
173 DISALLOW_COPY_AND_ASSIGN(ProcessMemoryDumpAsyncState); | 174 DISALLOW_COPY_AND_ASSIGN(ProcessMemoryDumpAsyncState); |
174 }; | 175 }; |
175 | 176 |
176 static const int kMaxConsecutiveFailuresCount; | 177 static const int kMaxConsecutiveFailuresCount; |
| 178 static const char* const kSystemAllocatorPoolName; |
177 | 179 |
178 MemoryDumpManager(); | 180 MemoryDumpManager(); |
179 ~MemoryDumpManager() override; | 181 ~MemoryDumpManager() override; |
180 | 182 |
181 static void SetInstanceForTesting(MemoryDumpManager* instance); | 183 static void SetInstanceForTesting(MemoryDumpManager* instance); |
182 static void FinalizeDumpAndAddToTrace( | 184 static void FinalizeDumpAndAddToTrace( |
183 scoped_ptr<ProcessMemoryDumpAsyncState> pmd_async_state); | 185 scoped_ptr<ProcessMemoryDumpAsyncState> pmd_async_state); |
184 static void AbortDumpLocked(MemoryDumpCallback callback, | 186 static void AbortDumpLocked(MemoryDumpCallback callback, |
185 scoped_refptr<SingleThreadTaskRunner> task_runner, | 187 scoped_refptr<SingleThreadTaskRunner> task_runner, |
186 uint64 dump_guid); | 188 uint64 dump_guid); |
(...skipping 27 matching lines...) Expand all Loading... |
214 // dump_providers_enabled_ list) when tracing is not enabled. | 216 // dump_providers_enabled_ list) when tracing is not enabled. |
215 subtle::AtomicWord memory_tracing_enabled_; | 217 subtle::AtomicWord memory_tracing_enabled_; |
216 | 218 |
217 // For time-triggered periodic dumps. | 219 // For time-triggered periodic dumps. |
218 RepeatingTimer<MemoryDumpManager> periodic_dump_timer_; | 220 RepeatingTimer<MemoryDumpManager> periodic_dump_timer_; |
219 | 221 |
220 // The unique id of the child process. This is created only for tracing and is | 222 // The unique id of the child process. This is created only for tracing and is |
221 // expected to be valid only when tracing is enabled. | 223 // expected to be valid only when tracing is enabled. |
222 uint64 tracing_process_id_; | 224 uint64 tracing_process_id_; |
223 | 225 |
224 // Name of the allocated_objects dump. | |
225 const char* system_allocator_pool_name_; | |
226 | |
227 // Skips the auto-registration of the core dumpers during Initialize(). | 226 // Skips the auto-registration of the core dumpers during Initialize(). |
228 bool skip_core_dumpers_auto_registration_for_testing_; | 227 bool skip_core_dumpers_auto_registration_for_testing_; |
229 | 228 |
230 // When true, the initialization phase does not start the periodic memory | 229 // When true, the initialization phase does not start the periodic memory |
231 // dumps. | 230 // dumps. |
232 // TODO(primiano): This should go into TraceConfig. https://goo.gl/5Hj3o0. | 231 // TODO(primiano): This should go into TraceConfig. https://goo.gl/5Hj3o0. |
233 bool disable_periodic_dumps_for_testing_; | 232 bool disable_periodic_dumps_for_testing_; |
234 | 233 |
235 DISALLOW_COPY_AND_ASSIGN(MemoryDumpManager); | 234 DISALLOW_COPY_AND_ASSIGN(MemoryDumpManager); |
236 }; | 235 }; |
(...skipping 23 matching lines...) Expand all Loading... |
260 } | 259 } |
261 | 260 |
262 private: | 261 private: |
263 DISALLOW_COPY_AND_ASSIGN(MemoryDumpManagerDelegate); | 262 DISALLOW_COPY_AND_ASSIGN(MemoryDumpManagerDelegate); |
264 }; | 263 }; |
265 | 264 |
266 } // namespace trace_event | 265 } // namespace trace_event |
267 } // namespace base | 266 } // namespace base |
268 | 267 |
269 #endif // BASE_TRACE_EVENT_MEMORY_DUMP_MANAGER_H_ | 268 #endif // BASE_TRACE_EVENT_MEMORY_DUMP_MANAGER_H_ |
OLD | NEW |