| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 #ifndef TOOLS_GN_TRACE_H_ | 5 #ifndef TOOLS_GN_TRACE_H_ |
| 6 #define TOOLS_GN_TRACE_H_ | 6 #define TOOLS_GN_TRACE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/threading/platform_thread.h" | 11 #include "base/threading/platform_thread.h" |
| 12 #include "base/time/time.h" | 12 #include "base/time/time.h" |
| 13 | 13 |
| 14 class Label; | 14 class Label; |
| 15 | 15 |
| 16 namespace base { | 16 namespace base { |
| 17 class CommandLine; | 17 class CommandLine; |
| 18 class FilePath; | 18 class FilePath; |
| 19 } | 19 } |
| 20 | 20 |
| 21 class TraceItem { | 21 class TraceItem { |
| 22 public: | 22 public: |
| 23 enum Type { | 23 enum Type { |
| 24 TRACE_SETUP, | 24 TRACE_SETUP, |
| 25 TRACE_FILE_LOAD, | 25 TRACE_FILE_LOAD, |
| 26 TRACE_FILE_PARSE, | 26 TRACE_FILE_PARSE, |
| 27 TRACE_FILE_EXECUTE, | 27 TRACE_FILE_EXECUTE, |
| 28 TRACE_FILE_WRITE, | 28 TRACE_FILE_WRITE, |
| 29 TRACE_IMPORT_LOAD, |
| 30 TRACE_IMPORT_BLOCK, |
| 29 TRACE_SCRIPT_EXECUTE, | 31 TRACE_SCRIPT_EXECUTE, |
| 30 TRACE_DEFINE_TARGET, | 32 TRACE_DEFINE_TARGET, |
| 31 TRACE_ON_RESOLVED, | 33 TRACE_ON_RESOLVED, |
| 32 TRACE_CHECK_HEADER, // One file. | 34 TRACE_CHECK_HEADER, // One file. |
| 33 TRACE_CHECK_HEADERS, // All files. | 35 TRACE_CHECK_HEADERS, // All files. |
| 34 }; | 36 }; |
| 35 | 37 |
| 36 TraceItem(Type type, | 38 TraceItem(Type type, |
| 37 const std::string& name, | 39 const std::string& name, |
| 38 base::PlatformThreadId thread_id); | 40 base::PlatformThreadId thread_id); |
| 39 ~TraceItem(); | 41 ~TraceItem(); |
| 40 | 42 |
| 41 Type type() const { return type_; } | 43 Type type() const { return type_; } |
| 42 const std::string& name() const { return name_; } | 44 const std::string& name() const { return name_; } |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 void Done(); | 83 void Done(); |
| 82 | 84 |
| 83 private: | 85 private: |
| 84 TraceItem* item_; | 86 TraceItem* item_; |
| 85 bool done_; | 87 bool done_; |
| 86 }; | 88 }; |
| 87 | 89 |
| 88 // Call to turn tracing on. It's off by default. | 90 // Call to turn tracing on. It's off by default. |
| 89 void EnableTracing(); | 91 void EnableTracing(); |
| 90 | 92 |
| 93 // Returns whether tracing is enabled. |
| 94 bool TracingEnabled(); |
| 95 |
| 91 // Adds a trace event to the log. Takes ownership of the pointer. | 96 // Adds a trace event to the log. Takes ownership of the pointer. |
| 92 void AddTrace(TraceItem* item); | 97 void AddTrace(TraceItem* item); |
| 93 | 98 |
| 94 // Returns a summary of the current traces, or the empty string if tracing is | 99 // Returns a summary of the current traces, or the empty string if tracing is |
| 95 // not enabled. | 100 // not enabled. |
| 96 std::string SummarizeTraces(); | 101 std::string SummarizeTraces(); |
| 97 | 102 |
| 98 // Saves the current traces to the given filename in JSON format. | 103 // Saves the current traces to the given filename in JSON format. |
| 99 void SaveTraces(const base::FilePath& file_name); | 104 void SaveTraces(const base::FilePath& file_name); |
| 100 | 105 |
| 101 #endif // TOOLS_GN_TRACE_H_ | 106 #endif // TOOLS_GN_TRACE_H_ |
| OLD | NEW |