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

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

Issue 1173263004: [tracing] Send unique tracing process id for cross-process memory dumps identification. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixing DCHECK while setting id. Created 5 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 | « base/trace_event/memory_dump_manager.h ('k') | components/tracing/child_trace_message_filter.h » ('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 #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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 126
126 MemoryDumpManager::GetInstance()->RequestGlobalDump(dump_type); 127 MemoryDumpManager::GetInstance()->RequestGlobalDump(dump_type);
127 } 128 }
128 129
129 void InitializeThreadLocalEventBufferIfSupported() { 130 void InitializeThreadLocalEventBufferIfSupported() {
130 TraceLog::GetInstance()->InitializeThreadLocalEventBufferIfSupported(); 131 TraceLog::GetInstance()->InitializeThreadLocalEventBufferIfSupported();
131 } 132 }
132 133
133 } // namespace 134 } // namespace
134 135
136 // The value -1 is not used as child process id.
137 const int MemoryDumpManager::kInvalidTracingProcessId =
138 MemoryDumpManager::ChildProcessIdToTracingProcessId(-1);
dcheng 2015/06/25 20:28:36 FYI, this introduces a static initializer. Sorry I
139
135 // static 140 // static
136 const char* const MemoryDumpManager::kTraceCategoryForTesting = kTraceCategory; 141 const char* const MemoryDumpManager::kTraceCategoryForTesting = kTraceCategory;
137 142
138 // static 143 // static
139 const int MemoryDumpManager::kMaxConsecutiveFailuresCount = 3; 144 const int MemoryDumpManager::kMaxConsecutiveFailuresCount = 3;
140 145
141 // static 146 // static
142 MemoryDumpManager* MemoryDumpManager::GetInstance() { 147 MemoryDumpManager* MemoryDumpManager::GetInstance() {
143 if (g_instance_for_testing) 148 if (g_instance_for_testing)
144 return g_instance_for_testing; 149 return g_instance_for_testing;
145 150
146 return Singleton<MemoryDumpManager, 151 return Singleton<MemoryDumpManager,
147 LeakySingletonTraits<MemoryDumpManager>>::get(); 152 LeakySingletonTraits<MemoryDumpManager>>::get();
148 } 153 }
149 154
150 // static 155 // static
151 void MemoryDumpManager::SetInstanceForTesting(MemoryDumpManager* instance) { 156 void MemoryDumpManager::SetInstanceForTesting(MemoryDumpManager* instance) {
152 if (instance) 157 if (instance)
153 instance->skip_core_dumpers_auto_registration_for_testing_ = true; 158 instance->skip_core_dumpers_auto_registration_for_testing_ = true;
154 g_instance_for_testing = instance; 159 g_instance_for_testing = instance;
155 } 160 }
156 161
157 MemoryDumpManager::MemoryDumpManager() 162 MemoryDumpManager::MemoryDumpManager()
158 : delegate_(nullptr), 163 : delegate_(nullptr),
159 memory_tracing_enabled_(0), 164 memory_tracing_enabled_(0),
165 tracing_process_id_(kInvalidTracingProcessId),
160 skip_core_dumpers_auto_registration_for_testing_(false) { 166 skip_core_dumpers_auto_registration_for_testing_(false) {
161 g_next_guid.GetNext(); // Make sure that first guid is not zero. 167 g_next_guid.GetNext(); // Make sure that first guid is not zero.
162 } 168 }
163 169
164 MemoryDumpManager::~MemoryDumpManager() { 170 MemoryDumpManager::~MemoryDumpManager() {
165 base::trace_event::TraceLog::GetInstance()->RemoveEnabledStateObserver(this); 171 base::trace_event::TraceLog::GetInstance()->RemoveEnabledStateObserver(this);
166 } 172 }
167 173
168 void MemoryDumpManager::Initialize() { 174 void MemoryDumpManager::Initialize() {
169 TRACE_EVENT0(kTraceCategory, "init"); // Add to trace-viewer category list. 175 TRACE_EVENT0(kTraceCategory, "init"); // Add to trace-viewer category list.
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 } 431 }
426 } 432 }
427 433
428 void MemoryDumpManager::OnTraceLogDisabled() { 434 void MemoryDumpManager::OnTraceLogDisabled() {
429 AutoLock lock(lock_); 435 AutoLock lock(lock_);
430 periodic_dump_timer_.Stop(); 436 periodic_dump_timer_.Stop();
431 subtle::NoBarrier_Store(&memory_tracing_enabled_, 0); 437 subtle::NoBarrier_Store(&memory_tracing_enabled_, 0);
432 session_state_ = nullptr; 438 session_state_ = nullptr;
433 } 439 }
434 440
441 // static
442 int MemoryDumpManager::ChildProcessIdToTracingProcessId(int child_process_id) {
443 return Hash(reinterpret_cast<const char*>(&child_process_id),
444 sizeof(child_process_id));
445 }
446
435 MemoryDumpManager::MemoryDumpProviderInfo::MemoryDumpProviderInfo( 447 MemoryDumpManager::MemoryDumpProviderInfo::MemoryDumpProviderInfo(
436 const scoped_refptr<SingleThreadTaskRunner>& task_runner) 448 const scoped_refptr<SingleThreadTaskRunner>& task_runner)
437 : task_runner(task_runner), consecutive_failures(0), disabled(false) { 449 : task_runner(task_runner), consecutive_failures(0), disabled(false) {
438 } 450 }
439 MemoryDumpManager::MemoryDumpProviderInfo::~MemoryDumpProviderInfo() { 451 MemoryDumpManager::MemoryDumpProviderInfo::~MemoryDumpProviderInfo() {
440 } 452 }
441 453
442 } // namespace trace_event 454 } // namespace trace_event
443 } // namespace base 455 } // namespace base
OLDNEW
« no previous file with comments | « base/trace_event/memory_dump_manager.h ('k') | components/tracing/child_trace_message_filter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698