| 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" |
| 11 #include "base/logging.h" |
| 11 #include "base/macros.h" | 12 #include "base/macros.h" |
| 12 #include "base/memory/ref_counted_memory.h" | 13 #include "base/memory/ref_counted_memory.h" |
| 13 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
| 14 #include "base/sys_info.h" | 15 #include "base/sys_info.h" |
| 15 #include "base/threading/thread_task_runner_handle.h" | 16 #include "base/threading/thread_task_runner_handle.h" |
| 16 #include "base/time/time.h" | 17 #include "base/time/time.h" |
| 17 #include "base/trace_event/trace_event.h" | 18 #include "base/trace_event/trace_event.h" |
| 18 #include "build/build_config.h" | 19 #include "build/build_config.h" |
| 19 #include "components/tracing/common/process_metrics_memory_dump_provider.h" | 20 #include "components/tracing/common/process_metrics_memory_dump_provider.h" |
| 20 #include "content/browser/tracing/file_tracing_provider_impl.h" | 21 #include "content/browser/tracing/file_tracing_provider_impl.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 35 #if (defined(OS_POSIX) && defined(USE_UDEV)) || defined(OS_WIN) || \ | 36 #if (defined(OS_POSIX) && defined(USE_UDEV)) || defined(OS_WIN) || \ |
| 36 defined(OS_MACOSX) | 37 defined(OS_MACOSX) |
| 37 #define ENABLE_POWER_TRACING | 38 #define ENABLE_POWER_TRACING |
| 38 #endif | 39 #endif |
| 39 | 40 |
| 40 #if defined(ENABLE_POWER_TRACING) | 41 #if defined(ENABLE_POWER_TRACING) |
| 41 #include "content/browser/tracing/power_tracing_agent.h" | 42 #include "content/browser/tracing/power_tracing_agent.h" |
| 42 #endif | 43 #endif |
| 43 | 44 |
| 44 #if defined(OS_CHROMEOS) | 45 #if defined(OS_CHROMEOS) |
| 45 #include "chromeos/dbus/dbus_thread_manager.h" | 46 #include "chrome/browser/chromeos/trace/sys_trace_agent.h" |
| 46 #include "chromeos/dbus/debug_daemon_client.h" | |
| 47 #endif | 47 #endif |
| 48 | 48 |
| 49 #if defined(OS_WIN) | 49 #if defined(OS_WIN) |
| 50 #include "content/browser/tracing/etw_tracing_agent_win.h" | 50 #include "content/browser/tracing/etw_tracing_agent_win.h" |
| 51 #endif | 51 #endif |
| 52 | 52 |
| 53 using base::trace_event::TraceLog; | 53 using base::trace_event::TraceLog; |
| 54 using base::trace_event::TraceConfig; | 54 using base::trace_event::TraceConfig; |
| 55 | 55 |
| 56 namespace content { | 56 namespace content { |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 if (trace_config.IsSystraceEnabled()) { | 272 if (trace_config.IsSystraceEnabled()) { |
| 273 #if defined(ENABLE_POWER_TRACING) | 273 #if defined(ENABLE_POWER_TRACING) |
| 274 PowerTracingAgent::GetInstance()->StartAgentTracing( | 274 PowerTracingAgent::GetInstance()->StartAgentTracing( |
| 275 trace_config, | 275 trace_config, |
| 276 base::Bind(&TracingControllerImpl::OnStartAgentTracingAcked, | 276 base::Bind(&TracingControllerImpl::OnStartAgentTracingAcked, |
| 277 base::Unretained(this))); | 277 base::Unretained(this))); |
| 278 ++pending_start_tracing_ack_count_; | 278 ++pending_start_tracing_ack_count_; |
| 279 #endif | 279 #endif |
| 280 | 280 |
| 281 #if defined(OS_CHROMEOS) | 281 #if defined(OS_CHROMEOS) |
| 282 chromeos::DebugDaemonClient* debug_daemon = | 282 chromeos::SysTraceAgent::GetInstance()->StartAgentTracing( |
| 283 chromeos::DBusThreadManager::Get()->GetDebugDaemonClient(); | 283 trace_config, |
| 284 if (debug_daemon) { | 284 base::Bind(&TracingControllerImpl::OnStartAgentTracingAcked, |
| 285 debug_daemon->StartAgentTracing( | 285 base::Unretained(this))); |
| 286 trace_config, | 286 ++pending_start_tracing_ack_count_; |
| 287 base::Bind(&TracingControllerImpl::OnStartAgentTracingAcked, | |
| 288 base::Unretained(this))); | |
| 289 ++pending_start_tracing_ack_count_; | |
| 290 } | |
| 291 #elif defined(OS_WIN) | 287 #elif defined(OS_WIN) |
| 292 EtwTracingAgent::GetInstance()->StartAgentTracing( | 288 EtwTracingAgent::GetInstance()->StartAgentTracing( |
| 293 trace_config, | 289 trace_config, |
| 294 base::Bind(&TracingControllerImpl::OnStartAgentTracingAcked, | 290 base::Bind(&TracingControllerImpl::OnStartAgentTracingAcked, |
| 295 base::Unretained(this))); | 291 base::Unretained(this))); |
| 296 ++pending_start_tracing_ack_count_; | 292 ++pending_start_tracing_ack_count_; |
| 297 #endif | 293 #endif |
| 298 } | 294 } |
| 299 | 295 |
| 300 // TraceLog may have been enabled in startup tracing before threads are ready. | 296 // TraceLog may have been enabled in startup tracing before threads are ready. |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 591 base::RetainedRef(trace_message_filter), | 587 base::RetainedRef(trace_message_filter), |
| 592 queued_memory_dump_requests_.front().args.dump_guid, | 588 queued_memory_dump_requests_.front().args.dump_guid, |
| 593 false /* success */)); | 589 false /* success */)); |
| 594 } | 590 } |
| 595 } | 591 } |
| 596 trace_message_filters_.erase(trace_message_filter); | 592 trace_message_filters_.erase(trace_message_filter); |
| 597 } | 593 } |
| 598 | 594 |
| 599 void TracingControllerImpl::AddTracingAgent(const std::string& agent_name) { | 595 void TracingControllerImpl::AddTracingAgent(const std::string& agent_name) { |
| 600 #if defined(OS_CHROMEOS) | 596 #if defined(OS_CHROMEOS) |
| 601 auto* debug_daemon = | 597 auto* cros_trace_agent = chromeos::SysTraceAgent::GetInstance(); |
| 602 chromeos::DBusThreadManager::Get()->GetDebugDaemonClient(); | 598 if (agent_name == cros_trace_agent->GetTracingAgentName()) { |
| 603 if (agent_name == debug_daemon->GetTracingAgentName()) { | 599 additional_tracing_agents_.push_back(cros_trace_agent); |
| 604 additional_tracing_agents_.push_back(debug_daemon); | 600 cros_trace_agent->SetStopAgentTracingTaskRunner( |
| 605 debug_daemon->SetStopAgentTracingTaskRunner( | |
| 606 BrowserThread::GetBlockingPool()); | 601 BrowserThread::GetBlockingPool()); |
| 607 return; | 602 return; |
| 608 } | 603 } |
| 609 #elif defined(OS_WIN) | 604 #elif defined(OS_WIN) |
| 610 auto* etw_agent = EtwTracingAgent::GetInstance(); | 605 auto* etw_agent = EtwTracingAgent::GetInstance(); |
| 611 if (agent_name == etw_agent->GetTracingAgentName()) { | 606 if (agent_name == etw_agent->GetTracingAgentName()) { |
| 612 additional_tracing_agents_.push_back(etw_agent); | 607 additional_tracing_agents_.push_back(etw_agent); |
| 613 return; | 608 return; |
| 614 } | 609 } |
| 615 #endif | 610 #endif |
| (...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1116 // Schedule the next queued dump (if applicable). | 1111 // Schedule the next queued dump (if applicable). |
| 1117 if (!queued_memory_dump_requests_.empty()) { | 1112 if (!queued_memory_dump_requests_.empty()) { |
| 1118 BrowserThread::PostTask( | 1113 BrowserThread::PostTask( |
| 1119 BrowserThread::UI, FROM_HERE, | 1114 BrowserThread::UI, FROM_HERE, |
| 1120 base::Bind(&TracingControllerImpl::PerformNextQueuedGlobalMemoryDump, | 1115 base::Bind(&TracingControllerImpl::PerformNextQueuedGlobalMemoryDump, |
| 1121 base::Unretained(this))); | 1116 base::Unretained(this))); |
| 1122 } | 1117 } |
| 1123 } | 1118 } |
| 1124 | 1119 |
| 1125 } // namespace content | 1120 } // namespace content |
| OLD | NEW |