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 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
8 #include "base/debug/trace_event_win.h" | 8 #include "base/debug/trace_event_win.h" |
9 #endif | 9 #endif |
10 #include "base/format_macros.h" | 10 #include "base/format_macros.h" |
11 #include "base/memory/ref_counted_memory.h" | 11 #include "base/memory/ref_counted_memory.h" |
12 #include "base/process_util.h" | 12 #include "base/process_util.h" |
13 #include "base/stringprintf.h" | 13 #include "base/stringprintf.h" |
14 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
| 15 #include "base/stl_util.h" |
15 #include "base/time.h" | 16 #include "base/time.h" |
16 | 17 |
17 #define USE_UNRELIABLE_NOW | 18 #define USE_UNRELIABLE_NOW |
18 | 19 |
19 namespace base { | 20 namespace base { |
20 namespace debug { | 21 namespace debug { |
21 | 22 |
22 // Controls the number of trace events we will buffer in-memory | 23 // Controls the number of trace events we will buffer in-memory |
23 // before throwing them away. | 24 // before throwing them away. |
24 const size_t kTraceEventBufferSize = 500000; | 25 const size_t kTraceEventBufferSize = 500000; |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 alloc_size += GetAllocLength(arg1_name); | 164 alloc_size += GetAllocLength(arg1_name); |
164 alloc_size += GetAllocLength(arg2_name); | 165 alloc_size += GetAllocLength(arg2_name); |
165 } | 166 } |
166 // We always take a copy of string arg_vals, even if |copy| was not set. | 167 // We always take a copy of string arg_vals, even if |copy| was not set. |
167 if (arg1_val.type() == TraceValue::TRACE_TYPE_STRING) | 168 if (arg1_val.type() == TraceValue::TRACE_TYPE_STRING) |
168 alloc_size += GetAllocLength(arg1_val.as_string()); | 169 alloc_size += GetAllocLength(arg1_val.as_string()); |
169 if (arg2_val.type() == TraceValue::TRACE_TYPE_STRING) | 170 if (arg2_val.type() == TraceValue::TRACE_TYPE_STRING) |
170 alloc_size += GetAllocLength(arg2_val.as_string()); | 171 alloc_size += GetAllocLength(arg2_val.as_string()); |
171 | 172 |
172 if (alloc_size) { | 173 if (alloc_size) { |
173 parameter_copy_storage_ = new RefCountedBytes; | 174 parameter_copy_storage_ = new base::RefCountedString; |
174 parameter_copy_storage_->data.resize(alloc_size); | 175 parameter_copy_storage_->data().resize(alloc_size); |
175 char* ptr = reinterpret_cast<char*>(¶meter_copy_storage_->data[0]); | 176 char* ptr = string_as_array(¶meter_copy_storage_->data()); |
176 const char* end = ptr + alloc_size; | 177 const char* end = ptr + alloc_size; |
177 if (copy) { | 178 if (copy) { |
178 CopyTraceEventParameter(&ptr, &name_, end); | 179 CopyTraceEventParameter(&ptr, &name_, end); |
179 CopyTraceEventParameter(&ptr, &arg_names_[0], end); | 180 CopyTraceEventParameter(&ptr, &arg_names_[0], end); |
180 CopyTraceEventParameter(&ptr, &arg_names_[1], end); | 181 CopyTraceEventParameter(&ptr, &arg_names_[1], end); |
181 } | 182 } |
182 if (arg_values_[0].type() == TraceValue::TRACE_TYPE_STRING) | 183 if (arg_values_[0].type() == TraceValue::TRACE_TYPE_STRING) |
183 CopyTraceEventParameter(&ptr, arg_values_[0].as_assignable_string(), end); | 184 CopyTraceEventParameter(&ptr, arg_values_[0].as_assignable_string(), end); |
184 if (arg_values_[1].type() == TraceValue::TRACE_TYPE_STRING) | 185 if (arg_values_[1].type() == TraceValue::TRACE_TYPE_STRING) |
185 CopyTraceEventParameter(&ptr, arg_values_[1].as_assignable_string(), end); | 186 CopyTraceEventParameter(&ptr, arg_values_[1].as_assignable_string(), end); |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
463 p_data_->name, | 464 p_data_->name, |
464 NULL, 0, NULL, 0, | 465 NULL, 0, NULL, 0, |
465 p_data_->threshold_begin_id, p_data_->threshold, false); | 466 p_data_->threshold_begin_id, p_data_->threshold, false); |
466 } | 467 } |
467 } | 468 } |
468 | 469 |
469 } // namespace internal | 470 } // namespace internal |
470 | 471 |
471 } // namespace debug | 472 } // namespace debug |
472 } // namespace base | 473 } // namespace base |
OLD | NEW |