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 <fcntl.h> | 7 #include <fcntl.h> |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
(...skipping 20 matching lines...) Loading... |
31 if (written <= 0) | 31 if (written <= 0) |
32 break; | 32 break; |
33 total_written += written; | 33 total_written += written; |
34 } | 34 } |
35 if (total_written < size) { | 35 if (total_written < size) { |
36 PLOG(WARNING) << "Failed to write buffer '" << std::string(buffer, size) | 36 PLOG(WARNING) << "Failed to write buffer '" << std::string(buffer, size) |
37 << "' to " << kATraceMarkerFile; | 37 << "' to " << kATraceMarkerFile; |
38 } | 38 } |
39 } | 39 } |
40 | 40 |
41 void WriteEvent(char phase, | 41 void WriteEvent( |
42 const char* category_group, | 42 char phase, |
43 const char* name, | 43 const char* category_group, |
44 unsigned long long id, | 44 const char* name, |
45 const char** arg_names, | 45 unsigned long long id, |
46 const unsigned char* arg_types, | 46 const char** arg_names, |
47 const TraceEvent::TraceValue* arg_values, | 47 const unsigned char* arg_types, |
48 const scoped_ptr<ConvertableToTraceFormat>* convertable_values, | 48 const TraceEvent::TraceValue* arg_values, |
49 unsigned int flags) { | 49 const std::unique_ptr<ConvertableToTraceFormat>* convertable_values, |
| 50 unsigned int flags) { |
50 std::string out = StringPrintf("%c|%d|%s", phase, getpid(), name); | 51 std::string out = StringPrintf("%c|%d|%s", phase, getpid(), name); |
51 if (flags & TRACE_EVENT_FLAG_HAS_ID) | 52 if (flags & TRACE_EVENT_FLAG_HAS_ID) |
52 StringAppendF(&out, "-%" PRIx64, static_cast<uint64_t>(id)); | 53 StringAppendF(&out, "-%" PRIx64, static_cast<uint64_t>(id)); |
53 out += '|'; | 54 out += '|'; |
54 | 55 |
55 for (int i = 0; i < kTraceMaxNumArgs && arg_names[i]; | 56 for (int i = 0; i < kTraceMaxNumArgs && arg_names[i]; |
56 ++i) { | 57 ++i) { |
57 if (i) | 58 if (i) |
58 out += ';'; | 59 out += ';'; |
59 out += arg_names[i]; | 60 out += arg_names[i]; |
(...skipping 144 matching lines...) Loading... |
204 // trace buffer. | 205 // trace buffer. |
205 double now_in_seconds = (TimeTicks::Now() - TimeTicks()).InSecondsF(); | 206 double now_in_seconds = (TimeTicks::Now() - TimeTicks()).InSecondsF(); |
206 std::string marker = StringPrintf( | 207 std::string marker = StringPrintf( |
207 "trace_event_clock_sync: parent_ts=%f\n", now_in_seconds); | 208 "trace_event_clock_sync: parent_ts=%f\n", now_in_seconds); |
208 WriteToATrace(atrace_fd, marker.c_str(), marker.size()); | 209 WriteToATrace(atrace_fd, marker.c_str(), marker.size()); |
209 close(atrace_fd); | 210 close(atrace_fd); |
210 } | 211 } |
211 | 212 |
212 } // namespace trace_event | 213 } // namespace trace_event |
213 } // namespace base | 214 } // namespace base |
OLD | NEW |