| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/debug/trace_event.h" | 5 #include "base/debug/trace_event_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/debug/trace_event.h" |
| 10 #include "base/file_util.h" | 11 #include "base/file_util.h" |
| 11 #include "base/format_macros.h" | 12 #include "base/format_macros.h" |
| 12 #include "base/lazy_instance.h" | 13 #include "base/lazy_instance.h" |
| 13 #include "base/memory/singleton.h" | 14 #include "base/memory/singleton.h" |
| 14 #include "base/process_util.h" | 15 #include "base/process_util.h" |
| 15 #include "base/stringprintf.h" | 16 #include "base/stringprintf.h" |
| 16 #include "base/string_tokenizer.h" | 17 #include "base/string_tokenizer.h" |
| 17 #include "base/threading/platform_thread.h" | 18 #include "base/threading/platform_thread.h" |
| 18 #include "base/threading/thread_local.h" | 19 #include "base/threading/thread_local.h" |
| 19 #include "base/utf_string_conversions.h" | 20 #include "base/utf_string_conversions.h" |
| (...skipping 717 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 737 // Create a FNV hash from the process ID for XORing. | 738 // Create a FNV hash from the process ID for XORing. |
| 738 // See http://isthe.com/chongo/tech/comp/fnv/ for algorithm details. | 739 // See http://isthe.com/chongo/tech/comp/fnv/ for algorithm details. |
| 739 unsigned long long offset_basis = 14695981039346656037ull; | 740 unsigned long long offset_basis = 14695981039346656037ull; |
| 740 unsigned long long fnv_prime = 1099511628211ull; | 741 unsigned long long fnv_prime = 1099511628211ull; |
| 741 unsigned long long pid = static_cast<unsigned long long>(process_id_); | 742 unsigned long long pid = static_cast<unsigned long long>(process_id_); |
| 742 process_id_hash_ = (offset_basis ^ pid) * fnv_prime; | 743 process_id_hash_ = (offset_basis ^ pid) * fnv_prime; |
| 743 } | 744 } |
| 744 | 745 |
| 745 } // namespace debug | 746 } // namespace debug |
| 746 } // namespace base | 747 } // namespace base |
| 747 | |
| 748 namespace trace_event_internal { | |
| 749 | |
| 750 void TraceEndOnScopeClose::Initialize(const unsigned char* category_enabled, | |
| 751 const char* name) { | |
| 752 data_.category_enabled = category_enabled; | |
| 753 data_.name = name; | |
| 754 p_data_ = &data_; | |
| 755 } | |
| 756 | |
| 757 void TraceEndOnScopeClose::AddEventIfEnabled() { | |
| 758 // Only called when p_data_ is non-null. | |
| 759 if (*p_data_->category_enabled) { | |
| 760 TRACE_EVENT_API_ADD_TRACE_EVENT( | |
| 761 TRACE_EVENT_PHASE_END, | |
| 762 p_data_->category_enabled, | |
| 763 p_data_->name, kNoEventId, | |
| 764 kZeroNumArgs, NULL, NULL, NULL, | |
| 765 kNoThreshholdBeginId, kNoThresholdValue, TRACE_EVENT_FLAG_NONE); | |
| 766 } | |
| 767 } | |
| 768 | |
| 769 void TraceEndOnScopeCloseThreshold::Initialize( | |
| 770 const unsigned char* category_enabled, | |
| 771 const char* name, | |
| 772 int threshold_begin_id, | |
| 773 long long threshold) { | |
| 774 data_.category_enabled = category_enabled; | |
| 775 data_.name = name; | |
| 776 data_.threshold_begin_id = threshold_begin_id; | |
| 777 data_.threshold = threshold; | |
| 778 p_data_ = &data_; | |
| 779 } | |
| 780 | |
| 781 void TraceEndOnScopeCloseThreshold::AddEventIfEnabled() { | |
| 782 // Only called when p_data_ is non-null. | |
| 783 if (*p_data_->category_enabled) { | |
| 784 TRACE_EVENT_API_ADD_TRACE_EVENT( | |
| 785 TRACE_EVENT_PHASE_END, | |
| 786 p_data_->category_enabled, | |
| 787 p_data_->name, kNoEventId, | |
| 788 kZeroNumArgs, NULL, NULL, NULL, | |
| 789 p_data_->threshold_begin_id, p_data_->threshold, | |
| 790 TRACE_EVENT_FLAG_NONE); | |
| 791 } | |
| 792 } | |
| 793 | |
| 794 } // namespace trace_event_internal | |
| OLD | NEW |