Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(19)

Side by Side Diff: base/debug/trace_event_impl.cc

Issue 9213013: Split up trace_event.h into trace_event_impl.h and add webkitplatform support. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: removed webkit changes Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/debug/trace_event_impl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 609 matching lines...) Expand 10 before | Expand all | Expand 10 after
629 const void* id, 630 const void* id,
630 const std::string& extra) 631 const std::string& extra)
631 { 632 {
632 #if defined(OS_WIN) 633 #if defined(OS_WIN)
633 TraceEventETWProvider::Trace(name, phase, id, extra); 634 TraceEventETWProvider::Trace(name, phase, id, extra);
634 #endif 635 #endif
635 INTERNAL_TRACE_EVENT_ADD(phase, "ETW Trace Event", name, 636 INTERNAL_TRACE_EVENT_ADD(phase, "ETW Trace Event", name,
636 TRACE_EVENT_FLAG_COPY, "id", id, "extra", extra); 637 TRACE_EVENT_FLAG_COPY, "id", id, "extra", extra);
637 } 638 }
638 639
639 void TraceLog::AddCounterEvent(const unsigned char* category_enabled,
640 const char* name,
641 unsigned long long id,
642 const char* value1_name, int value1_val,
643 const char* value2_name, int value2_val,
644 unsigned char flags) {
645 int num_args = value2_name ? 2 : 1;
646 const char* arg_names[2] = {value1_name, value2_name};
647 unsigned char arg_types[2];
648 unsigned long long arg_values[2];
649 trace_event_internal::SetTraceValue(value1_val, &arg_types[0],
650 &arg_values[0]);
651 trace_event_internal::SetTraceValue(value2_val, &arg_types[1],
652 &arg_values[1]);
653 AddTraceEvent(TRACE_EVENT_PHASE_COUNTER,
654 category_enabled,
655 name,
656 id,
657 num_args,
658 arg_names,
659 arg_types,
660 arg_values,
661 trace_event_internal::kNoThreshholdBeginId,
662 trace_event_internal::kNoThresholdValue,
663 flags);
664 }
665
666 void TraceLog::AddClockSyncMetadataEvents() { 640 void TraceLog::AddClockSyncMetadataEvents() {
667 #if defined(OS_ANDROID) 641 #if defined(OS_ANDROID)
668 // Since Android does not support sched_setaffinity, we cannot establish clock 642 // Since Android does not support sched_setaffinity, we cannot establish clock
669 // sync unless the scheduler clock is set to global. If the trace_clock file 643 // sync unless the scheduler clock is set to global. If the trace_clock file
670 // can't be read, we will assume the kernel doesn't support tracing and do 644 // can't be read, we will assume the kernel doesn't support tracing and do
671 // nothing. 645 // nothing.
672 std::string clock_mode; 646 std::string clock_mode;
673 if (!file_util::ReadFileToString( 647 if (!file_util::ReadFileToString(
674 FilePath("/sys/kernel/debug/tracing/trace_clock"), 648 FilePath("/sys/kernel/debug/tracing/trace_clock"),
675 &clock_mode)) 649 &clock_mode))
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
737 // Create a FNV hash from the process ID for XORing. 711 // Create a FNV hash from the process ID for XORing.
738 // See http://isthe.com/chongo/tech/comp/fnv/ for algorithm details. 712 // See http://isthe.com/chongo/tech/comp/fnv/ for algorithm details.
739 unsigned long long offset_basis = 14695981039346656037ull; 713 unsigned long long offset_basis = 14695981039346656037ull;
740 unsigned long long fnv_prime = 1099511628211ull; 714 unsigned long long fnv_prime = 1099511628211ull;
741 unsigned long long pid = static_cast<unsigned long long>(process_id_); 715 unsigned long long pid = static_cast<unsigned long long>(process_id_);
742 process_id_hash_ = (offset_basis ^ pid) * fnv_prime; 716 process_id_hash_ = (offset_basis ^ pid) * fnv_prime;
743 } 717 }
744 718
745 } // namespace debug 719 } // namespace debug
746 } // namespace base 720 } // 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
OLDNEW
« no previous file with comments | « base/debug/trace_event_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698