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

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: adding comments. 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
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"
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 // static 150 // static
151 void MemoryDumpManager::SetInstanceForTesting(MemoryDumpManager* instance) { 151 void MemoryDumpManager::SetInstanceForTesting(MemoryDumpManager* instance) {
152 if (instance) 152 if (instance)
153 instance->skip_core_dumpers_auto_registration_for_testing_ = true; 153 instance->skip_core_dumpers_auto_registration_for_testing_ = true;
154 g_instance_for_testing = instance; 154 g_instance_for_testing = instance;
155 } 155 }
156 156
157 MemoryDumpManager::MemoryDumpManager() 157 MemoryDumpManager::MemoryDumpManager()
158 : delegate_(nullptr), 158 : delegate_(nullptr),
159 memory_tracing_enabled_(0), 159 memory_tracing_enabled_(0),
160 tracing_process_id_(kInvalidTracingProcessId),
160 skip_core_dumpers_auto_registration_for_testing_(false) { 161 skip_core_dumpers_auto_registration_for_testing_(false) {
161 g_next_guid.GetNext(); // Make sure that first guid is not zero. 162 g_next_guid.GetNext(); // Make sure that first guid is not zero.
162 } 163 }
163 164
164 MemoryDumpManager::~MemoryDumpManager() { 165 MemoryDumpManager::~MemoryDumpManager() {
165 base::trace_event::TraceLog::GetInstance()->RemoveEnabledStateObserver(this); 166 base::trace_event::TraceLog::GetInstance()->RemoveEnabledStateObserver(this);
166 } 167 }
167 168
168 void MemoryDumpManager::Initialize() { 169 void MemoryDumpManager::Initialize() {
169 TRACE_EVENT0(kTraceCategory, "init"); // Add to trace-viewer category list. 170 TRACE_EVENT0(kTraceCategory, "init"); // Add to trace-viewer category list.
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 } 426 }
426 } 427 }
427 428
428 void MemoryDumpManager::OnTraceLogDisabled() { 429 void MemoryDumpManager::OnTraceLogDisabled() {
429 AutoLock lock(lock_); 430 AutoLock lock(lock_);
430 periodic_dump_timer_.Stop(); 431 periodic_dump_timer_.Stop();
431 subtle::NoBarrier_Store(&memory_tracing_enabled_, 0); 432 subtle::NoBarrier_Store(&memory_tracing_enabled_, 0);
432 session_state_ = nullptr; 433 session_state_ = nullptr;
433 } 434 }
434 435
436 // static
437 int MemoryDumpManager::ChildProcessIdToTracingProcessId(int child_process_id) {
438 return 1000 + child_process_id;
picksi 2015/06/24 11:12:43 Can we use a named const to explain the 1000, e.g.
jam 2015/06/24 16:38:15 why is this guessable? i.e. why not a hash?
Primiano Tucci (use gerrit) 2015/06/24 17:47:34 +1
439 }
440
435 MemoryDumpManager::MemoryDumpProviderInfo::MemoryDumpProviderInfo( 441 MemoryDumpManager::MemoryDumpProviderInfo::MemoryDumpProviderInfo(
436 const scoped_refptr<SingleThreadTaskRunner>& task_runner) 442 const scoped_refptr<SingleThreadTaskRunner>& task_runner)
437 : task_runner(task_runner), consecutive_failures(0), disabled(false) { 443 : task_runner(task_runner), consecutive_failures(0), disabled(false) {
438 } 444 }
439 MemoryDumpManager::MemoryDumpProviderInfo::~MemoryDumpProviderInfo() { 445 MemoryDumpManager::MemoryDumpProviderInfo::~MemoryDumpProviderInfo() {
440 } 446 }
441 447
442 } // namespace trace_event 448 } // namespace trace_event
443 } // namespace base 449 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698