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 #if defined(OS_WIN) | 9 #if defined(OS_WIN) |
10 #include "base/debug/trace_event_win.h" | 10 #include "base/debug/trace_event_win.h" |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
76 *out += temp_string; | 76 *out += temp_string; |
77 break; | 77 break; |
78 case TRACE_TYPE_POINTER: | 78 case TRACE_TYPE_POINTER: |
79 base::snprintf(temp_string, arraysize(temp_string), "%llu", | 79 base::snprintf(temp_string, arraysize(temp_string), "%llu", |
80 static_cast<unsigned long long>( | 80 static_cast<unsigned long long>( |
81 reinterpret_cast<intptr_t>( | 81 reinterpret_cast<intptr_t>( |
82 as_pointer()))); | 82 as_pointer()))); |
83 *out += temp_string; | 83 *out += temp_string; |
84 break; | 84 break; |
85 case TRACE_TYPE_STRING: | 85 case TRACE_TYPE_STRING: |
86 case TRACE_TYPE_STATIC_STRING: | |
86 *out += "\""; | 87 *out += "\""; |
87 start_pos = out->size(); | 88 start_pos = out->size(); |
88 *out += as_string(); | 89 *out += as_string(); |
89 // replace " character with ' | 90 // replace " character with ' |
90 while ((start_pos = out->find_first_of('\"', start_pos)) != | 91 while ((start_pos = out->find_first_of('\"', start_pos)) != |
91 std::string::npos) | 92 std::string::npos) |
92 (*out)[start_pos] = '\''; | 93 (*out)[start_pos] = '\''; |
93 *out += "\""; | 94 *out += "\""; |
94 break; | 95 break; |
95 default: | 96 default: |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
173 size_t alloc_size = 0; | 174 size_t alloc_size = 0; |
174 if (copy) { | 175 if (copy) { |
175 alloc_size += GetAllocLength(name); | 176 alloc_size += GetAllocLength(name); |
176 alloc_size += GetAllocLength(arg1_name); | 177 alloc_size += GetAllocLength(arg1_name); |
177 alloc_size += GetAllocLength(arg2_name); | 178 alloc_size += GetAllocLength(arg2_name); |
178 } | 179 } |
179 // We always take a copy of string arg_vals, even if |copy| was not set. | 180 // We always take a copy of string arg_vals, even if |copy| was not set. |
180 if (arg1_val.type() == TraceValue::TRACE_TYPE_STRING) | 181 if (arg1_val.type() == TraceValue::TRACE_TYPE_STRING) |
181 alloc_size += GetAllocLength(arg1_val.as_string()); | 182 alloc_size += GetAllocLength(arg1_val.as_string()); |
182 if (arg2_val.type() == TraceValue::TRACE_TYPE_STRING) | 183 if (arg2_val.type() == TraceValue::TRACE_TYPE_STRING) |
183 alloc_size += GetAllocLength(arg2_val.as_string()); | 184 alloc_size += GetAllocLength(arg2_val.as_string()); |
Evan Martin
2011/08/29 22:57:34
For others confused by this CL, this here is the i
| |
184 | 185 |
185 if (alloc_size) { | 186 if (alloc_size) { |
186 parameter_copy_storage_ = new base::RefCountedString; | 187 parameter_copy_storage_ = new base::RefCountedString; |
187 parameter_copy_storage_->data().resize(alloc_size); | 188 parameter_copy_storage_->data().resize(alloc_size); |
188 char* ptr = string_as_array(¶meter_copy_storage_->data()); | 189 char* ptr = string_as_array(¶meter_copy_storage_->data()); |
189 const char* end = ptr + alloc_size; | 190 const char* end = ptr + alloc_size; |
190 if (copy) { | 191 if (copy) { |
191 CopyTraceEventParameter(&ptr, &name_, end); | 192 CopyTraceEventParameter(&ptr, &name_, end); |
192 CopyTraceEventParameter(&ptr, &arg_names_[0], end); | 193 CopyTraceEventParameter(&ptr, &arg_names_[0], end); |
193 CopyTraceEventParameter(&ptr, &arg_names_[1], end); | 194 CopyTraceEventParameter(&ptr, &arg_names_[1], end); |
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
525 p_data_->name, | 526 p_data_->name, |
526 NULL, 0, NULL, 0, | 527 NULL, 0, NULL, 0, |
527 p_data_->threshold_begin_id, p_data_->threshold, false); | 528 p_data_->threshold_begin_id, p_data_->threshold, false); |
528 } | 529 } |
529 } | 530 } |
530 | 531 |
531 } // namespace internal | 532 } // namespace internal |
532 | 533 |
533 } // namespace debug | 534 } // namespace debug |
534 } // namespace base | 535 } // namespace base |
OLD | NEW |