OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/format_macros.h" | 10 #include "base/format_macros.h" |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 const char* TraceEvent::GetPhaseString(TraceEventPhase phase) { | 216 const char* TraceEvent::GetPhaseString(TraceEventPhase phase) { |
217 switch(phase) { | 217 switch(phase) { |
218 case TRACE_EVENT_PHASE_BEGIN: | 218 case TRACE_EVENT_PHASE_BEGIN: |
219 return "B"; | 219 return "B"; |
220 case TRACE_EVENT_PHASE_INSTANT: | 220 case TRACE_EVENT_PHASE_INSTANT: |
221 return "I"; | 221 return "I"; |
222 case TRACE_EVENT_PHASE_END: | 222 case TRACE_EVENT_PHASE_END: |
223 return "E"; | 223 return "E"; |
224 case TRACE_EVENT_PHASE_METADATA: | 224 case TRACE_EVENT_PHASE_METADATA: |
225 return "M"; | 225 return "M"; |
| 226 case TRACE_EVENT_PHASE_COUNTER: |
| 227 return "C"; |
226 default: | 228 default: |
227 NOTREACHED() << "Invalid phase argument"; | 229 NOTREACHED() << "Invalid phase argument"; |
228 return "?"; | 230 return "?"; |
229 } | 231 } |
230 } | 232 } |
231 | 233 |
232 TraceEventPhase TraceEvent::GetPhase(const char* phase) { | 234 TraceEventPhase TraceEvent::GetPhase(const char* phase) { |
233 switch(*phase) { | 235 switch(*phase) { |
234 case 'B': | 236 case 'B': |
235 return TRACE_EVENT_PHASE_BEGIN; | 237 return TRACE_EVENT_PHASE_BEGIN; |
236 case 'I': | 238 case 'I': |
237 return TRACE_EVENT_PHASE_INSTANT; | 239 return TRACE_EVENT_PHASE_INSTANT; |
238 case 'E': | 240 case 'E': |
239 return TRACE_EVENT_PHASE_END; | 241 return TRACE_EVENT_PHASE_END; |
240 case 'M': | 242 case 'M': |
241 return TRACE_EVENT_PHASE_METADATA; | 243 return TRACE_EVENT_PHASE_METADATA; |
| 244 case 'C': |
| 245 return TRACE_EVENT_PHASE_COUNTER; |
242 default: | 246 default: |
243 NOTREACHED() << "Invalid phase name"; | 247 NOTREACHED() << "Invalid phase name"; |
244 return TRACE_EVENT_PHASE_METADATA; | 248 return TRACE_EVENT_PHASE_METADATA; |
245 } | 249 } |
246 } | 250 } |
247 | 251 |
248 void TraceEvent::AppendEventsAsJSON(const std::vector<TraceEvent>& events, | 252 void TraceEvent::AppendEventsAsJSON(const std::vector<TraceEvent>& events, |
249 size_t start, | 253 size_t start, |
250 size_t count, | 254 size_t count, |
251 std::string* out) { | 255 std::string* out) { |
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
630 const std::string& extra) | 634 const std::string& extra) |
631 { | 635 { |
632 #if defined(OS_WIN) | 636 #if defined(OS_WIN) |
633 TraceEventETWProvider::Trace(name, phase, id, extra); | 637 TraceEventETWProvider::Trace(name, phase, id, extra); |
634 #endif | 638 #endif |
635 INTERNAL_TRACE_EVENT_ADD(phase, | 639 INTERNAL_TRACE_EVENT_ADD(phase, |
636 "ETW Trace Event", name, "id", id, "extra", extra, | 640 "ETW Trace Event", name, "id", id, "extra", extra, |
637 base::debug::TraceLog::EVENT_FLAG_COPY); | 641 base::debug::TraceLog::EVENT_FLAG_COPY); |
638 } | 642 } |
639 | 643 |
| 644 int TraceLog::AddCounterEvent(const TraceCategory* category, |
| 645 const char* name, |
| 646 const char* value1_name, int32 value1_val, |
| 647 const char* value2_name, int32 value2_val, |
| 648 EventFlags flags) { |
| 649 return AddTraceEvent(TRACE_EVENT_PHASE_COUNTER, |
| 650 category, |
| 651 name, |
| 652 value1_name, value1_val, |
| 653 value2_name, value2_val, |
| 654 -1, 0, |
| 655 flags); |
| 656 } |
| 657 |
640 void TraceLog::AddCurrentMetadataEvents() { | 658 void TraceLog::AddCurrentMetadataEvents() { |
641 lock_.AssertAcquired(); | 659 lock_.AssertAcquired(); |
642 for(base::hash_map<PlatformThreadId, std::string>::iterator it = | 660 for(base::hash_map<PlatformThreadId, std::string>::iterator it = |
643 thread_names_.begin(); | 661 thread_names_.begin(); |
644 it != thread_names_.end(); | 662 it != thread_names_.end(); |
645 it++) { | 663 it++) { |
646 if (!it->second.empty()) | 664 if (!it->second.empty()) |
647 logged_events_.push_back( | 665 logged_events_.push_back( |
648 TraceEvent(static_cast<unsigned long>(base::GetCurrentProcId()), | 666 TraceEvent(static_cast<unsigned long>(base::GetCurrentProcId()), |
649 it->first, | 667 it->first, |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
705 NULL, 0, NULL, 0, | 723 NULL, 0, NULL, 0, |
706 p_data_->threshold_begin_id, p_data_->threshold, | 724 p_data_->threshold_begin_id, p_data_->threshold, |
707 TraceLog::EVENT_FLAG_NONE); | 725 TraceLog::EVENT_FLAG_NONE); |
708 } | 726 } |
709 } | 727 } |
710 | 728 |
711 } // namespace internal | 729 } // namespace internal |
712 | 730 |
713 } // namespace debug | 731 } // namespace debug |
714 } // namespace base | 732 } // namespace base |
OLD | NEW |