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

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

Issue 2041583003: [tracing] Introduce "allowed_dump_modes" for memory dump config (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@background_config
Patch Set: Created 4 years, 6 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
« no previous file with comments | « no previous file | base/trace_event/memory_dump_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 const MemoryDumpCallback& callback); 108 const MemoryDumpCallback& callback);
109 109
110 // Same as above (still asynchronous), but without callback. 110 // Same as above (still asynchronous), but without callback.
111 void RequestGlobalDump(MemoryDumpType dump_type, 111 void RequestGlobalDump(MemoryDumpType dump_type,
112 MemoryDumpLevelOfDetail level_of_detail); 112 MemoryDumpLevelOfDetail level_of_detail);
113 113
114 // TraceLog::EnabledStateObserver implementation. 114 // TraceLog::EnabledStateObserver implementation.
115 void OnTraceLogEnabled() override; 115 void OnTraceLogEnabled() override;
116 void OnTraceLogDisabled() override; 116 void OnTraceLogDisabled() override;
117 117
118 // Returns true if the dump mode is allowed for current tracing session.
119 bool IsDumpModeAllowed(MemoryDumpLevelOfDetail dump_mode) {
120 return allowed_dump_modes_.find(dump_mode) != allowed_dump_modes_.end();
Primiano Tucci (use gerrit) 2016/06/08 15:48:30 - Let's move this to the .cc file, there is no nee
ssid 2016/06/08 18:04:17 Fixed.
121 }
122
118 // Returns the MemoryDumpSessionState object, which is shared by all the 123 // Returns the MemoryDumpSessionState object, which is shared by all the
119 // ProcessMemoryDump and MemoryAllocatorDump instances through all the tracing 124 // ProcessMemoryDump and MemoryAllocatorDump instances through all the tracing
120 // session lifetime. 125 // session lifetime.
121 const scoped_refptr<MemoryDumpSessionState>& session_state() const { 126 const scoped_refptr<MemoryDumpSessionState>& session_state() const {
122 return session_state_; 127 return session_state_;
123 } 128 }
124 129
125 // Returns a unique id for identifying the processes. The id can be 130 // Returns a unique id for identifying the processes. The id can be
126 // retrieved by child processes only when tracing is enabled. This is 131 // retrieved by child processes only when tracing is enabled. This is
127 // intended to express cross-process sharing of memory dumps on the 132 // intended to express cross-process sharing of memory dumps on the
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 const scoped_refptr<SingleThreadTaskRunner> dump_thread_task_runner; 273 const scoped_refptr<SingleThreadTaskRunner> dump_thread_task_runner;
269 274
270 private: 275 private:
271 DISALLOW_COPY_AND_ASSIGN(ProcessMemoryDumpAsyncState); 276 DISALLOW_COPY_AND_ASSIGN(ProcessMemoryDumpAsyncState);
272 }; 277 };
273 278
274 // Sets up periodic memory dump timers to start global dump requests based on 279 // Sets up periodic memory dump timers to start global dump requests based on
275 // the dump triggers from trace config. 280 // the dump triggers from trace config.
276 class BASE_EXPORT PeriodicGlobalDumpTimer { 281 class BASE_EXPORT PeriodicGlobalDumpTimer {
277 public: 282 public:
278 PeriodicGlobalDumpTimer(); 283 explicit PeriodicGlobalDumpTimer(MemoryDumpManager* mdm);
Primiano Tucci (use gerrit) 2016/06/08 15:48:30 uh why cannot we rely on MDM being a singleton?
ssid 2016/06/08 18:04:17 I did not want to do MDM::GetInstance() multiple t
Primiano Tucci (use gerrit) 2016/06/09 18:46:39 GetInstance is pretty fast and generally nothing c
279 ~PeriodicGlobalDumpTimer(); 284 ~PeriodicGlobalDumpTimer();
280 285
281 void Start(const std::vector<TraceConfig::MemoryDumpConfig::Trigger>& 286 void Start(const std::vector<TraceConfig::MemoryDumpConfig::Trigger>&
282 triggers_list); 287 triggers_list);
283 void Stop(); 288 void Stop();
284 289
285 bool IsRunning(); 290 bool IsRunning();
286 291
287 private: 292 private:
288 // Periodically called by the timer. 293 // Periodically called by the timer.
289 void RequestPeriodicGlobalDump(); 294 void RequestPeriodicGlobalDump();
290 295
296 MemoryDumpManager* mdm_;
297
291 RepeatingTimer timer_; 298 RepeatingTimer timer_;
292 uint32_t periodic_dumps_count_; 299 uint32_t periodic_dumps_count_;
293 uint32_t light_dump_rate_; 300 uint32_t light_dump_rate_;
294 uint32_t heavy_dump_rate_; 301 uint32_t heavy_dump_rate_;
295 302
296 DISALLOW_COPY_AND_ASSIGN(PeriodicGlobalDumpTimer); 303 DISALLOW_COPY_AND_ASSIGN(PeriodicGlobalDumpTimer);
297 }; 304 };
298 305
299 static const int kMaxConsecutiveFailuresCount; 306 static const int kMaxConsecutiveFailuresCount;
300 static const char* const kSystemAllocatorPoolName; 307 static const char* const kSystemAllocatorPoolName;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 MemoryDumpProviderInfo::OrderedSet dump_providers_; 350 MemoryDumpProviderInfo::OrderedSet dump_providers_;
344 351
345 // Shared among all the PMDs to keep state scoped to the tracing session. 352 // Shared among all the PMDs to keep state scoped to the tracing session.
346 scoped_refptr<MemoryDumpSessionState> session_state_; 353 scoped_refptr<MemoryDumpSessionState> session_state_;
347 354
348 MemoryDumpManagerDelegate* delegate_; // Not owned. 355 MemoryDumpManagerDelegate* delegate_; // Not owned.
349 356
350 // When true, this instance is in charge of coordinating periodic dumps. 357 // When true, this instance is in charge of coordinating periodic dumps.
351 bool is_coordinator_; 358 bool is_coordinator_;
352 359
360 // Set of dump modes allowed for the current tracing session by the trace
361 // config.
362 std::set<MemoryDumpLevelOfDetail> allowed_dump_modes_;
Primiano Tucci (use gerrit) 2016/06/08 15:48:30 Can me put ths into the SessionState. Every time i
ssid 2016/06/08 18:04:17 Sorry, fixed this! I should be reading session sta
363
353 // Protects from concurrent accesses to the |dump_providers_*| and |delegate_| 364 // Protects from concurrent accesses to the |dump_providers_*| and |delegate_|
354 // to guard against disabling logging while dumping on another thread. 365 // to guard against disabling logging while dumping on another thread.
355 Lock lock_; 366 Lock lock_;
356 367
357 // Optimization to avoid attempting any memory dump (i.e. to not walk an empty 368 // Optimization to avoid attempting any memory dump (i.e. to not walk an empty
358 // dump_providers_enabled_ list) when tracing is not enabled. 369 // dump_providers_enabled_ list) when tracing is not enabled.
359 subtle::AtomicWord memory_tracing_enabled_; 370 subtle::AtomicWord memory_tracing_enabled_;
360 371
361 // For time-triggered periodic dumps. 372 // For time-triggered periodic dumps.
362 PeriodicGlobalDumpTimer periodic_dump_timer_; 373 PeriodicGlobalDumpTimer periodic_dump_timer_;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 } 413 }
403 414
404 private: 415 private:
405 DISALLOW_COPY_AND_ASSIGN(MemoryDumpManagerDelegate); 416 DISALLOW_COPY_AND_ASSIGN(MemoryDumpManagerDelegate);
406 }; 417 };
407 418
408 } // namespace trace_event 419 } // namespace trace_event
409 } // namespace base 420 } // namespace base
410 421
411 #endif // BASE_TRACE_EVENT_MEMORY_DUMP_MANAGER_H_ 422 #endif // BASE_TRACE_EVENT_MEMORY_DUMP_MANAGER_H_
OLDNEW
« no previous file with comments | « no previous file | base/trace_event/memory_dump_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698