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