| 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/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 #include <memory> | 9 #include <memory> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 if (trace_event && handle) | 301 if (trace_event && handle) |
| 302 MakeHandle(chunk_->seq(), chunk_index_, event_index, handle); | 302 MakeHandle(chunk_->seq(), chunk_index_, event_index, handle); |
| 303 | 303 |
| 304 return trace_event; | 304 return trace_event; |
| 305 } | 305 } |
| 306 | 306 |
| 307 void TraceLog::ThreadLocalEventBuffer::WillDestroyCurrentMessageLoop() { | 307 void TraceLog::ThreadLocalEventBuffer::WillDestroyCurrentMessageLoop() { |
| 308 delete this; | 308 delete this; |
| 309 } | 309 } |
| 310 | 310 |
| 311 bool TraceLog::ThreadLocalEventBuffer::OnMemoryDump(const MemoryDumpArgs& args, | 311 bool TraceLog::ThreadLocalEventBuffer::OnMemoryDump( |
| 312 ProcessMemoryDump* pmd) { | 312 const MemoryDumpArgs& /* args */, |
| 313 ProcessMemoryDump* pmd) { |
| 313 if (!chunk_) | 314 if (!chunk_) |
| 314 return true; | 315 return true; |
| 315 std::string dump_base_name = StringPrintf( | 316 std::string dump_base_name = StringPrintf( |
| 316 "tracing/thread_%d", static_cast<int>(PlatformThread::CurrentId())); | 317 "tracing/thread_%d", static_cast<int>(PlatformThread::CurrentId())); |
| 317 TraceEventMemoryOverhead overhead; | 318 TraceEventMemoryOverhead overhead; |
| 318 chunk_->EstimateTraceMemoryOverhead(&overhead); | 319 chunk_->EstimateTraceMemoryOverhead(&overhead); |
| 319 overhead.DumpInto(dump_base_name.c_str(), pmd); | 320 overhead.DumpInto(dump_base_name.c_str(), pmd); |
| 320 return true; | 321 return true; |
| 321 } | 322 } |
| 322 | 323 |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 407 !CheckGeneration(thread_local_event_buffer->generation())) { | 408 !CheckGeneration(thread_local_event_buffer->generation())) { |
| 408 delete thread_local_event_buffer; | 409 delete thread_local_event_buffer; |
| 409 thread_local_event_buffer = NULL; | 410 thread_local_event_buffer = NULL; |
| 410 } | 411 } |
| 411 if (!thread_local_event_buffer) { | 412 if (!thread_local_event_buffer) { |
| 412 thread_local_event_buffer = new ThreadLocalEventBuffer(this); | 413 thread_local_event_buffer = new ThreadLocalEventBuffer(this); |
| 413 thread_local_event_buffer_.Set(thread_local_event_buffer); | 414 thread_local_event_buffer_.Set(thread_local_event_buffer); |
| 414 } | 415 } |
| 415 } | 416 } |
| 416 | 417 |
| 417 bool TraceLog::OnMemoryDump(const MemoryDumpArgs& args, | 418 bool TraceLog::OnMemoryDump(const MemoryDumpArgs& /* args */, |
| 418 ProcessMemoryDump* pmd) { | 419 ProcessMemoryDump* pmd) { |
| 419 // TODO(ssid): Use MemoryDumpArgs to create light dumps when requested | 420 // TODO(ssid): Use MemoryDumpArgs to create light dumps when requested |
| 420 // (crbug.com/499731). | 421 // (crbug.com/499731). |
| 421 TraceEventMemoryOverhead overhead; | 422 TraceEventMemoryOverhead overhead; |
| 422 overhead.Add("TraceLog", sizeof(*this)); | 423 overhead.Add("TraceLog", sizeof(*this)); |
| 423 { | 424 { |
| 424 AutoLock lock(lock_); | 425 AutoLock lock(lock_); |
| 425 if (logged_events_) | 426 if (logged_events_) |
| 426 logged_events_->EstimateTraceMemoryOverhead(&overhead); | 427 logged_events_->EstimateTraceMemoryOverhead(&overhead); |
| 427 | 428 |
| (...skipping 1358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1786 } | 1787 } |
| 1787 | 1788 |
| 1788 ScopedTraceBinaryEfficient::~ScopedTraceBinaryEfficient() { | 1789 ScopedTraceBinaryEfficient::~ScopedTraceBinaryEfficient() { |
| 1789 if (*category_group_enabled_) { | 1790 if (*category_group_enabled_) { |
| 1790 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(category_group_enabled_, name_, | 1791 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(category_group_enabled_, name_, |
| 1791 event_handle_); | 1792 event_handle_); |
| 1792 } | 1793 } |
| 1793 } | 1794 } |
| 1794 | 1795 |
| 1795 } // namespace trace_event_internal | 1796 } // namespace trace_event_internal |
| OLD | NEW |