| 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/json/string_escape.h" | 9 #include "base/json/string_escape.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
| 12 #include "base/sys_info.h" | 12 #include "base/sys_info.h" |
| 13 #include "base/trace_event/trace_event.h" | 13 #include "base/trace_event/trace_event.h" |
| 14 #include "build/build_config.h" |
| 14 #include "content/browser/tracing/file_tracing_provider_impl.h" | 15 #include "content/browser/tracing/file_tracing_provider_impl.h" |
| 15 #include "content/browser/tracing/power_tracing_agent.h" | 16 #include "content/browser/tracing/power_tracing_agent.h" |
| 16 #include "content/browser/tracing/trace_message_filter.h" | 17 #include "content/browser/tracing/trace_message_filter.h" |
| 17 #include "content/browser/tracing/tracing_ui.h" | 18 #include "content/browser/tracing/tracing_ui.h" |
| 18 #include "content/common/child_process_messages.h" | 19 #include "content/common/child_process_messages.h" |
| 19 #include "content/public/browser/browser_message_filter.h" | 20 #include "content/public/browser/browser_message_filter.h" |
| 20 #include "content/public/browser/content_browser_client.h" | 21 #include "content/public/browser/content_browser_client.h" |
| 21 #include "content/public/browser/gpu_data_manager.h" | 22 #include "content/public/browser/gpu_data_manager.h" |
| 22 #include "content/public/browser/tracing_delegate.h" | 23 #include "content/public/browser/tracing_delegate.h" |
| 23 #include "content/public/common/child_process_host.h" | 24 #include "content/public/common/child_process_host.h" |
| (...skipping 1003 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1027 // If there are no child processes we are just done. | 1028 // If there are no child processes we are just done. |
| 1028 if (pending_memory_dump_ack_count_ == 1) | 1029 if (pending_memory_dump_ack_count_ == 1) |
| 1029 return; | 1030 return; |
| 1030 | 1031 |
| 1031 pending_memory_dump_filters_ = trace_message_filters_; | 1032 pending_memory_dump_filters_ = trace_message_filters_; |
| 1032 | 1033 |
| 1033 for (const scoped_refptr<TraceMessageFilter>& tmf : trace_message_filters_) | 1034 for (const scoped_refptr<TraceMessageFilter>& tmf : trace_message_filters_) |
| 1034 tmf->SendProcessMemoryDumpRequest(args); | 1035 tmf->SendProcessMemoryDumpRequest(args); |
| 1035 } | 1036 } |
| 1036 | 1037 |
| 1037 uint64 TracingControllerImpl::GetTracingProcessId() const { | 1038 uint64_t TracingControllerImpl::GetTracingProcessId() const { |
| 1038 return ChildProcessHost::kBrowserTracingProcessId; | 1039 return ChildProcessHost::kBrowserTracingProcessId; |
| 1039 } | 1040 } |
| 1040 | 1041 |
| 1041 void TracingControllerImpl::AddTraceMessageFilterObserver( | 1042 void TracingControllerImpl::AddTraceMessageFilterObserver( |
| 1042 TraceMessageFilterObserver* observer) { | 1043 TraceMessageFilterObserver* observer) { |
| 1043 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1044 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 1044 trace_message_filter_observers_.AddObserver(observer); | 1045 trace_message_filter_observers_.AddObserver(observer); |
| 1045 | 1046 |
| 1046 for (auto& filter : trace_message_filters_) | 1047 for (auto& filter : trace_message_filters_) |
| 1047 observer->OnTraceMessageFilterAdded(filter.get()); | 1048 observer->OnTraceMessageFilterAdded(filter.get()); |
| 1048 } | 1049 } |
| 1049 | 1050 |
| 1050 void TracingControllerImpl::RemoveTraceMessageFilterObserver( | 1051 void TracingControllerImpl::RemoveTraceMessageFilterObserver( |
| 1051 TraceMessageFilterObserver* observer) { | 1052 TraceMessageFilterObserver* observer) { |
| 1052 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1053 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 1053 trace_message_filter_observers_.RemoveObserver(observer); | 1054 trace_message_filter_observers_.RemoveObserver(observer); |
| 1054 | 1055 |
| 1055 for (auto& filter : trace_message_filters_) | 1056 for (auto& filter : trace_message_filters_) |
| 1056 observer->OnTraceMessageFilterRemoved(filter.get()); | 1057 observer->OnTraceMessageFilterRemoved(filter.get()); |
| 1057 } | 1058 } |
| 1058 | 1059 |
| 1059 void TracingControllerImpl::OnProcessMemoryDumpResponse( | 1060 void TracingControllerImpl::OnProcessMemoryDumpResponse( |
| 1060 TraceMessageFilter* trace_message_filter, | 1061 TraceMessageFilter* trace_message_filter, |
| 1061 uint64 dump_guid, | 1062 uint64_t dump_guid, |
| 1062 bool success) { | 1063 bool success) { |
| 1063 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { | 1064 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { |
| 1064 BrowserThread::PostTask( | 1065 BrowserThread::PostTask( |
| 1065 BrowserThread::UI, FROM_HERE, | 1066 BrowserThread::UI, FROM_HERE, |
| 1066 base::Bind(&TracingControllerImpl::OnProcessMemoryDumpResponse, | 1067 base::Bind(&TracingControllerImpl::OnProcessMemoryDumpResponse, |
| 1067 base::Unretained(this), | 1068 base::Unretained(this), |
| 1068 make_scoped_refptr(trace_message_filter), dump_guid, | 1069 make_scoped_refptr(trace_message_filter), dump_guid, |
| 1069 success)); | 1070 success)); |
| 1070 return; | 1071 return; |
| 1071 } | 1072 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1083 --pending_memory_dump_ack_count_; | 1084 --pending_memory_dump_ack_count_; |
| 1084 pending_memory_dump_filters_.erase(it); | 1085 pending_memory_dump_filters_.erase(it); |
| 1085 if (!success) { | 1086 if (!success) { |
| 1086 ++failed_memory_dump_count_; | 1087 ++failed_memory_dump_count_; |
| 1087 DLOG(WARNING) << "Global memory dump failed because of NACK from child " | 1088 DLOG(WARNING) << "Global memory dump failed because of NACK from child " |
| 1088 << trace_message_filter->peer_pid(); | 1089 << trace_message_filter->peer_pid(); |
| 1089 } | 1090 } |
| 1090 FinalizeGlobalMemoryDumpIfAllProcessesReplied(); | 1091 FinalizeGlobalMemoryDumpIfAllProcessesReplied(); |
| 1091 } | 1092 } |
| 1092 | 1093 |
| 1093 void TracingControllerImpl::OnBrowserProcessMemoryDumpDone(uint64 dump_guid, | 1094 void TracingControllerImpl::OnBrowserProcessMemoryDumpDone(uint64_t dump_guid, |
| 1094 bool success) { | 1095 bool success) { |
| 1095 DCHECK_GT(pending_memory_dump_ack_count_, 0); | 1096 DCHECK_GT(pending_memory_dump_ack_count_, 0); |
| 1096 --pending_memory_dump_ack_count_; | 1097 --pending_memory_dump_ack_count_; |
| 1097 if (!success) { | 1098 if (!success) { |
| 1098 ++failed_memory_dump_count_; | 1099 ++failed_memory_dump_count_; |
| 1099 DLOG(WARNING) << "Global memory dump aborted on the current process"; | 1100 DLOG(WARNING) << "Global memory dump aborted on the current process"; |
| 1100 } | 1101 } |
| 1101 FinalizeGlobalMemoryDumpIfAllProcessesReplied(); | 1102 FinalizeGlobalMemoryDumpIfAllProcessesReplied(); |
| 1102 } | 1103 } |
| 1103 | 1104 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1122 is_monitoring_ = is_monitoring; | 1123 is_monitoring_ = is_monitoring; |
| 1123 #if !defined(OS_ANDROID) | 1124 #if !defined(OS_ANDROID) |
| 1124 for (std::set<TracingUI*>::iterator it = tracing_uis_.begin(); | 1125 for (std::set<TracingUI*>::iterator it = tracing_uis_.begin(); |
| 1125 it != tracing_uis_.end(); it++) { | 1126 it != tracing_uis_.end(); it++) { |
| 1126 (*it)->OnMonitoringStateChanged(is_monitoring); | 1127 (*it)->OnMonitoringStateChanged(is_monitoring); |
| 1127 } | 1128 } |
| 1128 #endif | 1129 #endif |
| 1129 } | 1130 } |
| 1130 | 1131 |
| 1131 } // namespace content | 1132 } // namespace content |
| OLD | NEW |