| 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 | 9 |
| 10 #include "base/base_switches.h" | 10 #include "base/base_switches.h" |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 : trace_log_(trace_log), | 254 : trace_log_(trace_log), |
| 255 chunk_index_(0), | 255 chunk_index_(0), |
| 256 generation_(trace_log->generation()) { | 256 generation_(trace_log->generation()) { |
| 257 // ThreadLocalEventBuffer is created only if the thread has a message loop, so | 257 // ThreadLocalEventBuffer is created only if the thread has a message loop, so |
| 258 // the following message_loop won't be NULL. | 258 // the following message_loop won't be NULL. |
| 259 MessageLoop* message_loop = MessageLoop::current(); | 259 MessageLoop* message_loop = MessageLoop::current(); |
| 260 message_loop->AddDestructionObserver(this); | 260 message_loop->AddDestructionObserver(this); |
| 261 | 261 |
| 262 // This is to report the local memory usage when memory-infra is enabled. | 262 // This is to report the local memory usage when memory-infra is enabled. |
| 263 MemoryDumpManager::GetInstance()->RegisterDumpProvider( | 263 MemoryDumpManager::GetInstance()->RegisterDumpProvider( |
| 264 this, ThreadTaskRunnerHandle::Get()); | 264 this, "ThreadLocalEventBuffer", ThreadTaskRunnerHandle::Get()); |
| 265 | 265 |
| 266 AutoLock lock(trace_log->lock_); | 266 AutoLock lock(trace_log->lock_); |
| 267 trace_log->thread_message_loops_.insert(message_loop); | 267 trace_log->thread_message_loops_.insert(message_loop); |
| 268 } | 268 } |
| 269 | 269 |
| 270 TraceLog::ThreadLocalEventBuffer::~ThreadLocalEventBuffer() { | 270 TraceLog::ThreadLocalEventBuffer::~ThreadLocalEventBuffer() { |
| 271 CheckThisIsCurrentBuffer(); | 271 CheckThisIsCurrentBuffer(); |
| 272 MessageLoop::current()->RemoveDestructionObserver(this); | 272 MessageLoop::current()->RemoveDestructionObserver(this); |
| 273 MemoryDumpManager::GetInstance()->UnregisterDumpProvider(this); | 273 MemoryDumpManager::GetInstance()->UnregisterDumpProvider(this); |
| 274 | 274 |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 } | 389 } |
| 390 | 390 |
| 391 LOG(ERROR) << "Start " << switches::kTraceToConsole | 391 LOG(ERROR) << "Start " << switches::kTraceToConsole |
| 392 << " with CategoryFilter '" << filter << "'."; | 392 << " with CategoryFilter '" << filter << "'."; |
| 393 SetEnabled(TraceConfig(filter, ECHO_TO_CONSOLE), RECORDING_MODE); | 393 SetEnabled(TraceConfig(filter, ECHO_TO_CONSOLE), RECORDING_MODE); |
| 394 } | 394 } |
| 395 #endif | 395 #endif |
| 396 | 396 |
| 397 logged_events_.reset(CreateTraceBuffer()); | 397 logged_events_.reset(CreateTraceBuffer()); |
| 398 | 398 |
| 399 MemoryDumpManager::GetInstance()->RegisterDumpProvider(this); | 399 MemoryDumpManager::GetInstance()->RegisterDumpProvider(this, "TraceLog", |
| 400 nullptr); |
| 400 } | 401 } |
| 401 | 402 |
| 402 TraceLog::~TraceLog() {} | 403 TraceLog::~TraceLog() {} |
| 403 | 404 |
| 404 void TraceLog::InitializeThreadLocalEventBufferIfSupported() { | 405 void TraceLog::InitializeThreadLocalEventBufferIfSupported() { |
| 405 // A ThreadLocalEventBuffer needs the message loop | 406 // A ThreadLocalEventBuffer needs the message loop |
| 406 // - to know when the thread exits; | 407 // - to know when the thread exits; |
| 407 // - to handle the final flush. | 408 // - to handle the final flush. |
| 408 // For a thread without a message loop or the message loop may be blocked, the | 409 // For a thread without a message loop or the message loop may be blocked, the |
| 409 // trace events will be added into the main buffer directly. | 410 // trace events will be added into the main buffer directly. |
| (...skipping 1315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1725 } | 1726 } |
| 1726 | 1727 |
| 1727 ScopedTraceBinaryEfficient::~ScopedTraceBinaryEfficient() { | 1728 ScopedTraceBinaryEfficient::~ScopedTraceBinaryEfficient() { |
| 1728 if (*category_group_enabled_) { | 1729 if (*category_group_enabled_) { |
| 1729 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(category_group_enabled_, name_, | 1730 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(category_group_enabled_, name_, |
| 1730 event_handle_); | 1731 event_handle_); |
| 1731 } | 1732 } |
| 1732 } | 1733 } |
| 1733 | 1734 |
| 1734 } // namespace trace_event_internal | 1735 } // namespace trace_event_internal |
| OLD | NEW |