| OLD | NEW |
| 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/trace_event/trace_event_impl.h" | 5 #include "base/trace_event/trace_event_impl.h" |
| 6 | 6 |
| 7 #include "base/format_macros.h" | 7 #include "base/format_macros.h" |
| 8 #include "base/json/string_escape.h" | 8 #include "base/json/string_escape.h" |
| 9 #include "base/process/process_handle.h" | 9 #include "base/process/process_handle.h" |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 for (int i = 0; i < kTraceMaxNumArgs; ++i) { | 72 for (int i = 0; i < kTraceMaxNumArgs; ++i) { |
| 73 arg_names_[i] = other.arg_names_[i]; | 73 arg_names_[i] = other.arg_names_[i]; |
| 74 arg_types_[i] = other.arg_types_[i]; | 74 arg_types_[i] = other.arg_types_[i]; |
| 75 arg_values_[i] = other.arg_values_[i]; | 75 arg_values_[i] = other.arg_values_[i]; |
| 76 convertable_values_[i] = other.convertable_values_[i]; | 76 convertable_values_[i] = other.convertable_values_[i]; |
| 77 } | 77 } |
| 78 } | 78 } |
| 79 | 79 |
| 80 void TraceEvent::Initialize( | 80 void TraceEvent::Initialize( |
| 81 int thread_id, | 81 int thread_id, |
| 82 TraceTicks timestamp, | 82 TimeTicks timestamp, |
| 83 ThreadTicks thread_timestamp, | 83 ThreadTicks thread_timestamp, |
| 84 char phase, | 84 char phase, |
| 85 const unsigned char* category_group_enabled, | 85 const unsigned char* category_group_enabled, |
| 86 const char* name, | 86 const char* name, |
| 87 unsigned long long id, | 87 unsigned long long id, |
| 88 unsigned long long context_id, | 88 unsigned long long context_id, |
| 89 unsigned long long bind_id, | 89 unsigned long long bind_id, |
| 90 int num_args, | 90 int num_args, |
| 91 const char** arg_names, | 91 const char** arg_names, |
| 92 const unsigned char* arg_types, | 92 const unsigned char* arg_types, |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 | 170 |
| 171 void TraceEvent::Reset() { | 171 void TraceEvent::Reset() { |
| 172 // Only reset fields that won't be initialized in Initialize(), or that may | 172 // Only reset fields that won't be initialized in Initialize(), or that may |
| 173 // hold references to other objects. | 173 // hold references to other objects. |
| 174 duration_ = TimeDelta::FromInternalValue(-1); | 174 duration_ = TimeDelta::FromInternalValue(-1); |
| 175 parameter_copy_storage_ = NULL; | 175 parameter_copy_storage_ = NULL; |
| 176 for (int i = 0; i < kTraceMaxNumArgs; ++i) | 176 for (int i = 0; i < kTraceMaxNumArgs; ++i) |
| 177 convertable_values_[i] = NULL; | 177 convertable_values_[i] = NULL; |
| 178 } | 178 } |
| 179 | 179 |
| 180 void TraceEvent::UpdateDuration(const TraceTicks& now, | 180 void TraceEvent::UpdateDuration(const TimeTicks& now, |
| 181 const ThreadTicks& thread_now) { | 181 const ThreadTicks& thread_now) { |
| 182 DCHECK_EQ(duration_.ToInternalValue(), -1); | 182 DCHECK_EQ(duration_.ToInternalValue(), -1); |
| 183 duration_ = now - timestamp_; | 183 duration_ = now - timestamp_; |
| 184 | 184 |
| 185 // |thread_timestamp_| can be empty if the thread ticks clock wasn't | 185 // |thread_timestamp_| can be empty if the thread ticks clock wasn't |
| 186 // initialized when it was recorded. | 186 // initialized when it was recorded. |
| 187 if (thread_timestamp_ != ThreadTicks()) | 187 if (thread_timestamp_ != ThreadTicks()) |
| 188 thread_duration_ = thread_now - thread_timestamp_; | 188 thread_duration_ = thread_now - thread_timestamp_; |
| 189 } | 189 } |
| 190 | 190 |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 416 AppendValueAsJSON(arg_types_[i], arg_values_[i], &value_as_text); | 416 AppendValueAsJSON(arg_types_[i], arg_values_[i], &value_as_text); |
| 417 | 417 |
| 418 *out << value_as_text; | 418 *out << value_as_text; |
| 419 } | 419 } |
| 420 *out << "}"; | 420 *out << "}"; |
| 421 } | 421 } |
| 422 } | 422 } |
| 423 | 423 |
| 424 } // namespace trace_event | 424 } // namespace trace_event |
| 425 } // namespace base | 425 } // namespace base |
| OLD | NEW |