OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 // Trace events to track application performance. Events consist of a name | 5 // Trace events to track application performance. Events consist of a name |
6 // a type (BEGIN, END or INSTANT), a tracking id and extra string data. | 6 // a type (BEGIN, END or INSTANT), a tracking id and extra string data. |
7 // In addition, the current process id, thread id, a timestamp down to the | 7 // In addition, the current process id, thread id, a timestamp down to the |
8 // microsecond and a file and line number of the calling location. | 8 // microsecond and a file and line number of the calling location. |
9 // | 9 // |
10 // The current implementation logs these events into a log file of the form | 10 // The current implementation logs these events into a log file of the form |
(...skipping 13 matching lines...) Expand all Loading... |
24 // | 24 // |
25 // Note that the Windows implementation is always enabled, irrespective the | 25 // Note that the Windows implementation is always enabled, irrespective the |
26 // value of the CHROMIUM_ENABLE_TRACE_EVENT define. The Windows implementation | 26 // value of the CHROMIUM_ENABLE_TRACE_EVENT define. The Windows implementation |
27 // is controlled by Event Tracing for Windows, which will turn tracing on only | 27 // is controlled by Event Tracing for Windows, which will turn tracing on only |
28 // if there is someone listening for the events it generates. | 28 // if there is someone listening for the events it generates. |
29 #include "base/debug/trace_event_win.h" | 29 #include "base/debug/trace_event_win.h" |
30 #else // defined(OS_WIN) | 30 #else // defined(OS_WIN) |
31 | 31 |
32 #include <string> | 32 #include <string> |
33 | 33 |
34 #include "base/lock.h" | |
35 #include "base/scoped_ptr.h" | 34 #include "base/scoped_ptr.h" |
36 #include "base/singleton.h" | 35 #include "base/singleton.h" |
| 36 #include "base/synchronization/lock.h" |
37 #include "base/time.h" | 37 #include "base/time.h" |
38 #include "base/timer.h" | 38 #include "base/timer.h" |
39 | 39 |
40 #ifndef CHROMIUM_ENABLE_TRACE_EVENT | 40 #ifndef CHROMIUM_ENABLE_TRACE_EVENT |
41 #define TRACE_EVENT_BEGIN(name, id, extra) ((void) 0) | 41 #define TRACE_EVENT_BEGIN(name, id, extra) ((void) 0) |
42 #define TRACE_EVENT_END(name, id, extra) ((void) 0) | 42 #define TRACE_EVENT_END(name, id, extra) ((void) 0) |
43 #define TRACE_EVENT_INSTANT(name, id, extra) ((void) 0) | 43 #define TRACE_EVENT_INSTANT(name, id, extra) ((void) 0) |
44 | 44 |
45 #else // CHROMIUM_ENABLE_TRACE_EVENT | 45 #else // CHROMIUM_ENABLE_TRACE_EVENT |
46 // Use the following macros rather than using the TraceLog class directly as the | 46 // Use the following macros rather than using the TraceLog class directly as the |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 ~TraceLog(); | 128 ~TraceLog(); |
129 bool OpenLogFile(); | 129 bool OpenLogFile(); |
130 void CloseLogFile(); | 130 void CloseLogFile(); |
131 bool Start(); | 131 bool Start(); |
132 void Stop(); | 132 void Stop(); |
133 void Heartbeat(); | 133 void Heartbeat(); |
134 void Log(const std::string& msg); | 134 void Log(const std::string& msg); |
135 | 135 |
136 bool enabled_; | 136 bool enabled_; |
137 FILE* log_file_; | 137 FILE* log_file_; |
138 Lock file_lock_; | 138 base::Lock file_lock_; |
139 TimeTicks trace_start_time_; | 139 TimeTicks trace_start_time_; |
140 scoped_ptr<base::ProcessMetrics> process_metrics_; | 140 scoped_ptr<base::ProcessMetrics> process_metrics_; |
141 RepeatingTimer<TraceLog> timer_; | 141 RepeatingTimer<TraceLog> timer_; |
142 }; | 142 }; |
143 | 143 |
144 } // namespace debug | 144 } // namespace debug |
145 } // namespace base | 145 } // namespace base |
146 | 146 |
147 #endif // defined(OS_WIN) | 147 #endif // defined(OS_WIN) |
148 | 148 |
149 #endif // BASE_DEBUG_TRACE_EVENT_H_ | 149 #endif // BASE_DEBUG_TRACE_EVENT_H_ |
OLD | NEW |