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

Unified Diff: base/trace_event/memory_dump_manager.h

Issue 1308403002: [Tracing] Disable registration of regular dump providers during tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@reland-content-browsertest
Patch Set: Created 5 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: base/trace_event/memory_dump_manager.h
diff --git a/base/trace_event/memory_dump_manager.h b/base/trace_event/memory_dump_manager.h
index dfaf3a1fc9e0e16a226a5f833c50d648e4629fde..240524d0f4a5580d286bde204874f770d4f19a87 100644
--- a/base/trace_event/memory_dump_manager.h
+++ b/base/trace_event/memory_dump_manager.h
@@ -17,6 +17,10 @@
#include "base/trace_event/process_memory_dump.h"
#include "base/trace_event/trace_event.h"
+namespace content {
+class MemoryTracingTest;
Primiano Tucci (use gerrit) 2015/08/24 17:23:34 Hmm no, base should never know anything about cont
Ruud van Asseldonk 2015/08/25 09:51:17 I made |ignore_dumper_registrations_for_testing()|
+}
+
namespace base {
class SingleThreadTaskRunner;
@@ -107,6 +111,7 @@ class BASE_EXPORT MemoryDumpManager : public TraceLog::EnabledStateObserver {
friend struct DefaultSingletonTraits<MemoryDumpManager>;
friend class MemoryDumpManagerDelegate;
friend class MemoryDumpManagerTest;
+ friend class content::MemoryTracingTest;
FRIEND_TEST_ALL_PREFIXES(MemoryDumpManagerTest, DisableFailingDumpers);
FRIEND_TEST_ALL_PREFIXES(MemoryDumpManagerTest,
UnregisterDumperFromThreadWhileDumping);
@@ -208,7 +213,7 @@ class BASE_EXPORT MemoryDumpManager : public TraceLog::EnabledStateObserver {
// Protects from concurrent accesses to the |dump_providers_*| and |delegate_|
// to guard against disabling logging while dumping on another thread.
- Lock lock_;
+ mutable Lock lock_;
Primiano Tucci (use gerrit) 2015/08/24 17:23:34 See comment below, you don't need to use the lock
// Optimization to avoid attempting any memory dump (i.e. to not walk an empty
// dump_providers_enabled_ list) when tracing is not enabled.
@@ -224,8 +229,18 @@ class BASE_EXPORT MemoryDumpManager : public TraceLog::EnabledStateObserver {
// Name of the allocated_objects dump.
const char* system_allocator_pool_name_;
- // Skips the auto-registration of the core dumpers during Initialize().
- bool skip_core_dumpers_auto_registration_for_testing_;
+ // When true, calling RegisterMemoryDumpProvider is a no-op.
+ bool ignore_registrations_for_testing_;
Primiano Tucci (use gerrit) 2015/08/24 17:23:34 I'd name this (and the setter) ignore_dumper_regis
Ruud van Asseldonk 2015/08/25 09:51:17 Done.
+
+ bool ignore_registrations_for_testing() const {
+ AutoLock lock(lock_);
Primiano Tucci (use gerrit) 2015/08/24 17:23:34 If this was production code would have been fine.
Ruud van Asseldonk 2015/08/25 09:51:17 It is used in |MemoryDumpManagerTest::EnableTracin
+ return ignore_registrations_for_testing_;
+ }
+
+ void set_ignore_registrations_for_testing(bool ignore) {
+ AutoLock lock(lock_);
+ ignore_registrations_for_testing_ = ignore;
+ }
// When true, the initialization phase does not start the periodic memory
// dumps.
« no previous file with comments | « no previous file | base/trace_event/memory_dump_manager.cc » ('j') | base/trace_event/memory_dump_manager_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698