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 1370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1381 scoped_ptr<TraceEvent> trace_event(new TraceEvent); | 1381 scoped_ptr<TraceEvent> trace_event(new TraceEvent); |
1382 trace_event->Initialize( | 1382 trace_event->Initialize( |
1383 0, // thread_id | 1383 0, // thread_id |
1384 TimeTicks(), ThreadTicks(), TRACE_EVENT_PHASE_METADATA, | 1384 TimeTicks(), ThreadTicks(), TRACE_EVENT_PHASE_METADATA, |
1385 &g_category_group_enabled[g_category_metadata], name, | 1385 &g_category_group_enabled[g_category_metadata], name, |
1386 trace_event_internal::kNoId, // id | 1386 trace_event_internal::kNoId, // id |
1387 trace_event_internal::kNoId, // context_id | 1387 trace_event_internal::kNoId, // context_id |
1388 trace_event_internal::kNoId, // bind_id | 1388 trace_event_internal::kNoId, // bind_id |
1389 num_args, arg_names, arg_types, arg_values, convertable_values, flags); | 1389 num_args, arg_names, arg_types, arg_values, convertable_values, flags); |
1390 AutoLock lock(lock_); | 1390 AutoLock lock(lock_); |
1391 metadata_events_.push_back(trace_event.Pass()); | 1391 metadata_events_.push_back(std::move(trace_event)); |
1392 } | 1392 } |
1393 | 1393 |
1394 // May be called when a COMPELETE event ends and the unfinished event has been | 1394 // May be called when a COMPELETE event ends and the unfinished event has been |
1395 // recycled (phase == TRACE_EVENT_PHASE_END and trace_event == NULL). | 1395 // recycled (phase == TRACE_EVENT_PHASE_END and trace_event == NULL). |
1396 std::string TraceLog::EventToConsoleMessage(unsigned char phase, | 1396 std::string TraceLog::EventToConsoleMessage(unsigned char phase, |
1397 const TimeTicks& timestamp, | 1397 const TimeTicks& timestamp, |
1398 TraceEvent* trace_event) { | 1398 TraceEvent* trace_event) { |
1399 AutoLock thread_info_lock(thread_info_lock_); | 1399 AutoLock thread_info_lock(thread_info_lock_); |
1400 | 1400 |
1401 // The caller should translate TRACE_EVENT_PHASE_COMPLETE to | 1401 // The caller should translate TRACE_EVENT_PHASE_COMPLETE to |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1522 } | 1522 } |
1523 | 1523 |
1524 uint64 TraceLog::MangleEventId(uint64 id) { | 1524 uint64 TraceLog::MangleEventId(uint64 id) { |
1525 return id ^ process_id_hash_; | 1525 return id ^ process_id_hash_; |
1526 } | 1526 } |
1527 | 1527 |
1528 void TraceLog::AddMetadataEventsWhileLocked() { | 1528 void TraceLog::AddMetadataEventsWhileLocked() { |
1529 lock_.AssertAcquired(); | 1529 lock_.AssertAcquired(); |
1530 | 1530 |
1531 // Copy metadata added by |AddMetadataEvent| into the trace log. | 1531 // Copy metadata added by |AddMetadataEvent| into the trace log. |
1532 for (TraceEvent* event : metadata_events_) | 1532 for (scoped_ptr<TraceEvent>& event : metadata_events_) |
Primiano Tucci (use gerrit)
2015/11/26 15:49:14
+const at this point?
| |
1533 AddEventToThreadSharedChunkWhileLocked(nullptr, false)->CopyFrom(*event); | 1533 AddEventToThreadSharedChunkWhileLocked(nullptr, false)->CopyFrom(*event); |
1534 | 1534 |
1535 #if !defined(OS_NACL) // NaCl shouldn't expose the process id. | 1535 #if !defined(OS_NACL) // NaCl shouldn't expose the process id. |
1536 InitializeMetadataEvent(AddEventToThreadSharedChunkWhileLocked(NULL, false), | 1536 InitializeMetadataEvent(AddEventToThreadSharedChunkWhileLocked(NULL, false), |
1537 0, "num_cpus", "number", | 1537 0, "num_cpus", "number", |
1538 base::SysInfo::NumberOfProcessors()); | 1538 base::SysInfo::NumberOfProcessors()); |
1539 #endif | 1539 #endif |
1540 | 1540 |
1541 int current_thread_id = static_cast<int>(base::PlatformThread::CurrentId()); | 1541 int current_thread_id = static_cast<int>(base::PlatformThread::CurrentId()); |
1542 if (process_sort_index_ != 0) { | 1542 if (process_sort_index_ != 0) { |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1769 } | 1769 } |
1770 | 1770 |
1771 ScopedTraceBinaryEfficient::~ScopedTraceBinaryEfficient() { | 1771 ScopedTraceBinaryEfficient::~ScopedTraceBinaryEfficient() { |
1772 if (*category_group_enabled_) { | 1772 if (*category_group_enabled_) { |
1773 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(category_group_enabled_, name_, | 1773 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(category_group_enabled_, name_, |
1774 event_handle_); | 1774 event_handle_); |
1775 } | 1775 } |
1776 } | 1776 } |
1777 | 1777 |
1778 } // namespace trace_event_internal | 1778 } // namespace trace_event_internal |
OLD | NEW |