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

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

Issue 1262333005: [tracing] Introduce MemoryDumpArgs to enable light and heavy dumps (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 5 years, 4 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/trace_log.h ('k') | base/trace_event/winheap_dump_provider_win.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/trace_log.h" 5 #include "base/trace_event/trace_log.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 9
10 #include "base/base_switches.h" 10 #include "base/base_switches.h"
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 return chunk_->GetEventAt(handle.event_index); 220 return chunk_->GetEventAt(handle.event_index);
221 } 221 }
222 222
223 int generation() const { return generation_; } 223 int generation() const { return generation_; }
224 224
225 private: 225 private:
226 // MessageLoop::DestructionObserver 226 // MessageLoop::DestructionObserver
227 void WillDestroyCurrentMessageLoop() override; 227 void WillDestroyCurrentMessageLoop() override;
228 228
229 // MemoryDumpProvider implementation. 229 // MemoryDumpProvider implementation.
230 bool OnMemoryDump(ProcessMemoryDump* pmd) override; 230 bool OnMemoryDump(const MemoryDumpArgs& args,
231 ProcessMemoryDump* pmd) override;
231 232
232 void FlushWhileLocked(); 233 void FlushWhileLocked();
233 234
234 void CheckThisIsCurrentBuffer() const { 235 void CheckThisIsCurrentBuffer() const {
235 DCHECK(trace_log_->thread_local_event_buffer_.Get() == this); 236 DCHECK(trace_log_->thread_local_event_buffer_.Get() == this);
236 } 237 }
237 238
238 // Since TraceLog is a leaky singleton, trace_log_ will always be valid 239 // Since TraceLog is a leaky singleton, trace_log_ will always be valid
239 // as long as the thread exists. 240 // as long as the thread exists.
240 TraceLog* trace_log_; 241 TraceLog* trace_log_;
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 trace_event->UpdateDuration(now, thread_now); 349 trace_event->UpdateDuration(now, thread_now);
349 } 350 }
350 } 351 }
351 overhead_ += overhead; 352 overhead_ += overhead;
352 } 353 }
353 354
354 void TraceLog::ThreadLocalEventBuffer::WillDestroyCurrentMessageLoop() { 355 void TraceLog::ThreadLocalEventBuffer::WillDestroyCurrentMessageLoop() {
355 delete this; 356 delete this;
356 } 357 }
357 358
358 bool TraceLog::ThreadLocalEventBuffer::OnMemoryDump(ProcessMemoryDump* pmd) { 359 bool TraceLog::ThreadLocalEventBuffer::OnMemoryDump(const MemoryDumpArgs& args,
360 ProcessMemoryDump* pmd) {
359 if (!chunk_) 361 if (!chunk_)
360 return true; 362 return true;
361 std::string dump_base_name = StringPrintf( 363 std::string dump_base_name = StringPrintf(
362 "tracing/thread_%d", static_cast<int>(PlatformThread::CurrentId())); 364 "tracing/thread_%d", static_cast<int>(PlatformThread::CurrentId()));
363 TraceEventMemoryOverhead overhead; 365 TraceEventMemoryOverhead overhead;
364 chunk_->EstimateTraceMemoryOverhead(&overhead); 366 chunk_->EstimateTraceMemoryOverhead(&overhead);
365 overhead.DumpInto(dump_base_name.c_str(), pmd); 367 overhead.DumpInto(dump_base_name.c_str(), pmd);
366 return true; 368 return true;
367 } 369 }
368 370
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 !CheckGeneration(thread_local_event_buffer->generation())) { 461 !CheckGeneration(thread_local_event_buffer->generation())) {
460 delete thread_local_event_buffer; 462 delete thread_local_event_buffer;
461 thread_local_event_buffer = NULL; 463 thread_local_event_buffer = NULL;
462 } 464 }
463 if (!thread_local_event_buffer) { 465 if (!thread_local_event_buffer) {
464 thread_local_event_buffer = new ThreadLocalEventBuffer(this); 466 thread_local_event_buffer = new ThreadLocalEventBuffer(this);
465 thread_local_event_buffer_.Set(thread_local_event_buffer); 467 thread_local_event_buffer_.Set(thread_local_event_buffer);
466 } 468 }
467 } 469 }
468 470
469 bool TraceLog::OnMemoryDump(ProcessMemoryDump* pmd) { 471 bool TraceLog::OnMemoryDump(const MemoryDumpArgs& args,
472 ProcessMemoryDump* pmd) {
473 // TODO(ssid): Use MemoryDumpArgs to create light dumps when requested
474 // (crbug.com/499731).
470 TraceEventMemoryOverhead overhead; 475 TraceEventMemoryOverhead overhead;
471 overhead.Add("TraceLog", sizeof(*this)); 476 overhead.Add("TraceLog", sizeof(*this));
472 { 477 {
473 AutoLock lock(lock_); 478 AutoLock lock(lock_);
474 if (logged_events_) 479 if (logged_events_)
475 logged_events_->EstimateTraceMemoryOverhead(&overhead); 480 logged_events_->EstimateTraceMemoryOverhead(&overhead);
476 } 481 }
477 overhead.AddSelf(); 482 overhead.AddSelf();
478 overhead.DumpInto("tracing/main_trace_log", pmd); 483 overhead.DumpInto("tracing/main_trace_log", pmd);
479 return true; 484 return true;
(...skipping 1253 matching lines...) Expand 10 before | Expand all | Expand 10 after
1733 } 1738 }
1734 1739
1735 ScopedTraceBinaryEfficient::~ScopedTraceBinaryEfficient() { 1740 ScopedTraceBinaryEfficient::~ScopedTraceBinaryEfficient() {
1736 if (*category_group_enabled_) { 1741 if (*category_group_enabled_) {
1737 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(category_group_enabled_, name_, 1742 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(category_group_enabled_, name_,
1738 event_handle_); 1743 event_handle_);
1739 } 1744 }
1740 } 1745 }
1741 1746
1742 } // namespace trace_event_internal 1747 } // namespace trace_event_internal
OLDNEW
« no previous file with comments | « base/trace_event/trace_log.h ('k') | base/trace_event/winheap_dump_provider_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698