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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 // allocator registered (which is currently the case for Mac OS). | 134 // allocator registered (which is currently the case for Mac OS). |
135 const char* system_allocator_pool_name() const { | 135 const char* system_allocator_pool_name() const { |
136 return kSystemAllocatorPoolName; | 136 return kSystemAllocatorPoolName; |
137 }; | 137 }; |
138 | 138 |
139 // When set to true, calling |RegisterMemoryDumpProvider| is a no-op. | 139 // When set to true, calling |RegisterMemoryDumpProvider| is a no-op. |
140 void set_dumper_registrations_ignored_for_testing(bool ignored) { | 140 void set_dumper_registrations_ignored_for_testing(bool ignored) { |
141 dumper_registrations_ignored_for_testing_ = ignored; | 141 dumper_registrations_ignored_for_testing_ = ignored; |
142 } | 142 } |
143 | 143 |
144 // Resets the dump provider whitelist to the list given. | |
145 void set_dump_provider_whitelist_for_testing(const char* const* list) { | |
146 dump_provider_whitelist_ = list; | |
147 } | |
148 | |
149 private: | 144 private: |
150 friend std::default_delete<MemoryDumpManager>; // For the testing instance. | 145 friend std::default_delete<MemoryDumpManager>; // For the testing instance. |
151 friend struct DefaultSingletonTraits<MemoryDumpManager>; | 146 friend struct DefaultSingletonTraits<MemoryDumpManager>; |
152 friend class MemoryDumpManagerDelegate; | 147 friend class MemoryDumpManagerDelegate; |
153 friend class MemoryDumpManagerTest; | 148 friend class MemoryDumpManagerTest; |
154 | 149 |
155 // Descriptor used to hold information about registered MDPs. | 150 // Descriptor used to hold information about registered MDPs. |
156 // Some important considerations about lifetime of this object: | 151 // Some important considerations about lifetime of this object: |
157 // - In nominal conditions, all the MemoryDumpProviderInfo instances live in | 152 // - In nominal conditions, all the MemoryDumpProviderInfo instances live in |
158 // the |dump_providers_| collection (% unregistration while dumping). | 153 // the |dump_providers_| collection (% unregistration while dumping). |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 struct ProcessMemoryDumpAsyncState { | 218 struct ProcessMemoryDumpAsyncState { |
224 ProcessMemoryDumpAsyncState( | 219 ProcessMemoryDumpAsyncState( |
225 MemoryDumpRequestArgs req_args, | 220 MemoryDumpRequestArgs req_args, |
226 const MemoryDumpProviderInfo::OrderedSet& dump_providers, | 221 const MemoryDumpProviderInfo::OrderedSet& dump_providers, |
227 scoped_refptr<MemoryDumpSessionState> session_state, | 222 scoped_refptr<MemoryDumpSessionState> session_state, |
228 MemoryDumpCallback callback, | 223 MemoryDumpCallback callback, |
229 scoped_refptr<SingleThreadTaskRunner> dump_thread_task_runner); | 224 scoped_refptr<SingleThreadTaskRunner> dump_thread_task_runner); |
230 ~ProcessMemoryDumpAsyncState(); | 225 ~ProcessMemoryDumpAsyncState(); |
231 | 226 |
232 // Gets or creates the memory dump container for the given target process. | 227 // Gets or creates the memory dump container for the given target process. |
233 ProcessMemoryDump* GetOrCreateMemoryDumpContainerForProcess(ProcessId pid); | 228 ProcessMemoryDump* GetOrCreateMemoryDumpContainerForProcess( |
| 229 ProcessId pid, |
| 230 const MemoryDumpArgs& dump_args); |
234 | 231 |
235 // A map of ProcessId -> ProcessMemoryDump, one for each target process | 232 // A map of ProcessId -> ProcessMemoryDump, one for each target process |
236 // being dumped from the current process. Typically each process dumps only | 233 // being dumped from the current process. Typically each process dumps only |
237 // for itself, unless dump providers specify a different |target_process| in | 234 // for itself, unless dump providers specify a different |target_process| in |
238 // MemoryDumpProvider::Options. | 235 // MemoryDumpProvider::Options. |
239 std::map<ProcessId, std::unique_ptr<ProcessMemoryDump>> process_dumps; | 236 std::map<ProcessId, std::unique_ptr<ProcessMemoryDump>> process_dumps; |
240 | 237 |
241 // The arguments passed to the initial CreateProcessDump() request. | 238 // The arguments passed to the initial CreateProcessDump() request. |
242 const MemoryDumpRequestArgs req_args; | 239 const MemoryDumpRequestArgs req_args; |
243 | 240 |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 // dump_providers_enabled_ list) when tracing is not enabled. | 355 // dump_providers_enabled_ list) when tracing is not enabled. |
359 subtle::AtomicWord memory_tracing_enabled_; | 356 subtle::AtomicWord memory_tracing_enabled_; |
360 | 357 |
361 // For time-triggered periodic dumps. | 358 // For time-triggered periodic dumps. |
362 PeriodicGlobalDumpTimer periodic_dump_timer_; | 359 PeriodicGlobalDumpTimer periodic_dump_timer_; |
363 | 360 |
364 // Thread used for MemoryDumpProviders which don't specify a task runner | 361 // Thread used for MemoryDumpProviders which don't specify a task runner |
365 // affinity. | 362 // affinity. |
366 std::unique_ptr<Thread> dump_thread_; | 363 std::unique_ptr<Thread> dump_thread_; |
367 | 364 |
368 // List of names of the dump providers whitelisted for background mode. | |
369 const char* const* dump_provider_whitelist_; | |
370 | |
371 // The unique id of the child process. This is created only for tracing and is | 365 // The unique id of the child process. This is created only for tracing and is |
372 // expected to be valid only when tracing is enabled. | 366 // expected to be valid only when tracing is enabled. |
373 uint64_t tracing_process_id_; | 367 uint64_t tracing_process_id_; |
374 | 368 |
375 // When true, calling |RegisterMemoryDumpProvider| is a no-op. | 369 // When true, calling |RegisterMemoryDumpProvider| is a no-op. |
376 bool dumper_registrations_ignored_for_testing_; | 370 bool dumper_registrations_ignored_for_testing_; |
377 | 371 |
378 // Whether new memory dump providers should be told to enable heap profiling. | 372 // Whether new memory dump providers should be told to enable heap profiling. |
379 bool heap_profiling_enabled_; | 373 bool heap_profiling_enabled_; |
380 | 374 |
(...skipping 21 matching lines...) Expand all Loading... |
402 } | 396 } |
403 | 397 |
404 private: | 398 private: |
405 DISALLOW_COPY_AND_ASSIGN(MemoryDumpManagerDelegate); | 399 DISALLOW_COPY_AND_ASSIGN(MemoryDumpManagerDelegate); |
406 }; | 400 }; |
407 | 401 |
408 } // namespace trace_event | 402 } // namespace trace_event |
409 } // namespace base | 403 } // namespace base |
410 | 404 |
411 #endif // BASE_TRACE_EVENT_MEMORY_DUMP_MANAGER_H_ | 405 #endif // BASE_TRACE_EVENT_MEMORY_DUMP_MANAGER_H_ |
OLD | NEW |