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 1342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1353 // is in |TraceLog::UpdateTraceEventDuration|. | 1353 // is in |TraceLog::UpdateTraceEventDuration|. |
1354 AllocationContextTracker::GetInstanceForCurrentThread() | 1354 AllocationContextTracker::GetInstanceForCurrentThread() |
1355 ->PopPseudoStackFrame(name); | 1355 ->PopPseudoStackFrame(name); |
1356 } | 1356 } |
1357 } | 1357 } |
1358 | 1358 |
1359 return handle; | 1359 return handle; |
1360 } | 1360 } |
1361 | 1361 |
1362 void TraceLog::AddMetadataEvent( | 1362 void TraceLog::AddMetadataEvent( |
| 1363 char phase, |
1363 const unsigned char* category_group_enabled, | 1364 const unsigned char* category_group_enabled, |
1364 const char* name, | 1365 const char* name, |
| 1366 const TimeTicks& timestamp, |
1365 int num_args, | 1367 int num_args, |
1366 const char** arg_names, | 1368 const char** arg_names, |
1367 const unsigned char* arg_types, | 1369 const unsigned char* arg_types, |
1368 const unsigned long long* arg_values, | 1370 const unsigned long long* arg_values, |
1369 std::unique_ptr<ConvertableToTraceFormat>* convertable_values, | 1371 std::unique_ptr<ConvertableToTraceFormat>* convertable_values, |
1370 unsigned int flags) { | 1372 unsigned int flags) { |
1371 HEAP_PROFILER_SCOPED_IGNORE; | 1373 HEAP_PROFILER_SCOPED_IGNORE; |
1372 std::unique_ptr<TraceEvent> trace_event(new TraceEvent); | 1374 std::unique_ptr<TraceEvent> trace_event(new TraceEvent); |
1373 int thread_id = static_cast<int>(base::PlatformThread::CurrentId()); | 1375 int thread_id = static_cast<int>(base::PlatformThread::CurrentId()); |
1374 ThreadTicks thread_now = ThreadNow(); | 1376 ThreadTicks thread_now = ThreadNow(); |
1375 TimeTicks now = OffsetNow(); | 1377 TimeTicks offset_event_timestamp = OffsetTimestamp(timestamp); |
| 1378 |
1376 AutoLock lock(lock_); | 1379 AutoLock lock(lock_); |
1377 trace_event->Initialize( | 1380 trace_event->Initialize(thread_id, offset_event_timestamp, thread_now, phase, |
1378 thread_id, now, thread_now, TRACE_EVENT_PHASE_METADATA, | 1381 category_group_enabled, name, |
1379 category_group_enabled, name, | 1382 trace_event_internal::kGlobalScope, // scope |
1380 trace_event_internal::kGlobalScope, // scope | 1383 trace_event_internal::kNoId, // id |
1381 trace_event_internal::kNoId, // id | 1384 trace_event_internal::kNoId, // bind_id |
1382 trace_event_internal::kNoId, // bind_id | 1385 num_args, arg_names, arg_types, arg_values, |
1383 num_args, arg_names, arg_types, arg_values, convertable_values, flags); | 1386 convertable_values, flags); |
1384 metadata_events_.push_back(std::move(trace_event)); | 1387 metadata_events_.push_back(std::move(trace_event)); |
1385 } | 1388 } |
1386 | 1389 |
1387 // May be called when a COMPELETE event ends and the unfinished event has been | 1390 // May be called when a COMPELETE event ends and the unfinished event has been |
1388 // recycled (phase == TRACE_EVENT_PHASE_END and trace_event == NULL). | 1391 // recycled (phase == TRACE_EVENT_PHASE_END and trace_event == NULL). |
1389 std::string TraceLog::EventToConsoleMessage(unsigned char phase, | 1392 std::string TraceLog::EventToConsoleMessage(unsigned char phase, |
1390 const TimeTicks& timestamp, | 1393 const TimeTicks& timestamp, |
1391 TraceEvent* trace_event) { | 1394 TraceEvent* trace_event) { |
1392 HEAP_PROFILER_SCOPED_IGNORE; | 1395 HEAP_PROFILER_SCOPED_IGNORE; |
1393 AutoLock thread_info_lock(thread_info_lock_); | 1396 AutoLock thread_info_lock(thread_info_lock_); |
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1786 } | 1789 } |
1787 | 1790 |
1788 ScopedTraceBinaryEfficient::~ScopedTraceBinaryEfficient() { | 1791 ScopedTraceBinaryEfficient::~ScopedTraceBinaryEfficient() { |
1789 if (*category_group_enabled_) { | 1792 if (*category_group_enabled_) { |
1790 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(category_group_enabled_, name_, | 1793 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(category_group_enabled_, name_, |
1791 event_handle_); | 1794 event_handle_); |
1792 } | 1795 } |
1793 } | 1796 } |
1794 | 1797 |
1795 } // namespace trace_event_internal | 1798 } // namespace trace_event_internal |
OLD | NEW |