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 "build/build_config.h" |
| 15 #include "components/tracing/process_metrics_memory_dump_provider.h" |
15 #include "content/browser/tracing/file_tracing_provider_impl.h" | 16 #include "content/browser/tracing/file_tracing_provider_impl.h" |
16 #include "content/browser/tracing/power_tracing_agent.h" | 17 #include "content/browser/tracing/power_tracing_agent.h" |
17 #include "content/browser/tracing/trace_message_filter.h" | 18 #include "content/browser/tracing/trace_message_filter.h" |
18 #include "content/browser/tracing/tracing_ui.h" | 19 #include "content/browser/tracing/tracing_ui.h" |
19 #include "content/common/child_process_messages.h" | 20 #include "content/common/child_process_messages.h" |
20 #include "content/public/browser/browser_message_filter.h" | 21 #include "content/public/browser/browser_message_filter.h" |
21 #include "content/public/browser/content_browser_client.h" | 22 #include "content/public/browser/content_browser_client.h" |
22 #include "content/public/browser/gpu_data_manager.h" | 23 #include "content/public/browser/gpu_data_manager.h" |
23 #include "content/public/browser/tracing_delegate.h" | 24 #include "content/public/browser/tracing_delegate.h" |
24 #include "content/public/common/child_process_host.h" | 25 #include "content/public/common/child_process_host.h" |
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
549 void TracingControllerImpl::AddTraceMessageFilter( | 550 void TracingControllerImpl::AddTraceMessageFilter( |
550 TraceMessageFilter* trace_message_filter) { | 551 TraceMessageFilter* trace_message_filter) { |
551 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { | 552 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { |
552 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 553 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
553 base::Bind(&TracingControllerImpl::AddTraceMessageFilter, | 554 base::Bind(&TracingControllerImpl::AddTraceMessageFilter, |
554 base::Unretained(this), | 555 base::Unretained(this), |
555 make_scoped_refptr(trace_message_filter))); | 556 make_scoped_refptr(trace_message_filter))); |
556 return; | 557 return; |
557 } | 558 } |
558 | 559 |
| 560 #if defined(OS_LINUX) |
| 561 // On Linux the browser process dumps process metrics for child process due to |
| 562 // sandbox. |
| 563 tracing::ProcessMetricsMemoryDumpProvider::RegisterForProcess( |
| 564 trace_message_filter->peer_pid()); |
| 565 #endif |
| 566 |
559 trace_message_filters_.insert(trace_message_filter); | 567 trace_message_filters_.insert(trace_message_filter); |
560 if (can_cancel_watch_event()) { | 568 if (can_cancel_watch_event()) { |
561 trace_message_filter->SendSetWatchEvent(watch_category_name_, | 569 trace_message_filter->SendSetWatchEvent(watch_category_name_, |
562 watch_event_name_); | 570 watch_event_name_); |
563 } | 571 } |
564 if (can_stop_tracing()) { | 572 if (can_stop_tracing()) { |
565 trace_message_filter->SendBeginTracing( | 573 trace_message_filter->SendBeginTracing( |
566 TraceLog::GetInstance()->GetCurrentTraceConfig()); | 574 TraceLog::GetInstance()->GetCurrentTraceConfig()); |
567 } | 575 } |
568 if (can_stop_monitoring()) { | 576 if (can_stop_monitoring()) { |
569 trace_message_filter->SendStartMonitoring( | 577 trace_message_filter->SendStartMonitoring( |
570 TraceLog::GetInstance()->GetCurrentTraceConfig()); | 578 TraceLog::GetInstance()->GetCurrentTraceConfig()); |
571 } | 579 } |
572 | 580 |
573 FOR_EACH_OBSERVER(TraceMessageFilterObserver, trace_message_filter_observers_, | 581 FOR_EACH_OBSERVER(TraceMessageFilterObserver, trace_message_filter_observers_, |
574 OnTraceMessageFilterAdded(trace_message_filter)); | 582 OnTraceMessageFilterAdded(trace_message_filter)); |
575 } | 583 } |
576 | 584 |
577 void TracingControllerImpl::RemoveTraceMessageFilter( | 585 void TracingControllerImpl::RemoveTraceMessageFilter( |
578 TraceMessageFilter* trace_message_filter) { | 586 TraceMessageFilter* trace_message_filter) { |
579 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { | 587 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { |
580 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 588 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
581 base::Bind(&TracingControllerImpl::RemoveTraceMessageFilter, | 589 base::Bind(&TracingControllerImpl::RemoveTraceMessageFilter, |
582 base::Unretained(this), | 590 base::Unretained(this), |
583 make_scoped_refptr(trace_message_filter))); | 591 make_scoped_refptr(trace_message_filter))); |
584 return; | 592 return; |
585 } | 593 } |
586 | 594 |
| 595 #if defined(OS_LINUX) |
| 596 tracing::ProcessMetricsMemoryDumpProvider::UnregisterForProcess( |
| 597 trace_message_filter->peer_pid()); |
| 598 #endif |
| 599 |
587 // If a filter is removed while a response from that filter is pending then | 600 // If a filter is removed while a response from that filter is pending then |
588 // simulate the response. Otherwise the response count will be wrong and the | 601 // simulate the response. Otherwise the response count will be wrong and the |
589 // completion callback will never be executed. | 602 // completion callback will never be executed. |
590 if (pending_stop_tracing_ack_count_ > 0) { | 603 if (pending_stop_tracing_ack_count_ > 0) { |
591 TraceMessageFilterSet::const_iterator it = | 604 TraceMessageFilterSet::const_iterator it = |
592 pending_stop_tracing_filters_.find(trace_message_filter); | 605 pending_stop_tracing_filters_.find(trace_message_filter); |
593 if (it != pending_stop_tracing_filters_.end()) { | 606 if (it != pending_stop_tracing_filters_.end()) { |
594 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 607 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
595 base::Bind(&TracingControllerImpl::OnStopTracingAcked, | 608 base::Bind(&TracingControllerImpl::OnStopTracingAcked, |
596 base::Unretained(this), | 609 base::Unretained(this), |
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1123 is_monitoring_ = is_monitoring; | 1136 is_monitoring_ = is_monitoring; |
1124 #if !defined(OS_ANDROID) | 1137 #if !defined(OS_ANDROID) |
1125 for (std::set<TracingUI*>::iterator it = tracing_uis_.begin(); | 1138 for (std::set<TracingUI*>::iterator it = tracing_uis_.begin(); |
1126 it != tracing_uis_.end(); it++) { | 1139 it != tracing_uis_.end(); it++) { |
1127 (*it)->OnMonitoringStateChanged(is_monitoring); | 1140 (*it)->OnMonitoringStateChanged(is_monitoring); |
1128 } | 1141 } |
1129 #endif | 1142 #endif |
1130 } | 1143 } |
1131 | 1144 |
1132 } // namespace content | 1145 } // namespace content |
OLD | NEW |