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