Chromium Code Reviews| 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/files/file_util.h" | 7 #include "base/files/file_util.h" |
| 8 #include "base/json/string_escape.h" | 8 #include "base/json/string_escape.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| (...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 477 watch_event_name_); | 477 watch_event_name_); |
| 478 } | 478 } |
| 479 if (can_disable_recording()) { | 479 if (can_disable_recording()) { |
| 480 trace_message_filter->SendBeginTracing( | 480 trace_message_filter->SendBeginTracing( |
| 481 TraceLog::GetInstance()->GetCurrentTraceConfig()); | 481 TraceLog::GetInstance()->GetCurrentTraceConfig()); |
| 482 } | 482 } |
| 483 if (can_disable_monitoring()) { | 483 if (can_disable_monitoring()) { |
| 484 trace_message_filter->SendEnableMonitoring( | 484 trace_message_filter->SendEnableMonitoring( |
| 485 TraceLog::GetInstance()->GetCurrentTraceConfig()); | 485 TraceLog::GetInstance()->GetCurrentTraceConfig()); |
| 486 } | 486 } |
| 487 if (!trace_message_filter_added_callback_.is_null()) | |
| 488 trace_message_filter_added_callback_.Run(trace_message_filter); | |
| 487 } | 489 } |
| 488 | 490 |
| 489 void TracingControllerImpl::RemoveTraceMessageFilter( | 491 void TracingControllerImpl::RemoveTraceMessageFilter( |
| 490 TraceMessageFilter* trace_message_filter) { | 492 TraceMessageFilter* trace_message_filter) { |
| 491 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { | 493 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { |
| 492 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 494 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 493 base::Bind(&TracingControllerImpl::RemoveTraceMessageFilter, | 495 base::Bind(&TracingControllerImpl::RemoveTraceMessageFilter, |
| 494 base::Unretained(this), | 496 base::Unretained(this), |
| 495 make_scoped_refptr(trace_message_filter))); | 497 make_scoped_refptr(trace_message_filter))); |
| 496 return; | 498 return; |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 818 pending_memory_dump_filters_ = trace_message_filters_; | 820 pending_memory_dump_filters_ = trace_message_filters_; |
| 819 | 821 |
| 820 for (const scoped_refptr<TraceMessageFilter>& tmf : trace_message_filters_) | 822 for (const scoped_refptr<TraceMessageFilter>& tmf : trace_message_filters_) |
| 821 tmf->SendProcessMemoryDumpRequest(args); | 823 tmf->SendProcessMemoryDumpRequest(args); |
| 822 } | 824 } |
| 823 | 825 |
| 824 bool TracingControllerImpl::IsCoordinatorProcess() const { | 826 bool TracingControllerImpl::IsCoordinatorProcess() const { |
| 825 return true; | 827 return true; |
| 826 } | 828 } |
| 827 | 829 |
| 830 void TracingControllerImpl::SetTraceMessageFilterAddedCallback( | |
| 831 const TraceMessageFilterAddedCallback& callback) { | |
| 832 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
| 833 trace_message_filter_added_callback_ = callback; | |
| 834 } | |
| 835 | |
| 836 void TracingControllerImpl::GetTraceMessageFilters( | |
| 837 TraceMessageFilterSet* filters) { | |
| 838 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
| 839 std::copy(trace_message_filters_.begin(), trace_message_filters_.end(), | |
|
dcheng
2015/07/23 21:11:33
filters->insert(trace_message_filters_.begin(), tr
shatch
2015/07/23 23:06:52
Done.
| |
| 840 std::inserter(*filters, filters->end())); | |
| 841 } | |
| 842 | |
| 828 void TracingControllerImpl::OnProcessMemoryDumpResponse( | 843 void TracingControllerImpl::OnProcessMemoryDumpResponse( |
| 829 TraceMessageFilter* trace_message_filter, | 844 TraceMessageFilter* trace_message_filter, |
| 830 uint64 dump_guid, | 845 uint64 dump_guid, |
| 831 bool success) { | 846 bool success) { |
| 832 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { | 847 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { |
| 833 BrowserThread::PostTask( | 848 BrowserThread::PostTask( |
| 834 BrowserThread::UI, FROM_HERE, | 849 BrowserThread::UI, FROM_HERE, |
| 835 base::Bind(&TracingControllerImpl::OnProcessMemoryDumpResponse, | 850 base::Bind(&TracingControllerImpl::OnProcessMemoryDumpResponse, |
| 836 base::Unretained(this), | 851 base::Unretained(this), |
| 837 make_scoped_refptr(trace_message_filter), dump_guid, | 852 make_scoped_refptr(trace_message_filter), dump_guid, |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 891 is_monitoring_ = is_monitoring; | 906 is_monitoring_ = is_monitoring; |
| 892 #if !defined(OS_ANDROID) | 907 #if !defined(OS_ANDROID) |
| 893 for (std::set<TracingUI*>::iterator it = tracing_uis_.begin(); | 908 for (std::set<TracingUI*>::iterator it = tracing_uis_.begin(); |
| 894 it != tracing_uis_.end(); it++) { | 909 it != tracing_uis_.end(); it++) { |
| 895 (*it)->OnMonitoringStateChanged(is_monitoring); | 910 (*it)->OnMonitoringStateChanged(is_monitoring); |
| 896 } | 911 } |
| 897 #endif | 912 #endif |
| 898 } | 913 } |
| 899 | 914 |
| 900 } // namespace content | 915 } // namespace content |
| OLD | NEW |