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

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

Issue 1211883003: Revert of [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: 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"
12 #include "base/thread_task_runner_handle.h" 11 #include "base/thread_task_runner_handle.h"
13 #include "base/trace_event/memory_dump_provider.h" 12 #include "base/trace_event/memory_dump_provider.h"
14 #include "base/trace_event/memory_dump_session_state.h" 13 #include "base/trace_event/memory_dump_session_state.h"
15 #include "base/trace_event/process_memory_dump.h" 14 #include "base/trace_event/process_memory_dump.h"
16 #include "base/trace_event/trace_event_argument.h" 15 #include "base/trace_event/trace_event_argument.h"
17 #include "build/build_config.h" 16 #include "build/build_config.h"
18 17
19 #if !defined(OS_NACL) 18 #if !defined(OS_NACL)
20 #include "base/trace_event/process_memory_totals_dump_provider.h" 19 #include "base/trace_event/process_memory_totals_dump_provider.h"
21 #endif 20 #endif
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 125
127 MemoryDumpManager::GetInstance()->RequestGlobalDump(dump_type); 126 MemoryDumpManager::GetInstance()->RequestGlobalDump(dump_type);
128 } 127 }
129 128
130 void InitializeThreadLocalEventBufferIfSupported() { 129 void InitializeThreadLocalEventBufferIfSupported() {
131 TraceLog::GetInstance()->InitializeThreadLocalEventBufferIfSupported(); 130 TraceLog::GetInstance()->InitializeThreadLocalEventBufferIfSupported();
132 } 131 }
133 132
134 } // namespace 133 } // namespace
135 134
136 // The value -1 is not used as child process id.
137 const int MemoryDumpManager::kInvalidTracingProcessId =
138 MemoryDumpManager::ChildProcessIdToTracingProcessId(-1);
139
140 // static 135 // static
141 const char* const MemoryDumpManager::kTraceCategoryForTesting = kTraceCategory; 136 const char* const MemoryDumpManager::kTraceCategoryForTesting = kTraceCategory;
142 137
143 // static 138 // static
144 const int MemoryDumpManager::kMaxConsecutiveFailuresCount = 3; 139 const int MemoryDumpManager::kMaxConsecutiveFailuresCount = 3;
145 140
146 // static 141 // static
147 MemoryDumpManager* MemoryDumpManager::GetInstance() { 142 MemoryDumpManager* MemoryDumpManager::GetInstance() {
148 if (g_instance_for_testing) 143 if (g_instance_for_testing)
149 return g_instance_for_testing; 144 return g_instance_for_testing;
150 145
151 return Singleton<MemoryDumpManager, 146 return Singleton<MemoryDumpManager,
152 LeakySingletonTraits<MemoryDumpManager>>::get(); 147 LeakySingletonTraits<MemoryDumpManager>>::get();
153 } 148 }
154 149
155 // static 150 // static
156 void MemoryDumpManager::SetInstanceForTesting(MemoryDumpManager* instance) { 151 void MemoryDumpManager::SetInstanceForTesting(MemoryDumpManager* instance) {
157 if (instance) 152 if (instance)
158 instance->skip_core_dumpers_auto_registration_for_testing_ = true; 153 instance->skip_core_dumpers_auto_registration_for_testing_ = true;
159 g_instance_for_testing = instance; 154 g_instance_for_testing = instance;
160 } 155 }
161 156
162 MemoryDumpManager::MemoryDumpManager() 157 MemoryDumpManager::MemoryDumpManager()
163 : delegate_(nullptr), 158 : delegate_(nullptr),
164 memory_tracing_enabled_(0), 159 memory_tracing_enabled_(0),
165 tracing_process_id_(kInvalidTracingProcessId),
166 skip_core_dumpers_auto_registration_for_testing_(false) { 160 skip_core_dumpers_auto_registration_for_testing_(false) {
167 g_next_guid.GetNext(); // Make sure that first guid is not zero. 161 g_next_guid.GetNext(); // Make sure that first guid is not zero.
168 } 162 }
169 163
170 MemoryDumpManager::~MemoryDumpManager() { 164 MemoryDumpManager::~MemoryDumpManager() {
171 base::trace_event::TraceLog::GetInstance()->RemoveEnabledStateObserver(this); 165 base::trace_event::TraceLog::GetInstance()->RemoveEnabledStateObserver(this);
172 } 166 }
173 167
174 void MemoryDumpManager::Initialize() { 168 void MemoryDumpManager::Initialize() {
175 TRACE_EVENT0(kTraceCategory, "init"); // Add to trace-viewer category list. 169 TRACE_EVENT0(kTraceCategory, "init"); // Add to trace-viewer category list.
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 } 425 }
432 } 426 }
433 427
434 void MemoryDumpManager::OnTraceLogDisabled() { 428 void MemoryDumpManager::OnTraceLogDisabled() {
435 AutoLock lock(lock_); 429 AutoLock lock(lock_);
436 periodic_dump_timer_.Stop(); 430 periodic_dump_timer_.Stop();
437 subtle::NoBarrier_Store(&memory_tracing_enabled_, 0); 431 subtle::NoBarrier_Store(&memory_tracing_enabled_, 0);
438 session_state_ = nullptr; 432 session_state_ = nullptr;
439 } 433 }
440 434
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
447 MemoryDumpManager::MemoryDumpProviderInfo::MemoryDumpProviderInfo( 435 MemoryDumpManager::MemoryDumpProviderInfo::MemoryDumpProviderInfo(
448 const scoped_refptr<SingleThreadTaskRunner>& task_runner) 436 const scoped_refptr<SingleThreadTaskRunner>& task_runner)
449 : task_runner(task_runner), consecutive_failures(0), disabled(false) { 437 : task_runner(task_runner), consecutive_failures(0), disabled(false) {
450 } 438 }
451 MemoryDumpManager::MemoryDumpProviderInfo::~MemoryDumpProviderInfo() { 439 MemoryDumpManager::MemoryDumpProviderInfo::~MemoryDumpProviderInfo() {
452 } 440 }
453 441
454 } // namespace trace_event 442 } // namespace trace_event
455 } // namespace base 443 } // 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