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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 uint64 GetTracingProcessId() const; | 98 uint64 GetTracingProcessId() const; |
99 | 99 |
100 // Returns the name for a the allocated_objects dump. Use this to declare | 100 // Returns the name for a the allocated_objects dump. Use this to declare |
101 // suballocator dumps from other dump providers. | 101 // suballocator dumps from other dump providers. |
102 // It will return nullptr if there is no dump provider for the system | 102 // It will return nullptr if there is no dump provider for the system |
103 // allocator registered (which is currently the case for Mac OS). | 103 // allocator registered (which is currently the case for Mac OS). |
104 const char* system_allocator_pool_name() const { | 104 const char* system_allocator_pool_name() const { |
105 return kSystemAllocatorPoolName; | 105 return kSystemAllocatorPoolName; |
106 }; | 106 }; |
107 | 107 |
108 // Tells the initialization phase to skip scheduling periodic memory dumps. | |
109 void DisablePeriodicDumpsForTesting() { | |
110 disable_periodic_dumps_for_testing_ = true; | |
111 } | |
112 | |
113 private: | 108 private: |
114 friend struct DefaultDeleter<MemoryDumpManager>; // For the testing instance. | 109 friend struct DefaultDeleter<MemoryDumpManager>; // For the testing instance. |
115 friend struct DefaultSingletonTraits<MemoryDumpManager>; | 110 friend struct DefaultSingletonTraits<MemoryDumpManager>; |
116 friend class MemoryDumpManagerDelegate; | 111 friend class MemoryDumpManagerDelegate; |
117 friend class MemoryDumpManagerTest; | 112 friend class MemoryDumpManagerTest; |
118 | 113 |
119 // Descriptor struct used to hold information about registered MDPs. It is | 114 // Descriptor struct used to hold information about registered MDPs. It is |
120 // deliberately copyable, in order to allow it to be used as std::set value. | 115 // deliberately copyable, in order to allow it to be used as std::set value. |
121 struct MemoryDumpProviderInfo { | 116 struct MemoryDumpProviderInfo { |
122 MemoryDumpProviderInfo( | 117 MemoryDumpProviderInfo( |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 // For time-triggered periodic dumps. | 221 // For time-triggered periodic dumps. |
227 RepeatingTimer<MemoryDumpManager> periodic_dump_timer_; | 222 RepeatingTimer<MemoryDumpManager> periodic_dump_timer_; |
228 | 223 |
229 // The unique id of the child process. This is created only for tracing and is | 224 // The unique id of the child process. This is created only for tracing and is |
230 // expected to be valid only when tracing is enabled. | 225 // expected to be valid only when tracing is enabled. |
231 uint64 tracing_process_id_; | 226 uint64 tracing_process_id_; |
232 | 227 |
233 // Skips the auto-registration of the core dumpers during Initialize(). | 228 // Skips the auto-registration of the core dumpers during Initialize(). |
234 bool skip_core_dumpers_auto_registration_for_testing_; | 229 bool skip_core_dumpers_auto_registration_for_testing_; |
235 | 230 |
236 // When true, the initialization phase does not start the periodic memory | |
237 // dumps. | |
238 // TODO(primiano): This should go into TraceConfig. https://goo.gl/5Hj3o0. | |
239 bool disable_periodic_dumps_for_testing_; | |
240 | |
241 DISALLOW_COPY_AND_ASSIGN(MemoryDumpManager); | 231 DISALLOW_COPY_AND_ASSIGN(MemoryDumpManager); |
242 }; | 232 }; |
243 | 233 |
244 // The delegate is supposed to be long lived (read: a Singleton) and thread | 234 // The delegate is supposed to be long lived (read: a Singleton) and thread |
245 // safe (i.e. should expect calls from any thread and handle thread hopping). | 235 // safe (i.e. should expect calls from any thread and handle thread hopping). |
246 class BASE_EXPORT MemoryDumpManagerDelegate { | 236 class BASE_EXPORT MemoryDumpManagerDelegate { |
247 public: | 237 public: |
248 virtual void RequestGlobalMemoryDump(const MemoryDumpRequestArgs& args, | 238 virtual void RequestGlobalMemoryDump(const MemoryDumpRequestArgs& args, |
249 const MemoryDumpCallback& callback) = 0; | 239 const MemoryDumpCallback& callback) = 0; |
250 | 240 |
(...skipping 11 matching lines...) Expand all Loading... |
262 } | 252 } |
263 | 253 |
264 private: | 254 private: |
265 DISALLOW_COPY_AND_ASSIGN(MemoryDumpManagerDelegate); | 255 DISALLOW_COPY_AND_ASSIGN(MemoryDumpManagerDelegate); |
266 }; | 256 }; |
267 | 257 |
268 } // namespace trace_event | 258 } // namespace trace_event |
269 } // namespace base | 259 } // namespace base |
270 | 260 |
271 #endif // BASE_TRACE_EVENT_MEMORY_DUMP_MANAGER_H_ | 261 #endif // BASE_TRACE_EVENT_MEMORY_DUMP_MANAGER_H_ |
OLD | NEW |