| OLD | NEW |
| 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 #include "content/browser/tracing/tracing_controller_impl.h" | 4 #include "content/browser/tracing/tracing_controller_impl.h" |
| 5 | 5 |
| 6 #include "base/bind.h" | 6 #include "base/bind.h" |
| 7 #include "base/cpu.h" | 7 #include "base/cpu.h" |
| 8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
| 9 #include "base/guid.h" | 9 #include "base/guid.h" |
| 10 #include "base/json/string_escape.h" | 10 #include "base/json/string_escape.h" |
| (...skipping 904 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 915 const base::trace_event::MemoryDumpCallback& callback) { | 915 const base::trace_event::MemoryDumpCallback& callback) { |
| 916 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { | 916 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { |
| 917 BrowserThread::PostTask( | 917 BrowserThread::PostTask( |
| 918 BrowserThread::UI, FROM_HERE, | 918 BrowserThread::UI, FROM_HERE, |
| 919 base::Bind(&TracingControllerImpl::RequestGlobalMemoryDump, | 919 base::Bind(&TracingControllerImpl::RequestGlobalMemoryDump, |
| 920 base::Unretained(this), args, callback)); | 920 base::Unretained(this), args, callback)); |
| 921 return; | 921 return; |
| 922 } | 922 } |
| 923 // Abort if another dump is already in progress. | 923 // Abort if another dump is already in progress. |
| 924 if (pending_memory_dump_guid_) { | 924 if (pending_memory_dump_guid_) { |
| 925 DVLOG(1) << "Requested memory dump " << args.dump_guid | 925 VLOG(1) << base::trace_event::MemoryDumpManager::kLogPrefix |
| 926 << " while waiting for " << pending_memory_dump_guid_; | 926 << " (" << args.dump_guid << ") aborted because another dump (" |
| 927 << pending_memory_dump_guid_ << ") is in progress"; |
| 927 if (!callback.is_null()) | 928 if (!callback.is_null()) |
| 928 callback.Run(args.dump_guid, false /* success */); | 929 callback.Run(args.dump_guid, false /* success */); |
| 929 return; | 930 return; |
| 930 } | 931 } |
| 931 | 932 |
| 932 // Count myself (local trace) in pending_memory_dump_ack_count_, acked by | 933 // Count myself (local trace) in pending_memory_dump_ack_count_, acked by |
| 933 // OnBrowserProcessMemoryDumpDone(). | 934 // OnBrowserProcessMemoryDumpDone(). |
| 934 pending_memory_dump_ack_count_ = trace_message_filters_.size() + 1; | 935 pending_memory_dump_ack_count_ = trace_message_filters_.size() + 1; |
| 935 pending_memory_dump_filters_.clear(); | 936 pending_memory_dump_filters_.clear(); |
| 936 pending_memory_dump_guid_ = args.dump_guid; | 937 pending_memory_dump_guid_ = args.dump_guid; |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 994 it == pending_memory_dump_filters_.end()) { | 995 it == pending_memory_dump_filters_.end()) { |
| 995 DLOG(WARNING) << "Received unexpected memory dump response: " << dump_guid; | 996 DLOG(WARNING) << "Received unexpected memory dump response: " << dump_guid; |
| 996 return; | 997 return; |
| 997 } | 998 } |
| 998 | 999 |
| 999 DCHECK_GT(pending_memory_dump_ack_count_, 0); | 1000 DCHECK_GT(pending_memory_dump_ack_count_, 0); |
| 1000 --pending_memory_dump_ack_count_; | 1001 --pending_memory_dump_ack_count_; |
| 1001 pending_memory_dump_filters_.erase(it); | 1002 pending_memory_dump_filters_.erase(it); |
| 1002 if (!success) { | 1003 if (!success) { |
| 1003 ++failed_memory_dump_count_; | 1004 ++failed_memory_dump_count_; |
| 1004 DLOG(WARNING) << "Global memory dump failed because of NACK from child " | 1005 VLOG(1) << base::trace_event::MemoryDumpManager::kLogPrefix |
| 1005 << trace_message_filter->peer_pid(); | 1006 << " failed because of NACK from child " |
| 1007 << trace_message_filter->peer_pid(); |
| 1006 } | 1008 } |
| 1007 FinalizeGlobalMemoryDumpIfAllProcessesReplied(); | 1009 FinalizeGlobalMemoryDumpIfAllProcessesReplied(); |
| 1008 } | 1010 } |
| 1009 | 1011 |
| 1010 void TracingControllerImpl::OnBrowserProcessMemoryDumpDone(uint64_t dump_guid, | 1012 void TracingControllerImpl::OnBrowserProcessMemoryDumpDone(uint64_t dump_guid, |
| 1011 bool success) { | 1013 bool success) { |
| 1012 DCHECK_GT(pending_memory_dump_ack_count_, 0); | 1014 DCHECK_GT(pending_memory_dump_ack_count_, 0); |
| 1013 --pending_memory_dump_ack_count_; | 1015 --pending_memory_dump_ack_count_; |
| 1014 if (!success) { | 1016 if (!success) { |
| 1015 ++failed_memory_dump_count_; | 1017 ++failed_memory_dump_count_; |
| 1016 DLOG(WARNING) << "Global memory dump aborted on the current process"; | 1018 VLOG(1) << base::trace_event::MemoryDumpManager::kLogPrefix |
| 1019 << " aborted on the current process"; |
| 1017 } | 1020 } |
| 1018 FinalizeGlobalMemoryDumpIfAllProcessesReplied(); | 1021 FinalizeGlobalMemoryDumpIfAllProcessesReplied(); |
| 1019 } | 1022 } |
| 1020 | 1023 |
| 1021 void TracingControllerImpl::FinalizeGlobalMemoryDumpIfAllProcessesReplied() { | 1024 void TracingControllerImpl::FinalizeGlobalMemoryDumpIfAllProcessesReplied() { |
| 1022 if (pending_memory_dump_ack_count_ > 0) | 1025 if (pending_memory_dump_ack_count_ > 0) |
| 1023 return; | 1026 return; |
| 1024 | 1027 |
| 1025 DCHECK_NE(0u, pending_memory_dump_guid_); | 1028 DCHECK_NE(0u, pending_memory_dump_guid_); |
| 1026 const bool global_success = failed_memory_dump_count_ == 0; | 1029 const bool global_success = failed_memory_dump_count_ == 0; |
| 1027 if (!pending_memory_dump_callback_.is_null()) { | 1030 if (!pending_memory_dump_callback_.is_null()) { |
| 1028 pending_memory_dump_callback_.Run(pending_memory_dump_guid_, | 1031 pending_memory_dump_callback_.Run(pending_memory_dump_guid_, |
| 1029 global_success); | 1032 global_success); |
| 1030 pending_memory_dump_callback_.Reset(); | 1033 pending_memory_dump_callback_.Reset(); |
| 1031 } | 1034 } |
| 1032 pending_memory_dump_guid_ = 0; | 1035 pending_memory_dump_guid_ = 0; |
| 1033 } | 1036 } |
| 1034 | 1037 |
| 1035 } // namespace content | 1038 } // namespace content |
| OLD | NEW |