OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 #include "content/browser/browser_shutdown_profile_dumper.h" | 5 #include "content/browser/browser_shutdown_profile_dumper.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 LOG(ERROR) << "Failed to open performance trace file: " | 50 LOG(ERROR) << "Failed to open performance trace file: " |
51 << dump_file_name_.value(); | 51 << dump_file_name_.value(); |
52 return; | 52 return; |
53 } | 53 } |
54 WriteString("{\"traceEvents\":"); | 54 WriteString("{\"traceEvents\":"); |
55 WriteString("["); | 55 WriteString("["); |
56 | 56 |
57 // TraceLog::Flush() requires the calling thread to have a message loop. | 57 // TraceLog::Flush() requires the calling thread to have a message loop. |
58 // As the message loop of the current thread may have quit, start another | 58 // As the message loop of the current thread may have quit, start another |
59 // thread for flushing the trace. | 59 // thread for flushing the trace. |
60 base::WaitableEvent flush_complete_event(false, false); | 60 base::WaitableEvent flush_complete_event( |
| 61 base::WaitableEvent::ResetPolicy::AUTOMATIC, |
| 62 base::WaitableEvent::InitialState::NOT_SIGNALED); |
61 base::Thread flush_thread("browser_shutdown_trace_event_flush"); | 63 base::Thread flush_thread("browser_shutdown_trace_event_flush"); |
62 flush_thread.Start(); | 64 flush_thread.Start(); |
63 flush_thread.task_runner()->PostTask( | 65 flush_thread.task_runner()->PostTask( |
64 FROM_HERE, base::Bind(&BrowserShutdownProfileDumper::EndTraceAndFlush, | 66 FROM_HERE, base::Bind(&BrowserShutdownProfileDumper::EndTraceAndFlush, |
65 base::Unretained(this), | 67 base::Unretained(this), |
66 base::Unretained(&flush_complete_event))); | 68 base::Unretained(&flush_complete_event))); |
67 | 69 |
68 bool original_wait_allowed = base::ThreadRestrictions::SetWaitAllowed(true); | 70 bool original_wait_allowed = base::ThreadRestrictions::SetWaitAllowed(true); |
69 flush_complete_event.Wait(); | 71 flush_complete_event.Wait(); |
70 base::ThreadRestrictions::SetWaitAllowed(original_wait_allowed); | 72 base::ThreadRestrictions::SetWaitAllowed(original_wait_allowed); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 } | 141 } |
140 | 142 |
141 void BrowserShutdownProfileDumper::CloseFile() { | 143 void BrowserShutdownProfileDumper::CloseFile() { |
142 if (!dump_file_) | 144 if (!dump_file_) |
143 return; | 145 return; |
144 base::CloseFile(dump_file_); | 146 base::CloseFile(dump_file_); |
145 dump_file_ = NULL; | 147 dump_file_ = NULL; |
146 } | 148 } |
147 | 149 |
148 } // namespace content | 150 } // namespace content |
OLD | NEW |