| 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" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 using base::trace_event::TraceLog; | 38 using base::trace_event::TraceLog; |
| 39 using base::trace_event::TraceConfig; | 39 using base::trace_event::TraceConfig; |
| 40 | 40 |
| 41 namespace content { | 41 namespace content { |
| 42 | 42 |
| 43 namespace { | 43 namespace { |
| 44 | 44 |
| 45 base::LazyInstance<TracingControllerImpl>::Leaky g_controller = | 45 base::LazyInstance<TracingControllerImpl>::Leaky g_controller = |
| 46 LAZY_INSTANCE_INITIALIZER; | 46 LAZY_INSTANCE_INITIALIZER; |
| 47 | 47 |
| 48 const char kChromeTracingAgentName[] = "chrome"; |
| 49 const char kETWTracingAgentName[] = "etw"; |
| 50 const char kChromeTraceLabel[] = "traceEvents"; |
| 48 | 51 |
| 49 std::string GetNetworkTypeString() { | 52 std::string GetNetworkTypeString() { |
| 50 switch (net::NetworkChangeNotifier::GetConnectionType()) { | 53 switch (net::NetworkChangeNotifier::GetConnectionType()) { |
| 51 case net::NetworkChangeNotifier::CONNECTION_ETHERNET: | 54 case net::NetworkChangeNotifier::CONNECTION_ETHERNET: |
| 52 return "Ethernet"; | 55 return "Ethernet"; |
| 53 case net::NetworkChangeNotifier::CONNECTION_WIFI: | 56 case net::NetworkChangeNotifier::CONNECTION_WIFI: |
| 54 return "WiFi"; | 57 return "WiFi"; |
| 55 case net::NetworkChangeNotifier::CONNECTION_2G: | 58 case net::NetworkChangeNotifier::CONNECTION_2G: |
| 56 return "2G"; | 59 return "2G"; |
| 57 case net::NetworkChangeNotifier::CONNECTION_3G: | 60 case net::NetworkChangeNotifier::CONNECTION_3G: |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 } | 141 } |
| 139 | 142 |
| 140 TracingControllerImpl::TracingControllerImpl() | 143 TracingControllerImpl::TracingControllerImpl() |
| 141 : pending_stop_tracing_ack_count_(0), | 144 : pending_stop_tracing_ack_count_(0), |
| 142 pending_capture_monitoring_snapshot_ack_count_(0), | 145 pending_capture_monitoring_snapshot_ack_count_(0), |
| 143 pending_trace_log_status_ack_count_(0), | 146 pending_trace_log_status_ack_count_(0), |
| 144 maximum_trace_buffer_usage_(0), | 147 maximum_trace_buffer_usage_(0), |
| 145 approximate_event_count_(0), | 148 approximate_event_count_(0), |
| 146 pending_memory_dump_ack_count_(0), | 149 pending_memory_dump_ack_count_(0), |
| 147 failed_memory_dump_count_(0), | 150 failed_memory_dump_count_(0), |
| 148 // Tracing may have been enabled by ContentMainRunner if kTraceStartup | |
| 149 // is specified in command line. | |
| 150 #if defined(OS_CHROMEOS) || defined(OS_WIN) | |
| 151 is_system_tracing_(false), | |
| 152 #endif | |
| 153 is_tracing_(false), | 151 is_tracing_(false), |
| 154 is_monitoring_(false), | 152 is_monitoring_(false) { |
| 155 is_power_tracing_(false) { | |
| 156 base::trace_event::MemoryDumpManager::GetInstance()->Initialize( | 153 base::trace_event::MemoryDumpManager::GetInstance()->Initialize( |
| 157 this /* delegate */, true /* is_coordinator */); | 154 this /* delegate */, true /* is_coordinator */); |
| 158 | 155 |
| 159 // Deliberately leaked, like this class. | 156 // Deliberately leaked, like this class. |
| 160 base::FileTracing::SetProvider(new FileTracingProviderImpl); | 157 base::FileTracing::SetProvider(new FileTracingProviderImpl); |
| 161 } | 158 } |
| 162 | 159 |
| 163 TracingControllerImpl::~TracingControllerImpl() { | 160 TracingControllerImpl::~TracingControllerImpl() { |
| 164 // This is a Leaky instance. | 161 // This is a Leaky instance. |
| 165 NOTREACHED(); | 162 NOTREACHED(); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 DCHECK_CURRENTLY_ON(BrowserThread::FILE); | 200 DCHECK_CURRENTLY_ON(BrowserThread::FILE); |
| 204 | 201 |
| 205 TraceLog::GetInstance()->SetDisabled(); | 202 TraceLog::GetInstance()->SetDisabled(); |
| 206 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, callback); | 203 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, callback); |
| 207 } | 204 } |
| 208 | 205 |
| 209 bool TracingControllerImpl::StartTracing( | 206 bool TracingControllerImpl::StartTracing( |
| 210 const TraceConfig& trace_config, | 207 const TraceConfig& trace_config, |
| 211 const StartTracingDoneCallback& callback) { | 208 const StartTracingDoneCallback& callback) { |
| 212 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 209 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 210 DCHECK(additional_tracing_agents_.empty()); |
| 213 | 211 |
| 214 if (!can_start_tracing()) | 212 if (!can_start_tracing()) |
| 215 return false; | 213 return false; |
| 216 is_tracing_ = true; | 214 is_tracing_ = true; |
| 215 start_tracing_done_callback_ = callback; |
| 217 | 216 |
| 218 #if defined(OS_ANDROID) | 217 #if defined(OS_ANDROID) |
| 219 if (pending_get_categories_done_callback_.is_null()) | 218 if (pending_get_categories_done_callback_.is_null()) |
| 220 TraceLog::GetInstance()->AddClockSyncMetadataEvent(); | 219 TraceLog::GetInstance()->AddClockSyncMetadataEvent(); |
| 221 #endif | 220 #endif |
| 222 | 221 |
| 223 if (trace_config.IsSystraceEnabled()) { | 222 if (trace_config.IsSystraceEnabled()) { |
| 224 DCHECK(!is_power_tracing_); | 223 if (PowerTracingAgent::GetInstance()->StartAgentTracing(trace_config)) |
| 225 is_power_tracing_ = PowerTracingAgent::GetInstance()->StartTracing(); | 224 additional_tracing_agents_.push_back(PowerTracingAgent::GetInstance()); |
| 226 #if defined(OS_CHROMEOS) | 225 #if defined(OS_CHROMEOS) |
| 227 DCHECK(!is_system_tracing_); | 226 chromeos::DebugDaemonClient* debug_daemon = |
| 228 chromeos::DBusThreadManager::Get()->GetDebugDaemonClient()-> | 227 chromeos::DBusThreadManager::Get()->GetDebugDaemonClient(); |
| 229 StartSystemTracing(); | 228 if (debug_daemon && debug_daemon->StartAgentTracing(trace_config)) { |
| 230 is_system_tracing_ = true; | 229 debug_daemon->SetStopAgentTracingTaskRunner( |
| 230 BrowserThread::GetBlockingPool()); |
| 231 additional_tracing_agents_.push_back( |
| 232 chromeos::DBusThreadManager::Get()->GetDebugDaemonClient()); |
| 233 } |
| 231 #elif defined(OS_WIN) | 234 #elif defined(OS_WIN) |
| 232 DCHECK(!is_system_tracing_); | 235 if (EtwSystemEventConsumer::GetInstance()->StartAgentTracing( |
| 233 is_system_tracing_ = | 236 trace_config)) { |
| 234 EtwSystemEventConsumer::GetInstance()->StartSystemTracing(); | 237 additional_tracing_agents_.push_back( |
| 238 EtwSystemEventConsumer::GetInstance()); |
| 239 } |
| 235 #endif | 240 #endif |
| 236 } | 241 } |
| 237 | 242 |
| 238 // TraceLog may have been enabled in startup tracing before threads are ready. | 243 // TraceLog may have been enabled in startup tracing before threads are ready. |
| 239 if (TraceLog::GetInstance()->IsEnabled()) | 244 if (TraceLog::GetInstance()->IsEnabled()) |
| 240 return true; | 245 return true; |
| 241 | 246 return StartAgentTracing(trace_config); |
| 242 base::Closure on_start_tracing_done_callback = | |
| 243 base::Bind(&TracingControllerImpl::OnStartTracingDone, | |
| 244 base::Unretained(this), | |
| 245 trace_config, callback); | |
| 246 if (!BrowserThread::PostTask( | |
| 247 BrowserThread::FILE, FROM_HERE, | |
| 248 base::Bind(&TracingControllerImpl::SetEnabledOnFileThread, | |
| 249 base::Unretained(this), trace_config, | |
| 250 base::trace_event::TraceLog::RECORDING_MODE, | |
| 251 on_start_tracing_done_callback))) { | |
| 252 // BrowserThread::PostTask fails if the threads haven't been created yet, | |
| 253 // so it should be safe to just use TraceLog::SetEnabled directly. | |
| 254 base::trace_event::TraceLog::GetInstance()->SetEnabled( | |
| 255 trace_config, base::trace_event::TraceLog::RECORDING_MODE); | |
| 256 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | |
| 257 on_start_tracing_done_callback); | |
| 258 } | |
| 259 | |
| 260 return true; | |
| 261 } | 247 } |
| 262 | 248 |
| 263 void TracingControllerImpl::OnStartTracingDone( | 249 void TracingControllerImpl::OnStartAgentTracingDone( |
| 264 const TraceConfig& trace_config, | 250 const TraceConfig& trace_config, |
| 265 const StartTracingDoneCallback& callback) { | 251 const StartTracingDoneCallback& callback) { |
| 266 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 252 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 267 | 253 |
| 268 TRACE_EVENT_API_ADD_METADATA_EVENT("IsTimeTicksHighResolution", "value", | 254 TRACE_EVENT_API_ADD_METADATA_EVENT("IsTimeTicksHighResolution", "value", |
| 269 base::TimeTicks::IsHighResolution()); | 255 base::TimeTicks::IsHighResolution()); |
| 270 TRACE_EVENT_API_ADD_METADATA_EVENT("TraceConfig", "value", | 256 TRACE_EVENT_API_ADD_METADATA_EVENT("TraceConfig", "value", |
| 271 trace_config.AsConvertableToTraceFormat()); | 257 trace_config.AsConvertableToTraceFormat()); |
| 272 | 258 |
| 273 // Notify all child processes. | 259 // Notify all child processes. |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 #if defined(OS_ANDROID) | 304 #if defined(OS_ANDROID) |
| 319 if (pending_get_categories_done_callback_.is_null()) | 305 if (pending_get_categories_done_callback_.is_null()) |
| 320 TraceLog::GetInstance()->AddClockSyncMetadataEvent(); | 306 TraceLog::GetInstance()->AddClockSyncMetadataEvent(); |
| 321 #endif | 307 #endif |
| 322 | 308 |
| 323 // Count myself (local trace) in pending_stop_tracing_ack_count_, | 309 // Count myself (local trace) in pending_stop_tracing_ack_count_, |
| 324 // acked below. | 310 // acked below. |
| 325 pending_stop_tracing_ack_count_ = trace_message_filters_.size() + 1; | 311 pending_stop_tracing_ack_count_ = trace_message_filters_.size() + 1; |
| 326 pending_stop_tracing_filters_ = trace_message_filters_; | 312 pending_stop_tracing_filters_ = trace_message_filters_; |
| 327 | 313 |
| 328 #if defined(OS_CHROMEOS) || defined(OS_WIN) | 314 pending_stop_tracing_ack_count_ += additional_tracing_agents_.size(); |
| 329 if (is_system_tracing_) { | 315 for (auto it : additional_tracing_agents_) { |
| 330 // Disable system tracing. | 316 it->StopAgentTracing( |
| 331 is_system_tracing_ = false; | 317 base::Bind(&TracingControllerImpl::OnEndAgentTracingAcked, |
| 332 ++pending_stop_tracing_ack_count_; | |
| 333 | |
| 334 #if defined(OS_CHROMEOS) | |
| 335 scoped_refptr<base::TaskRunner> task_runner = | |
| 336 BrowserThread::GetBlockingPool(); | |
| 337 chromeos::DBusThreadManager::Get() | |
| 338 ->GetDebugDaemonClient() | |
| 339 ->RequestStopSystemTracing( | |
| 340 task_runner, | |
| 341 base::Bind(&TracingControllerImpl::OnEndSystemTracingAcked, | |
| 342 base::Unretained(this))); | |
| 343 #elif defined(OS_WIN) | |
| 344 EtwSystemEventConsumer::GetInstance()->StopSystemTracing( | |
| 345 base::Bind(&TracingControllerImpl::OnEndSystemTracingAcked, | |
| 346 base::Unretained(this))); | |
| 347 #endif | |
| 348 } | |
| 349 #endif // defined(OS_CHROMEOS) || defined(OS_WIN) | |
| 350 | |
| 351 if (is_power_tracing_) { | |
| 352 is_power_tracing_ = false; | |
| 353 ++pending_stop_tracing_ack_count_; | |
| 354 PowerTracingAgent::GetInstance()->StopTracing( | |
| 355 base::Bind(&TracingControllerImpl::OnEndPowerTracingAcked, | |
| 356 base::Unretained(this))); | 318 base::Unretained(this))); |
| 357 } | 319 } |
| 320 additional_tracing_agents_.clear(); |
| 358 | 321 |
| 359 // Handle special case of zero child processes by immediately flushing the | 322 StopAgentTracing(StopAgentTracingCallback()); |
| 360 // trace log. Once the flush has completed the caller will be notified that | |
| 361 // tracing has ended. | |
| 362 if (pending_stop_tracing_ack_count_ == 1) { | |
| 363 // Flush/cancel asynchronously now, because we don't have any children to | |
| 364 // wait for. | |
| 365 if (trace_data_sink_) { | |
| 366 TraceLog::GetInstance()->Flush( | |
| 367 base::Bind(&TracingControllerImpl::OnLocalTraceDataCollected, | |
| 368 base::Unretained(this)), | |
| 369 true); | |
| 370 } else { | |
| 371 TraceLog::GetInstance()->CancelTracing( | |
| 372 base::Bind(&TracingControllerImpl::OnLocalTraceDataCollected, | |
| 373 base::Unretained(this))); | |
| 374 } | |
| 375 } | |
| 376 | |
| 377 // Notify all child processes. | |
| 378 for (TraceMessageFilterSet::iterator it = trace_message_filters_.begin(); | |
| 379 it != trace_message_filters_.end(); ++it) { | |
| 380 if (trace_data_sink_) | |
| 381 it->get()->SendEndTracing(); | |
| 382 else | |
| 383 it->get()->SendCancelTracing(); | |
| 384 } | |
| 385 } | 323 } |
| 386 | 324 |
| 387 bool TracingControllerImpl::StartMonitoring( | 325 bool TracingControllerImpl::StartMonitoring( |
| 388 const TraceConfig& trace_config, | 326 const TraceConfig& trace_config, |
| 389 const StartMonitoringDoneCallback& callback) { | 327 const StartMonitoringDoneCallback& callback) { |
| 390 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 328 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 391 | 329 |
| 392 if (!can_start_monitoring()) | 330 if (!can_start_monitoring()) |
| 393 return false; | 331 return false; |
| 394 OnMonitoringStateChanged(true); | 332 OnMonitoringStateChanged(true); |
| (...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 731 // Trigger callback if one is set. | 669 // Trigger callback if one is set. |
| 732 if (!pending_get_categories_done_callback_.is_null()) { | 670 if (!pending_get_categories_done_callback_.is_null()) { |
| 733 pending_get_categories_done_callback_.Run(known_category_groups_); | 671 pending_get_categories_done_callback_.Run(known_category_groups_); |
| 734 pending_get_categories_done_callback_.Reset(); | 672 pending_get_categories_done_callback_.Reset(); |
| 735 } else if (trace_data_sink_.get()) { | 673 } else if (trace_data_sink_.get()) { |
| 736 trace_data_sink_->Close(); | 674 trace_data_sink_->Close(); |
| 737 trace_data_sink_ = NULL; | 675 trace_data_sink_ = NULL; |
| 738 } | 676 } |
| 739 } | 677 } |
| 740 | 678 |
| 741 void TracingControllerImpl::OnEndPowerTracingAcked( | 679 void TracingControllerImpl::OnEndAgentTracingAcked( |
| 680 const std::string& agent_name, |
| 681 const std::string& events_label, |
| 742 const scoped_refptr<base::RefCountedString>& events_str_ptr) { | 682 const scoped_refptr<base::RefCountedString>& events_str_ptr) { |
| 743 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 683 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 744 | 684 |
| 745 if (trace_data_sink_.get()) { | 685 if (trace_data_sink_.get()) { |
| 746 std::string json_string = base::GetQuotedJSONString(events_str_ptr->data()); | 686 std::string json_string; |
| 747 trace_data_sink_->SetPowerTrace(json_string); | 687 if (agent_name == kETWTracingAgentName) { |
| 688 // The Windows kernel events are kept into a JSON format stored as string |
| 689 // and must not be escaped. |
| 690 json_string = events_str_ptr->data(); |
| 691 } else { |
| 692 json_string = base::GetQuotedJSONString(events_str_ptr->data()); |
| 693 } |
| 694 trace_data_sink_->AddAgentTrace(events_label, json_string); |
| 748 } | 695 } |
| 749 std::vector<std::string> category_groups; | 696 std::vector<std::string> category_groups; |
| 750 OnStopTracingAcked(NULL, category_groups); | 697 OnStopTracingAcked(NULL, category_groups); |
| 751 } | 698 } |
| 752 | 699 |
| 753 #if defined(OS_CHROMEOS) || defined(OS_WIN) | |
| 754 void TracingControllerImpl::OnEndSystemTracingAcked( | |
| 755 const scoped_refptr<base::RefCountedString>& events_str_ptr) { | |
| 756 DCHECK_CURRENTLY_ON(BrowserThread::UI); | |
| 757 | |
| 758 if (trace_data_sink_.get()) { | |
| 759 #if defined(OS_WIN) | |
| 760 // The Windows kernel events are kept into a JSon format stored as string | |
| 761 // and must not be escaped. | |
| 762 std::string json_string = events_str_ptr->data(); | |
| 763 #else | |
| 764 std::string json_string = | |
| 765 base::GetQuotedJSONString(events_str_ptr->data()); | |
| 766 #endif | |
| 767 trace_data_sink_->SetSystemTrace(json_string); | |
| 768 } | |
| 769 DCHECK(!is_system_tracing_); | |
| 770 std::vector<std::string> category_groups; | |
| 771 OnStopTracingAcked(NULL, category_groups); | |
| 772 } | |
| 773 #endif | |
| 774 | |
| 775 void TracingControllerImpl::OnCaptureMonitoringSnapshotAcked( | 700 void TracingControllerImpl::OnCaptureMonitoringSnapshotAcked( |
| 776 TraceMessageFilter* trace_message_filter) { | 701 TraceMessageFilter* trace_message_filter) { |
| 777 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { | 702 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { |
| 778 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 703 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 779 base::Bind(&TracingControllerImpl::OnCaptureMonitoringSnapshotAcked, | 704 base::Bind(&TracingControllerImpl::OnCaptureMonitoringSnapshotAcked, |
| 780 base::Unretained(this), | 705 base::Unretained(this), |
| 781 make_scoped_refptr(trace_message_filter))); | 706 make_scoped_refptr(trace_message_filter))); |
| 782 return; | 707 return; |
| 783 } | 708 } |
| 784 | 709 |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 917 DCHECK(tracing_uis_.find(tracing_ui) == tracing_uis_.end()); | 842 DCHECK(tracing_uis_.find(tracing_ui) == tracing_uis_.end()); |
| 918 tracing_uis_.insert(tracing_ui); | 843 tracing_uis_.insert(tracing_ui); |
| 919 } | 844 } |
| 920 | 845 |
| 921 void TracingControllerImpl::UnregisterTracingUI(TracingUI* tracing_ui) { | 846 void TracingControllerImpl::UnregisterTracingUI(TracingUI* tracing_ui) { |
| 922 std::set<TracingUI*>::iterator it = tracing_uis_.find(tracing_ui); | 847 std::set<TracingUI*>::iterator it = tracing_uis_.find(tracing_ui); |
| 923 DCHECK(it != tracing_uis_.end()); | 848 DCHECK(it != tracing_uis_.end()); |
| 924 tracing_uis_.erase(it); | 849 tracing_uis_.erase(it); |
| 925 } | 850 } |
| 926 | 851 |
| 852 std::string TracingControllerImpl::GetTracingAgentName() { |
| 853 return kChromeTracingAgentName; |
| 854 } |
| 855 |
| 856 std::string TracingControllerImpl::GetTraceEventLabel() { |
| 857 return kChromeTraceLabel; |
| 858 } |
| 859 |
| 860 bool TracingControllerImpl::StartAgentTracing( |
| 861 const base::trace_event::TraceConfig& trace_config) { |
| 862 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 863 |
| 864 base::Closure on_start_tracing_done_callback = |
| 865 base::Bind(&TracingControllerImpl::OnStartAgentTracingDone, |
| 866 base::Unretained(this), |
| 867 trace_config, start_tracing_done_callback_); |
| 868 if (!BrowserThread::PostTask( |
| 869 BrowserThread::FILE, FROM_HERE, |
| 870 base::Bind(&TracingControllerImpl::SetEnabledOnFileThread, |
| 871 base::Unretained(this), trace_config, |
| 872 base::trace_event::TraceLog::RECORDING_MODE, |
| 873 on_start_tracing_done_callback))) { |
| 874 // BrowserThread::PostTask fails if the threads haven't been created yet, |
| 875 // so it should be safe to just use TraceLog::SetEnabled directly. |
| 876 base::trace_event::TraceLog::GetInstance()->SetEnabled( |
| 877 trace_config, base::trace_event::TraceLog::RECORDING_MODE); |
| 878 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 879 on_start_tracing_done_callback); |
| 880 } |
| 881 |
| 882 return true; |
| 883 } |
| 884 |
| 885 void TracingControllerImpl::StopAgentTracing( |
| 886 const StopAgentTracingCallback& callback) { |
| 887 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 888 // Handle special case of zero child processes by immediately flushing the |
| 889 // trace log. Once the flush has completed the caller will be notified that |
| 890 // tracing has ended. |
| 891 if (pending_stop_tracing_ack_count_ == 1) { |
| 892 // Flush/cancel asynchronously now, because we don't have any children to |
| 893 // wait for. |
| 894 if (trace_data_sink_) { |
| 895 TraceLog::GetInstance()->Flush( |
| 896 base::Bind(&TracingControllerImpl::OnLocalTraceDataCollected, |
| 897 base::Unretained(this)), |
| 898 true); |
| 899 } else { |
| 900 TraceLog::GetInstance()->CancelTracing( |
| 901 base::Bind(&TracingControllerImpl::OnLocalTraceDataCollected, |
| 902 base::Unretained(this))); |
| 903 } |
| 904 } |
| 905 |
| 906 // Notify all child processes. |
| 907 for (auto it : trace_message_filters_) { |
| 908 if (trace_data_sink_) |
| 909 it->SendEndTracing(); |
| 910 else |
| 911 it->SendCancelTracing(); |
| 912 } |
| 913 } |
| 914 |
| 915 bool TracingControllerImpl::SupportsExplicitClockSync() { |
| 916 // TODO(zhenw): return true after implementing explicit clock sync. |
| 917 return false; |
| 918 } |
| 919 |
| 920 void TracingControllerImpl::RecordClockSyncMarker( |
| 921 int sync_id, |
| 922 const RecordClockSyncMarkerCallback& callback) { |
| 923 DCHECK(SupportsExplicitClockSync()); |
| 924 // TODO(zhenw): implement explicit clock sync. |
| 925 } |
| 926 |
| 927 void TracingControllerImpl::IssueClockSyncMarker() { |
| 928 // TODO(zhenw): implement explicit clock sync. |
| 929 } |
| 930 |
| 927 void TracingControllerImpl::RequestGlobalMemoryDump( | 931 void TracingControllerImpl::RequestGlobalMemoryDump( |
| 928 const base::trace_event::MemoryDumpRequestArgs& args, | 932 const base::trace_event::MemoryDumpRequestArgs& args, |
| 929 const base::trace_event::MemoryDumpCallback& callback) { | 933 const base::trace_event::MemoryDumpCallback& callback) { |
| 930 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { | 934 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { |
| 931 BrowserThread::PostTask( | 935 BrowserThread::PostTask( |
| 932 BrowserThread::UI, FROM_HERE, | 936 BrowserThread::UI, FROM_HERE, |
| 933 base::Bind(&TracingControllerImpl::RequestGlobalMemoryDump, | 937 base::Bind(&TracingControllerImpl::RequestGlobalMemoryDump, |
| 934 base::Unretained(this), args, callback)); | 938 base::Unretained(this), args, callback)); |
| 935 return; | 939 return; |
| 936 } | 940 } |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1053 is_monitoring_ = is_monitoring; | 1057 is_monitoring_ = is_monitoring; |
| 1054 #if !defined(OS_ANDROID) | 1058 #if !defined(OS_ANDROID) |
| 1055 for (std::set<TracingUI*>::iterator it = tracing_uis_.begin(); | 1059 for (std::set<TracingUI*>::iterator it = tracing_uis_.begin(); |
| 1056 it != tracing_uis_.end(); it++) { | 1060 it != tracing_uis_.end(); it++) { |
| 1057 (*it)->OnMonitoringStateChanged(is_monitoring); | 1061 (*it)->OnMonitoringStateChanged(is_monitoring); |
| 1058 } | 1062 } |
| 1059 #endif | 1063 #endif |
| 1060 } | 1064 } |
| 1061 | 1065 |
| 1062 } // namespace content | 1066 } // namespace content |
| OLD | NEW |