OLD | NEW |
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2014 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/test/trace_to_file.h" | 5 #include "base/test/trace_to_file.h" |
6 | 6 |
7 #include "base/base_switches.h" | 7 #include "base/base_switches.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 } | 45 } |
46 | 46 |
47 void TraceToFile::BeginTracing(const FilePath& path, | 47 void TraceToFile::BeginTracing(const FilePath& path, |
48 const std::string& categories) { | 48 const std::string& categories) { |
49 DCHECK(!started_); | 49 DCHECK(!started_); |
50 started_ = true; | 50 started_ = true; |
51 path_ = path; | 51 path_ = path; |
52 WriteFileHeader(); | 52 WriteFileHeader(); |
53 | 53 |
54 trace_event::TraceLog::GetInstance()->SetEnabled( | 54 trace_event::TraceLog::GetInstance()->SetEnabled( |
55 trace_event::CategoryFilter(categories), | 55 trace_event::TraceConfig(categories, trace_event::RECORD_UNTIL_FULL), |
56 trace_event::TraceLog::RECORDING_MODE, | 56 trace_event::TraceLog::RECORDING_MODE); |
57 trace_event::TraceOptions(trace_event::RECORD_UNTIL_FULL)); | |
58 } | 57 } |
59 | 58 |
60 void TraceToFile::WriteFileHeader() { | 59 void TraceToFile::WriteFileHeader() { |
61 const char str[] = "{\"traceEvents\": ["; | 60 const char str[] = "{\"traceEvents\": ["; |
62 WriteFile(path_, str, static_cast<int>(strlen(str))); | 61 WriteFile(path_, str, static_cast<int>(strlen(str))); |
63 } | 62 } |
64 | 63 |
65 void TraceToFile::AppendFileFooter() { | 64 void TraceToFile::AppendFileFooter() { |
66 const char str[] = "]}"; | 65 const char str[] = "]}"; |
67 AppendToFile(path_, str, static_cast<int>(strlen(str))); | 66 AppendToFile(path_, str, static_cast<int>(strlen(str))); |
(...skipping 28 matching lines...) Expand all Loading... |
96 RunLoop run_loop; | 95 RunLoop run_loop; |
97 trace_event::TraceLog::GetInstance()->Flush( | 96 trace_event::TraceLog::GetInstance()->Flush( |
98 Bind(&OnTraceDataCollected, run_loop.QuitClosure(), Unretained(&buffer))); | 97 Bind(&OnTraceDataCollected, run_loop.QuitClosure(), Unretained(&buffer))); |
99 run_loop.Run(); | 98 run_loop.Run(); |
100 | 99 |
101 AppendFileFooter(); | 100 AppendFileFooter(); |
102 } | 101 } |
103 | 102 |
104 } // namespace test | 103 } // namespace test |
105 } // namespace base | 104 } // namespace base |
OLD | NEW |