| 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 | 8 |
| 9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 int atrace_fd = open(kATraceMarkerFile, O_WRONLY | O_APPEND); | 180 int atrace_fd = open(kATraceMarkerFile, O_WRONLY | O_APPEND); |
| 181 if (atrace_fd == -1) { | 181 if (atrace_fd == -1) { |
| 182 PLOG(WARNING) << "Couldn't open " << kATraceMarkerFile; | 182 PLOG(WARNING) << "Couldn't open " << kATraceMarkerFile; |
| 183 return; | 183 return; |
| 184 } | 184 } |
| 185 | 185 |
| 186 // Android's kernel trace system has a trace_marker feature: this is a file on | 186 // Android's kernel trace system has a trace_marker feature: this is a file on |
| 187 // debugfs that takes the written data and pushes it onto the trace | 187 // debugfs that takes the written data and pushes it onto the trace |
| 188 // buffer. So, to establish clock sync, we write our monotonic clock into that | 188 // buffer. So, to establish clock sync, we write our monotonic clock into that |
| 189 // trace buffer. | 189 // trace buffer. |
| 190 TimeTicks now = TimeTicks::NowFromSystemTraceTime(); | 190 double now_in_seconds = (TraceTicks::Now() - TraceTicks()).InSecondsF(); |
| 191 double now_in_seconds = now.ToInternalValue() / 1000000.0; | |
| 192 std::string marker = StringPrintf( | 191 std::string marker = StringPrintf( |
| 193 "trace_event_clock_sync: parent_ts=%f\n", now_in_seconds); | 192 "trace_event_clock_sync: parent_ts=%f\n", now_in_seconds); |
| 194 if (write(atrace_fd, marker.c_str(), marker.size()) == -1) | 193 if (write(atrace_fd, marker.c_str(), marker.size()) == -1) |
| 195 PLOG(WARNING) << "Couldn't write to " << kATraceMarkerFile; | 194 PLOG(WARNING) << "Couldn't write to " << kATraceMarkerFile; |
| 196 close(atrace_fd); | 195 close(atrace_fd); |
| 197 } | 196 } |
| 198 | 197 |
| 199 } // namespace trace_event | 198 } // namespace trace_event |
| 200 } // namespace base | 199 } // namespace base |
| OLD | NEW |