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