OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/debug/trace_event_impl.h" | 5 #include "base/debug/trace_event_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/base_switches.h" | 9 #include "base/base_switches.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 1768 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1779 } | 1779 } |
1780 | 1780 |
1781 ConvertTraceEventsToTraceFormat(previous_logged_events.Pass(), | 1781 ConvertTraceEventsToTraceFormat(previous_logged_events.Pass(), |
1782 flush_output_callback); | 1782 flush_output_callback); |
1783 } | 1783 } |
1784 | 1784 |
1785 // Run in each thread holding a local event buffer. | 1785 // Run in each thread holding a local event buffer. |
1786 void TraceLog::FlushCurrentThread(int generation) { | 1786 void TraceLog::FlushCurrentThread(int generation) { |
1787 { | 1787 { |
1788 AutoLock lock(lock_); | 1788 AutoLock lock(lock_); |
1789 if (!CheckGeneration(generation) || !flush_message_loop_proxy_) { | 1789 if (!CheckGeneration(generation) || !flush_message_loop_proxy_.get()) { |
1790 // This is late. The corresponding flush has finished. | 1790 // This is late. The corresponding flush has finished. |
1791 return; | 1791 return; |
1792 } | 1792 } |
1793 } | 1793 } |
1794 | 1794 |
1795 // This will flush the thread local buffer. | 1795 // This will flush the thread local buffer. |
1796 delete thread_local_event_buffer_.Get(); | 1796 delete thread_local_event_buffer_.Get(); |
1797 | 1797 |
1798 AutoLock lock(lock_); | 1798 AutoLock lock(lock_); |
1799 if (!CheckGeneration(generation) || !flush_message_loop_proxy_ || | 1799 if (!CheckGeneration(generation) || !flush_message_loop_proxy_.get() || |
1800 thread_message_loops_.size()) | 1800 thread_message_loops_.size()) |
1801 return; | 1801 return; |
1802 | 1802 |
1803 flush_message_loop_proxy_->PostTask( | 1803 flush_message_loop_proxy_->PostTask( |
1804 FROM_HERE, | 1804 FROM_HERE, |
1805 Bind(&TraceLog::FinishFlush, Unretained(this), generation)); | 1805 Bind(&TraceLog::FinishFlush, Unretained(this), generation)); |
1806 } | 1806 } |
1807 | 1807 |
1808 void TraceLog::OnFlushTimeout(int generation) { | 1808 void TraceLog::OnFlushTimeout(int generation) { |
1809 { | 1809 { |
1810 AutoLock lock(lock_); | 1810 AutoLock lock(lock_); |
1811 if (!CheckGeneration(generation) || !flush_message_loop_proxy_) { | 1811 if (!CheckGeneration(generation) || !flush_message_loop_proxy_.get()) { |
1812 // Flush has finished before timeout. | 1812 // Flush has finished before timeout. |
1813 return; | 1813 return; |
1814 } | 1814 } |
1815 | 1815 |
1816 LOG(WARNING) << | 1816 LOG(WARNING) << |
1817 "The following threads haven't finished flush in time. " | 1817 "The following threads haven't finished flush in time. " |
1818 "If this happens stably for some thread, please call " | 1818 "If this happens stably for some thread, please call " |
1819 "TraceLog::GetInstance()->SetCurrentThreadBlocksMessageLoop() from " | 1819 "TraceLog::GetInstance()->SetCurrentThreadBlocksMessageLoop() from " |
1820 "the thread to avoid its trace events from being lost."; | 1820 "the thread to avoid its trace events from being lost."; |
1821 for (hash_set<MessageLoop*>::const_iterator it = | 1821 for (hash_set<MessageLoop*>::const_iterator it = |
(...skipping 740 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2562 } | 2562 } |
2563 | 2563 |
2564 ScopedTraceBinaryEfficient::~ScopedTraceBinaryEfficient() { | 2564 ScopedTraceBinaryEfficient::~ScopedTraceBinaryEfficient() { |
2565 if (*category_group_enabled_) { | 2565 if (*category_group_enabled_) { |
2566 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(category_group_enabled_, | 2566 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(category_group_enabled_, |
2567 name_, event_handle_); | 2567 name_, event_handle_); |
2568 } | 2568 } |
2569 } | 2569 } |
2570 | 2570 |
2571 } // namespace trace_event_internal | 2571 } // namespace trace_event_internal |
OLD | NEW |