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" |
| 15 #include "components/tracing/process_metrics_memory_dump_provider.h" |
14 #include "content/browser/tracing/file_tracing_provider_impl.h" | 16 #include "content/browser/tracing/file_tracing_provider_impl.h" |
15 #include "content/browser/tracing/power_tracing_agent.h" | 17 #include "content/browser/tracing/power_tracing_agent.h" |
16 #include "content/browser/tracing/trace_message_filter.h" | 18 #include "content/browser/tracing/trace_message_filter.h" |
17 #include "content/browser/tracing/tracing_ui.h" | 19 #include "content/browser/tracing/tracing_ui.h" |
18 #include "content/common/child_process_messages.h" | 20 #include "content/common/child_process_messages.h" |
19 #include "content/public/browser/browser_message_filter.h" | 21 #include "content/public/browser/browser_message_filter.h" |
20 #include "content/public/browser/content_browser_client.h" | 22 #include "content/public/browser/content_browser_client.h" |
21 #include "content/public/browser/gpu_data_manager.h" | 23 #include "content/public/browser/gpu_data_manager.h" |
22 #include "content/public/browser/tracing_delegate.h" | 24 #include "content/public/browser/tracing_delegate.h" |
23 #include "content/public/common/child_process_host.h" | 25 #include "content/public/common/child_process_host.h" |
(...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
579 void TracingControllerImpl::AddTraceMessageFilter( | 581 void TracingControllerImpl::AddTraceMessageFilter( |
580 TraceMessageFilter* trace_message_filter) { | 582 TraceMessageFilter* trace_message_filter) { |
581 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { | 583 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { |
582 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 584 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
583 base::Bind(&TracingControllerImpl::AddTraceMessageFilter, | 585 base::Bind(&TracingControllerImpl::AddTraceMessageFilter, |
584 base::Unretained(this), | 586 base::Unretained(this), |
585 make_scoped_refptr(trace_message_filter))); | 587 make_scoped_refptr(trace_message_filter))); |
586 return; | 588 return; |
587 } | 589 } |
588 | 590 |
| 591 #if defined(OS_LINUX) |
| 592 // The browser process dumps process metrics for child process in linux due to |
| 593 // sandbox. |
| 594 tracing::ProcessMetricsMemoryDumpProvider::RegisterForProcess( |
| 595 trace_message_filter->PeerHandle()); |
| 596 #endif |
| 597 |
589 trace_message_filters_.insert(trace_message_filter); | 598 trace_message_filters_.insert(trace_message_filter); |
590 if (can_cancel_watch_event()) { | 599 if (can_cancel_watch_event()) { |
591 trace_message_filter->SendSetWatchEvent(watch_category_name_, | 600 trace_message_filter->SendSetWatchEvent(watch_category_name_, |
592 watch_event_name_); | 601 watch_event_name_); |
593 } | 602 } |
594 if (can_stop_tracing()) { | 603 if (can_stop_tracing()) { |
595 trace_message_filter->SendBeginTracing( | 604 trace_message_filter->SendBeginTracing( |
596 TraceLog::GetInstance()->GetCurrentTraceConfig()); | 605 TraceLog::GetInstance()->GetCurrentTraceConfig()); |
597 } | 606 } |
598 if (can_stop_monitoring()) { | 607 if (can_stop_monitoring()) { |
599 trace_message_filter->SendStartMonitoring( | 608 trace_message_filter->SendStartMonitoring( |
600 TraceLog::GetInstance()->GetCurrentTraceConfig()); | 609 TraceLog::GetInstance()->GetCurrentTraceConfig()); |
601 } | 610 } |
602 | 611 |
603 FOR_EACH_OBSERVER(TraceMessageFilterObserver, trace_message_filter_observers_, | 612 FOR_EACH_OBSERVER(TraceMessageFilterObserver, trace_message_filter_observers_, |
604 OnTraceMessageFilterAdded(trace_message_filter)); | 613 OnTraceMessageFilterAdded(trace_message_filter)); |
605 } | 614 } |
606 | 615 |
607 void TracingControllerImpl::RemoveTraceMessageFilter( | 616 void TracingControllerImpl::RemoveTraceMessageFilter( |
608 TraceMessageFilter* trace_message_filter) { | 617 TraceMessageFilter* trace_message_filter) { |
609 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { | 618 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { |
610 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 619 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
611 base::Bind(&TracingControllerImpl::RemoveTraceMessageFilter, | 620 base::Bind(&TracingControllerImpl::RemoveTraceMessageFilter, |
612 base::Unretained(this), | 621 base::Unretained(this), |
613 make_scoped_refptr(trace_message_filter))); | 622 make_scoped_refptr(trace_message_filter))); |
614 return; | 623 return; |
615 } | 624 } |
616 | 625 |
| 626 #if defined(OS_LINUX) |
| 627 tracing::ProcessMetricsMemoryDumpProvider::UnregisterForProcess( |
| 628 trace_message_filter->PeerHandle()); |
| 629 #endif |
| 630 |
617 // If a filter is removed while a response from that filter is pending then | 631 // If a filter is removed while a response from that filter is pending then |
618 // simulate the response. Otherwise the response count will be wrong and the | 632 // simulate the response. Otherwise the response count will be wrong and the |
619 // completion callback will never be executed. | 633 // completion callback will never be executed. |
620 if (pending_stop_tracing_ack_count_ > 0) { | 634 if (pending_stop_tracing_ack_count_ > 0) { |
621 TraceMessageFilterSet::const_iterator it = | 635 TraceMessageFilterSet::const_iterator it = |
622 pending_stop_tracing_filters_.find(trace_message_filter); | 636 pending_stop_tracing_filters_.find(trace_message_filter); |
623 if (it != pending_stop_tracing_filters_.end()) { | 637 if (it != pending_stop_tracing_filters_.end()) { |
624 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 638 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
625 base::Bind(&TracingControllerImpl::OnStopTracingAcked, | 639 base::Bind(&TracingControllerImpl::OnStopTracingAcked, |
626 base::Unretained(this), | 640 base::Unretained(this), |
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1039 is_monitoring_ = is_monitoring; | 1053 is_monitoring_ = is_monitoring; |
1040 #if !defined(OS_ANDROID) | 1054 #if !defined(OS_ANDROID) |
1041 for (std::set<TracingUI*>::iterator it = tracing_uis_.begin(); | 1055 for (std::set<TracingUI*>::iterator it = tracing_uis_.begin(); |
1042 it != tracing_uis_.end(); it++) { | 1056 it != tracing_uis_.end(); it++) { |
1043 (*it)->OnMonitoringStateChanged(is_monitoring); | 1057 (*it)->OnMonitoringStateChanged(is_monitoring); |
1044 } | 1058 } |
1045 #endif | 1059 #endif |
1046 } | 1060 } |
1047 | 1061 |
1048 } // namespace content | 1062 } // namespace content |
OLD | NEW |