| 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 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 409 if (pending_get_categories_done_callback_.is_null()) | 409 if (pending_get_categories_done_callback_.is_null()) |
| 410 TraceLog::GetInstance()->AddClockSyncMetadataEvent(); | 410 TraceLog::GetInstance()->AddClockSyncMetadataEvent(); |
| 411 #endif | 411 #endif |
| 412 | 412 |
| 413 // Count myself (local trace) in pending_stop_tracing_ack_count_, | 413 // Count myself (local trace) in pending_stop_tracing_ack_count_, |
| 414 // acked below. | 414 // acked below. |
| 415 pending_stop_tracing_ack_count_ = trace_message_filters_.size() + 1; | 415 pending_stop_tracing_ack_count_ = trace_message_filters_.size() + 1; |
| 416 pending_stop_tracing_filters_ = trace_message_filters_; | 416 pending_stop_tracing_filters_ = trace_message_filters_; |
| 417 | 417 |
| 418 pending_stop_tracing_ack_count_ += additional_tracing_agents_.size(); | 418 pending_stop_tracing_ack_count_ += additional_tracing_agents_.size(); |
| 419 for (auto it : additional_tracing_agents_) { | 419 for (auto* it : additional_tracing_agents_) { |
| 420 it->StopAgentTracing( | 420 it->StopAgentTracing( |
| 421 base::Bind(&TracingControllerImpl::OnEndAgentTracingAcked, | 421 base::Bind(&TracingControllerImpl::OnEndAgentTracingAcked, |
| 422 base::Unretained(this))); | 422 base::Unretained(this))); |
| 423 } | 423 } |
| 424 additional_tracing_agents_.clear(); | 424 additional_tracing_agents_.clear(); |
| 425 | 425 |
| 426 StopAgentTracing(StopAgentTracingCallback()); | 426 StopAgentTracing(StopAgentTracingCallback()); |
| 427 } | 427 } |
| 428 | 428 |
| 429 bool TracingControllerImpl::GetTraceBufferUsage( | 429 bool TracingControllerImpl::GetTraceBufferUsage( |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 590 base::RetainedRef(trace_message_filter), | 590 base::RetainedRef(trace_message_filter), |
| 591 queued_memory_dump_requests_.front().args.dump_guid, | 591 queued_memory_dump_requests_.front().args.dump_guid, |
| 592 false /* success */)); | 592 false /* success */)); |
| 593 } | 593 } |
| 594 } | 594 } |
| 595 trace_message_filters_.erase(trace_message_filter); | 595 trace_message_filters_.erase(trace_message_filter); |
| 596 } | 596 } |
| 597 | 597 |
| 598 void TracingControllerImpl::AddTracingAgent(const std::string& agent_name) { | 598 void TracingControllerImpl::AddTracingAgent(const std::string& agent_name) { |
| 599 #if defined(OS_CHROMEOS) | 599 #if defined(OS_CHROMEOS) |
| 600 auto debug_daemon = | 600 auto* debug_daemon = |
| 601 chromeos::DBusThreadManager::Get()->GetDebugDaemonClient(); | 601 chromeos::DBusThreadManager::Get()->GetDebugDaemonClient(); |
| 602 if (agent_name == debug_daemon->GetTracingAgentName()) { | 602 if (agent_name == debug_daemon->GetTracingAgentName()) { |
| 603 additional_tracing_agents_.push_back(debug_daemon); | 603 additional_tracing_agents_.push_back(debug_daemon); |
| 604 debug_daemon->SetStopAgentTracingTaskRunner( | 604 debug_daemon->SetStopAgentTracingTaskRunner( |
| 605 BrowserThread::GetBlockingPool()); | 605 BrowserThread::GetBlockingPool()); |
| 606 return; | 606 return; |
| 607 } | 607 } |
| 608 #elif defined(OS_WIN) | 608 #elif defined(OS_WIN) |
| 609 auto etw_agent = EtwTracingAgent::GetInstance(); | 609 auto* etw_agent = EtwTracingAgent::GetInstance(); |
| 610 if (agent_name == etw_agent->GetTracingAgentName()) { | 610 if (agent_name == etw_agent->GetTracingAgentName()) { |
| 611 additional_tracing_agents_.push_back(etw_agent); | 611 additional_tracing_agents_.push_back(etw_agent); |
| 612 return; | 612 return; |
| 613 } | 613 } |
| 614 #endif | 614 #endif |
| 615 | 615 |
| 616 #if defined(ENABLE_POWER_TRACING) | 616 #if defined(ENABLE_POWER_TRACING) |
| 617 auto power_agent = PowerTracingAgent::GetInstance(); | 617 auto* power_agent = PowerTracingAgent::GetInstance(); |
| 618 if (agent_name == power_agent->GetTracingAgentName()) { | 618 if (agent_name == power_agent->GetTracingAgentName()) { |
| 619 additional_tracing_agents_.push_back(power_agent); | 619 additional_tracing_agents_.push_back(power_agent); |
| 620 return; | 620 return; |
| 621 } | 621 } |
| 622 #endif | 622 #endif |
| 623 | 623 |
| 624 DCHECK(agent_name == kChromeTracingAgentName); | 624 DCHECK(agent_name == kChromeTracingAgentName); |
| 625 } | 625 } |
| 626 | 626 |
| 627 void TracingControllerImpl::OnStartAgentTracingAcked( | 627 void TracingControllerImpl::OnStartAgentTracingAcked( |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 879 const RecordClockSyncMarkerCallback& callback) { | 879 const RecordClockSyncMarkerCallback& callback) { |
| 880 DCHECK(SupportsExplicitClockSync()); | 880 DCHECK(SupportsExplicitClockSync()); |
| 881 | 881 |
| 882 TRACE_EVENT_CLOCK_SYNC_RECEIVER(sync_id); | 882 TRACE_EVENT_CLOCK_SYNC_RECEIVER(sync_id); |
| 883 } | 883 } |
| 884 | 884 |
| 885 void TracingControllerImpl::IssueClockSyncMarker() { | 885 void TracingControllerImpl::IssueClockSyncMarker() { |
| 886 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 886 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 887 DCHECK(pending_clock_sync_ack_count_ == 0); | 887 DCHECK(pending_clock_sync_ack_count_ == 0); |
| 888 | 888 |
| 889 for (const auto& it : additional_tracing_agents_) { | 889 for (auto* it : additional_tracing_agents_) { |
| 890 if (it->SupportsExplicitClockSync()) { | 890 if (it->SupportsExplicitClockSync()) { |
| 891 it->RecordClockSyncMarker( | 891 it->RecordClockSyncMarker( |
| 892 base::GenerateGUID(), | 892 base::GenerateGUID(), |
| 893 base::Bind(&TracingControllerImpl::OnClockSyncMarkerRecordedByAgent, | 893 base::Bind(&TracingControllerImpl::OnClockSyncMarkerRecordedByAgent, |
| 894 base::Unretained(this))); | 894 base::Unretained(this))); |
| 895 pending_clock_sync_ack_count_++; | 895 pending_clock_sync_ack_count_++; |
| 896 } | 896 } |
| 897 } | 897 } |
| 898 | 898 |
| 899 // If no clock sync is needed, stop tracing right away. Otherwise, schedule | 899 // If no clock sync is needed, stop tracing right away. Otherwise, schedule |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1115 // Schedule the next queued dump (if applicable). | 1115 // Schedule the next queued dump (if applicable). |
| 1116 if (!queued_memory_dump_requests_.empty()) { | 1116 if (!queued_memory_dump_requests_.empty()) { |
| 1117 BrowserThread::PostTask( | 1117 BrowserThread::PostTask( |
| 1118 BrowserThread::UI, FROM_HERE, | 1118 BrowserThread::UI, FROM_HERE, |
| 1119 base::Bind(&TracingControllerImpl::PerformNextQueuedGlobalMemoryDump, | 1119 base::Bind(&TracingControllerImpl::PerformNextQueuedGlobalMemoryDump, |
| 1120 base::Unretained(this))); | 1120 base::Unretained(this))); |
| 1121 } | 1121 } |
| 1122 } | 1122 } |
| 1123 | 1123 |
| 1124 } // namespace content | 1124 } // namespace content |
| OLD | NEW |