| 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 "gpu/common/gpu_trace_event.h" | 5 #include "gpu/common/gpu_trace_event.h" |
| 6 | 6 |
| 7 #include "base/format_macros.h" | 7 #include "base/format_macros.h" |
| 8 #include "base/process_util.h" | 8 #include "base/process_util.h" |
| 9 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 return "I"; | 50 return "I"; |
| 51 } else if (phase == GPU_TRACE_EVENT_PHASE_END) { | 51 } else if (phase == GPU_TRACE_EVENT_PHASE_END) { |
| 52 return "E"; | 52 return "E"; |
| 53 } else { | 53 } else { |
| 54 DCHECK(false); | 54 DCHECK(false); |
| 55 return "?"; | 55 return "?"; |
| 56 } | 56 } |
| 57 } | 57 } |
| 58 } | 58 } |
| 59 | 59 |
| 60 TraceEvent::TraceEvent() { | 60 TraceEvent::TraceEvent() |
| 61 : processId(0), |
| 62 threadId(0), |
| 63 phase(GPU_TRACE_EVENT_PHASE_BEGIN), |
| 64 category(NULL), |
| 65 name(NULL) { |
| 66 memset(&argNames, 0, sizeof(argNames)); |
| 61 } | 67 } |
| 62 | 68 |
| 63 TraceEvent::~TraceEvent() { | 69 TraceEvent::~TraceEvent() { |
| 64 } | 70 } |
| 65 | 71 |
| 66 | 72 |
| 67 void TraceEvent::AppendAsJSON(std::string* out, | 73 void TraceEvent::AppendAsJSON(std::string* out, |
| 68 const std::vector<TraceEvent>& events) { | 74 const std::vector<TraceEvent>& events) { |
| 69 *out += "["; | 75 *out += "["; |
| 70 for (size_t i = 0; i < events.size(); ++i) { | 76 for (size_t i = 0; i < events.size(); ++i) { |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 { | 128 { |
| 123 logged_events_.reserve(1024); | 129 logged_events_.reserve(1024); |
| 124 } | 130 } |
| 125 | 131 |
| 126 TraceLog::~TraceLog() { | 132 TraceLog::~TraceLog() { |
| 127 } | 133 } |
| 128 | 134 |
| 129 TraceCategory* TraceLog::GetCategory(const char* name) { | 135 TraceCategory* TraceLog::GetCategory(const char* name) { |
| 130 AutoLock lock(lock_); | 136 AutoLock lock(lock_); |
| 131 // TODO(nduca): replace with a hash_map. | 137 // TODO(nduca): replace with a hash_map. |
| 132 for (int i = static_cast<int>(categories_.size()) - 1; i >= 0; i-- ) { | 138 for (int i = static_cast<int>(categories_.size()) - 1; i >= 0; i--) { |
| 133 if (strcmp(categories_[i]->name(), name) == 0) | 139 if (strcmp(categories_[i]->name(), name) == 0) |
| 134 return categories_[i]; | 140 return categories_[i]; |
| 135 } | 141 } |
| 136 TraceCategory* category = new TraceCategory(name, enabled_); | 142 TraceCategory* category = new TraceCategory(name, enabled_); |
| 137 categories_.push_back(category); | 143 categories_.push_back(category); |
| 138 return category; | 144 return category; |
| 139 } | 145 } |
| 140 | 146 |
| 141 void TraceLog::SetEnabled(bool enabled) { | 147 void TraceLog::SetEnabled(bool enabled) { |
| 142 AutoLock lock(lock_); | 148 AutoLock lock(lock_); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 event.argValues[0] = arg1name ? arg1val : ""; | 220 event.argValues[0] = arg1name ? arg1val : ""; |
| 215 event.argNames[1] = arg2name; | 221 event.argNames[1] = arg2name; |
| 216 event.argValues[1] = arg2name ? arg2val : ""; | 222 event.argValues[1] = arg2name ? arg2val : ""; |
| 217 COMPILE_ASSERT(TRACE_MAX_NUM_ARGS == 2, TraceEvent_arc_count_out_of_sync); | 223 COMPILE_ASSERT(TRACE_MAX_NUM_ARGS == 2, TraceEvent_arc_count_out_of_sync); |
| 218 | 224 |
| 219 if (logged_events_.size() > TRACE_EVENT_BUFFER_SIZE) | 225 if (logged_events_.size() > TRACE_EVENT_BUFFER_SIZE) |
| 220 FlushWithLockAlreadyHeld(); | 226 FlushWithLockAlreadyHeld(); |
| 221 } | 227 } |
| 222 | 228 |
| 223 } // namespace gpu | 229 } // namespace gpu |
| OLD | NEW |