Chromium Code Reviews| 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/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 11 #include "base/hash.h" | |
| 12 #include "base/strings/string_number_conversions.h" | |
| 11 #include "base/thread_task_runner_handle.h" | 13 #include "base/thread_task_runner_handle.h" |
| 12 #include "base/trace_event/memory_dump_provider.h" | 14 #include "base/trace_event/memory_dump_provider.h" |
| 13 #include "base/trace_event/memory_dump_session_state.h" | 15 #include "base/trace_event/memory_dump_session_state.h" |
| 14 #include "base/trace_event/process_memory_dump.h" | 16 #include "base/trace_event/process_memory_dump.h" |
| 15 #include "base/trace_event/trace_event_argument.h" | 17 #include "base/trace_event/trace_event_argument.h" |
| 16 #include "build/build_config.h" | 18 #include "build/build_config.h" |
| 17 | 19 |
| 18 #if !defined(OS_NACL) | 20 #if !defined(OS_NACL) |
| 19 #include "base/trace_event/process_memory_totals_dump_provider.h" | 21 #include "base/trace_event/process_memory_totals_dump_provider.h" |
| 20 #endif | 22 #endif |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 150 // static | 152 // static |
| 151 void MemoryDumpManager::SetInstanceForTesting(MemoryDumpManager* instance) { | 153 void MemoryDumpManager::SetInstanceForTesting(MemoryDumpManager* instance) { |
| 152 if (instance) | 154 if (instance) |
| 153 instance->skip_core_dumpers_auto_registration_for_testing_ = true; | 155 instance->skip_core_dumpers_auto_registration_for_testing_ = true; |
| 154 g_instance_for_testing = instance; | 156 g_instance_for_testing = instance; |
| 155 } | 157 } |
| 156 | 158 |
| 157 MemoryDumpManager::MemoryDumpManager() | 159 MemoryDumpManager::MemoryDumpManager() |
| 158 : delegate_(nullptr), | 160 : delegate_(nullptr), |
| 159 memory_tracing_enabled_(0), | 161 memory_tracing_enabled_(0), |
| 162 tracing_process_id_(kInvalidTracingProcessId), | |
| 160 skip_core_dumpers_auto_registration_for_testing_(false) { | 163 skip_core_dumpers_auto_registration_for_testing_(false) { |
| 161 g_next_guid.GetNext(); // Make sure that first guid is not zero. | 164 g_next_guid.GetNext(); // Make sure that first guid is not zero. |
| 162 } | 165 } |
| 163 | 166 |
| 164 MemoryDumpManager::~MemoryDumpManager() { | 167 MemoryDumpManager::~MemoryDumpManager() { |
| 165 base::trace_event::TraceLog::GetInstance()->RemoveEnabledStateObserver(this); | 168 base::trace_event::TraceLog::GetInstance()->RemoveEnabledStateObserver(this); |
| 166 } | 169 } |
| 167 | 170 |
| 168 void MemoryDumpManager::Initialize() { | 171 void MemoryDumpManager::Initialize() { |
| 169 TRACE_EVENT0(kTraceCategory, "init"); // Add to trace-viewer category list. | 172 TRACE_EVENT0(kTraceCategory, "init"); // Add to trace-viewer category list. |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 425 } | 428 } |
| 426 } | 429 } |
| 427 | 430 |
| 428 void MemoryDumpManager::OnTraceLogDisabled() { | 431 void MemoryDumpManager::OnTraceLogDisabled() { |
| 429 AutoLock lock(lock_); | 432 AutoLock lock(lock_); |
| 430 periodic_dump_timer_.Stop(); | 433 periodic_dump_timer_.Stop(); |
| 431 subtle::NoBarrier_Store(&memory_tracing_enabled_, 0); | 434 subtle::NoBarrier_Store(&memory_tracing_enabled_, 0); |
| 432 session_state_ = nullptr; | 435 session_state_ = nullptr; |
| 433 } | 436 } |
| 434 | 437 |
| 438 // static | |
| 439 int MemoryDumpManager::ChildProcessIdToTracingProcessId(int child_process_id) { | |
| 440 return Hash(IntToString(child_process_id)); | |
|
Primiano Tucci (use gerrit)
2015/06/24 17:47:35
Ok for the Hash, but do:
Hash(reinterpret_cast<con
| |
| 441 } | |
| 442 | |
| 435 MemoryDumpManager::MemoryDumpProviderInfo::MemoryDumpProviderInfo( | 443 MemoryDumpManager::MemoryDumpProviderInfo::MemoryDumpProviderInfo( |
| 436 const scoped_refptr<SingleThreadTaskRunner>& task_runner) | 444 const scoped_refptr<SingleThreadTaskRunner>& task_runner) |
| 437 : task_runner(task_runner), consecutive_failures(0), disabled(false) { | 445 : task_runner(task_runner), consecutive_failures(0), disabled(false) { |
| 438 } | 446 } |
| 439 MemoryDumpManager::MemoryDumpProviderInfo::~MemoryDumpProviderInfo() { | 447 MemoryDumpManager::MemoryDumpProviderInfo::~MemoryDumpProviderInfo() { |
| 440 } | 448 } |
| 441 | 449 |
| 442 } // namespace trace_event | 450 } // namespace trace_event |
| 443 } // namespace base | 451 } // namespace base |
| OLD | NEW |