Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(404)

Side by Side Diff: tools/gn/trace.h

Issue 56433003: GN threading refactor (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tools/gn/toolchain_manager.cc ('k') | tools/gn/trace.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/files/file_path.h" 12 #include "base/files/file_path.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "base/threading/platform_thread.h" 14 #include "base/threading/platform_thread.h"
15 #include "base/time/time.h" 15 #include "base/time/time.h"
16 16
17 class Label; 17 class Label;
18 18
19 class TraceItem { 19 class TraceItem {
20 public: 20 public:
21 enum Type { 21 enum Type {
22 TRACE_FILE_LOAD, 22 TRACE_FILE_LOAD,
23 TRACE_FILE_PARSE, 23 TRACE_FILE_PARSE,
24 TRACE_FILE_EXECUTE, 24 TRACE_FILE_EXECUTE,
25 TRACE_FILE_WRITE, 25 TRACE_FILE_WRITE,
26 TRACE_SCRIPT_EXECUTE 26 TRACE_SCRIPT_EXECUTE,
27 TRACE_DEFINE_TARGET
27 }; 28 };
28 29
29 TraceItem(Type type, 30 TraceItem(Type type,
30 const std::string& name, 31 const std::string& name,
31 base::PlatformThreadId thread_id); 32 base::PlatformThreadId thread_id);
32 ~TraceItem(); 33 ~TraceItem();
33 34
34 Type type() const { return type_; } 35 Type type() const { return type_; }
35 const std::string& name() const { return name_; } 36 const std::string& name() const { return name_; }
36 base::PlatformThreadId thread_id() const { return thread_id_; } 37 base::PlatformThreadId thread_id() const { return thread_id_; }
(...skipping 21 matching lines...) Expand all
58 base::TimeTicks begin_; 59 base::TimeTicks begin_;
59 base::TimeTicks end_; 60 base::TimeTicks end_;
60 61
61 std::string toolchain_; 62 std::string toolchain_;
62 std::string cmdline_; 63 std::string cmdline_;
63 }; 64 };
64 65
65 class ScopedTrace { 66 class ScopedTrace {
66 public: 67 public:
67 ScopedTrace(TraceItem::Type t, const std::string& name); 68 ScopedTrace(TraceItem::Type t, const std::string& name);
69 ScopedTrace(TraceItem::Type t, const Label& label);
68 ~ScopedTrace(); 70 ~ScopedTrace();
69 71
70 void SetToolchain(const Label& label); 72 void SetToolchain(const Label& label);
71 void SetCommandLine(const CommandLine& cmdline); 73 void SetCommandLine(const CommandLine& cmdline);
72 74
73 void Done(); 75 void Done();
74 76
75 private: 77 private:
76 TraceItem* item_; 78 TraceItem* item_;
77 bool done_; 79 bool done_;
78 }; 80 };
79 81
80 // Call to turn tracing on. It's off by default. 82 // Call to turn tracing on. It's off by default.
81 void EnableTracing(); 83 void EnableTracing();
82 84
83 // Adds a trace event to the log. Takes ownership of the pointer. 85 // Adds a trace event to the log. Takes ownership of the pointer.
84 void AddTrace(TraceItem* item); 86 void AddTrace(TraceItem* item);
85 87
86 // Returns a summary of the current traces, or the empty string if tracing is 88 // Returns a summary of the current traces, or the empty string if tracing is
87 // not enabled. 89 // not enabled.
88 std::string SummarizeTraces(); 90 std::string SummarizeTraces();
89 91
90 // Saves the current traces to the given filename in JSON format. 92 // Saves the current traces to the given filename in JSON format.
91 void SaveTraces(const base::FilePath& file_name); 93 void SaveTraces(const base::FilePath& file_name);
92 94
93 #endif // TOOLS_GN_TRACE_H_ 95 #endif // TOOLS_GN_TRACE_H_
OLDNEW
« no previous file with comments | « tools/gn/toolchain_manager.cc ('k') | tools/gn/trace.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698