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/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/debug/trace_event_impl.h" | 9 #include "base/debug/trace_event_impl.h" |
10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
(...skipping 49 matching lines...) Loading... |
60 const char str[] = "{\"traceEvents\": ["; | 60 const char str[] = "{\"traceEvents\": ["; |
61 WriteFile(path_, str, static_cast<int>(strlen(str))); | 61 WriteFile(path_, str, static_cast<int>(strlen(str))); |
62 } | 62 } |
63 | 63 |
64 void TraceToFile::AppendFileFooter() { | 64 void TraceToFile::AppendFileFooter() { |
65 const char str[] = "]}"; | 65 const char str[] = "]}"; |
66 AppendToFile(path_, str, static_cast<int>(strlen(str))); | 66 AppendToFile(path_, str, static_cast<int>(strlen(str))); |
67 } | 67 } |
68 | 68 |
69 void TraceToFile::TraceOutputCallback(const std::string& data) { | 69 void TraceToFile::TraceOutputCallback(const std::string& data) { |
70 int ret = AppendToFile(path_, data.c_str(), static_cast<int>(data.size())); | 70 bool ret = AppendToFile(path_, data.c_str(), static_cast<int>(data.size())); |
71 DCHECK_NE(-1, ret); | 71 DCHECK(ret); |
72 } | 72 } |
73 | 73 |
74 static void OnTraceDataCollected( | 74 static void OnTraceDataCollected( |
75 Closure quit_closure, | 75 Closure quit_closure, |
76 debug::TraceResultBuffer* buffer, | 76 debug::TraceResultBuffer* buffer, |
77 const scoped_refptr<RefCountedString>& json_events_str, | 77 const scoped_refptr<RefCountedString>& json_events_str, |
78 bool has_more_events) { | 78 bool has_more_events) { |
79 buffer->AddFragment(json_events_str->data()); | 79 buffer->AddFragment(json_events_str->data()); |
80 if (!has_more_events) | 80 if (!has_more_events) |
81 quit_closure.Run(); | 81 quit_closure.Run(); |
(...skipping 13 matching lines...) Loading... |
95 RunLoop run_loop; | 95 RunLoop run_loop; |
96 debug::TraceLog::GetInstance()->Flush( | 96 debug::TraceLog::GetInstance()->Flush( |
97 Bind(&OnTraceDataCollected, run_loop.QuitClosure(), Unretained(&buffer))); | 97 Bind(&OnTraceDataCollected, run_loop.QuitClosure(), Unretained(&buffer))); |
98 run_loop.Run(); | 98 run_loop.Run(); |
99 | 99 |
100 AppendFileFooter(); | 100 AppendFileFooter(); |
101 } | 101 } |
102 | 102 |
103 } // namespace test | 103 } // namespace test |
104 } // namespace base | 104 } // namespace base |
OLD | NEW |