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 #include "base/trace_event/memory_dump_manager.h" | 5 #include "base/trace_event/memory_dump_manager.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/atomic_sequence_num.h" | 9 #include "base/atomic_sequence_num.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 if (instance) | 90 if (instance) |
91 instance->skip_core_dumpers_auto_registration_for_testing_ = true; | 91 instance->skip_core_dumpers_auto_registration_for_testing_ = true; |
92 g_instance_for_testing = instance; | 92 g_instance_for_testing = instance; |
93 } | 93 } |
94 | 94 |
95 MemoryDumpManager::MemoryDumpManager() | 95 MemoryDumpManager::MemoryDumpManager() |
96 : delegate_(nullptr), | 96 : delegate_(nullptr), |
97 memory_tracing_enabled_(0), | 97 memory_tracing_enabled_(0), |
98 tracing_process_id_(kInvalidTracingProcessId), | 98 tracing_process_id_(kInvalidTracingProcessId), |
99 system_allocator_pool_name_(nullptr), | 99 system_allocator_pool_name_(nullptr), |
100 skip_core_dumpers_auto_registration_for_testing_(false) { | 100 skip_core_dumpers_auto_registration_for_testing_(false), |
| 101 disable_periodic_dumps_for_testing_(false) { |
101 g_next_guid.GetNext(); // Make sure that first guid is not zero. | 102 g_next_guid.GetNext(); // Make sure that first guid is not zero. |
102 } | 103 } |
103 | 104 |
104 MemoryDumpManager::~MemoryDumpManager() { | 105 MemoryDumpManager::~MemoryDumpManager() { |
105 base::trace_event::TraceLog::GetInstance()->RemoveEnabledStateObserver(this); | 106 base::trace_event::TraceLog::GetInstance()->RemoveEnabledStateObserver(this); |
106 } | 107 } |
107 | 108 |
108 void MemoryDumpManager::Initialize() { | 109 void MemoryDumpManager::Initialize() { |
109 TRACE_EVENT0(kTraceCategory, "init"); // Add to trace-viewer category list. | 110 TRACE_EVENT0(kTraceCategory, "init"); // Add to trace-viewer category list. |
110 trace_event::TraceLog::GetInstance()->AddEnabledStateObserver(this); | 111 trace_event::TraceLog::GetInstance()->AddEnabledStateObserver(this); |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
416 for (auto it = dump_providers_.begin(); it != dump_providers_.end(); ++it) { | 417 for (auto it = dump_providers_.begin(); it != dump_providers_.end(); ++it) { |
417 it->disabled = false; | 418 it->disabled = false; |
418 it->consecutive_failures = 0; | 419 it->consecutive_failures = 0; |
419 } | 420 } |
420 | 421 |
421 subtle::NoBarrier_Store(&memory_tracing_enabled_, 1); | 422 subtle::NoBarrier_Store(&memory_tracing_enabled_, 1); |
422 | 423 |
423 // TODO(primiano): This is a temporary hack to disable periodic memory dumps | 424 // TODO(primiano): This is a temporary hack to disable periodic memory dumps |
424 // when running memory benchmarks until they can be enabled/disabled in | 425 // when running memory benchmarks until they can be enabled/disabled in |
425 // base::trace_event::TraceConfig. See https://goo.gl/5Hj3o0. | 426 // base::trace_event::TraceConfig. See https://goo.gl/5Hj3o0. |
| 427 // The same mechanism should be used to disable periodic dumps in tests. |
426 if (delegate_->IsCoordinatorProcess() && | 428 if (delegate_->IsCoordinatorProcess() && |
427 !CommandLine::ForCurrentProcess()->HasSwitch( | 429 !CommandLine::ForCurrentProcess()->HasSwitch( |
428 "enable-memory-benchmarking")) { | 430 "enable-memory-benchmarking") && |
| 431 !disable_periodic_dumps_for_testing_) { |
429 g_periodic_dumps_count = 0; | 432 g_periodic_dumps_count = 0; |
430 periodic_dump_timer_.Start(FROM_HERE, | 433 periodic_dump_timer_.Start(FROM_HERE, |
431 TimeDelta::FromMilliseconds(kDumpIntervalMs), | 434 TimeDelta::FromMilliseconds(kDumpIntervalMs), |
432 base::Bind(&RequestPeriodicGlobalDump)); | 435 base::Bind(&RequestPeriodicGlobalDump)); |
433 } | 436 } |
434 } | 437 } |
435 | 438 |
436 void MemoryDumpManager::OnTraceLogDisabled() { | 439 void MemoryDumpManager::OnTraceLogDisabled() { |
437 AutoLock lock(lock_); | 440 AutoLock lock(lock_); |
438 periodic_dump_timer_.Stop(); | 441 periodic_dump_timer_.Stop(); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
473 next_dump_provider(next_dump_provider), | 476 next_dump_provider(next_dump_provider), |
474 callback(callback), | 477 callback(callback), |
475 task_runner(MessageLoop::current()->task_runner()) { | 478 task_runner(MessageLoop::current()->task_runner()) { |
476 } | 479 } |
477 | 480 |
478 MemoryDumpManager::ProcessMemoryDumpAsyncState::~ProcessMemoryDumpAsyncState() { | 481 MemoryDumpManager::ProcessMemoryDumpAsyncState::~ProcessMemoryDumpAsyncState() { |
479 } | 482 } |
480 | 483 |
481 } // namespace trace_event | 484 } // namespace trace_event |
482 } // namespace base | 485 } // namespace base |
OLD | NEW |