Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(883)

Side by Side Diff: content/browser/tracing/tracing_controller_impl.cc

Issue 1243743002: Slow Reports - Add message filter to trigger background traces from child processes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed dcheng's comments. Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/browser/tracing/tracing_controller_impl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 filters->insert(trace_message_filters_.begin(), trace_message_filters_.end());
840 }
841
828 void TracingControllerImpl::OnProcessMemoryDumpResponse( 842 void TracingControllerImpl::OnProcessMemoryDumpResponse(
829 TraceMessageFilter* trace_message_filter, 843 TraceMessageFilter* trace_message_filter,
830 uint64 dump_guid, 844 uint64 dump_guid,
831 bool success) { 845 bool success) {
832 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { 846 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) {
833 BrowserThread::PostTask( 847 BrowserThread::PostTask(
834 BrowserThread::UI, FROM_HERE, 848 BrowserThread::UI, FROM_HERE,
835 base::Bind(&TracingControllerImpl::OnProcessMemoryDumpResponse, 849 base::Bind(&TracingControllerImpl::OnProcessMemoryDumpResponse,
836 base::Unretained(this), 850 base::Unretained(this),
837 make_scoped_refptr(trace_message_filter), dump_guid, 851 make_scoped_refptr(trace_message_filter), dump_guid,
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
891 is_monitoring_ = is_monitoring; 905 is_monitoring_ = is_monitoring;
892 #if !defined(OS_ANDROID) 906 #if !defined(OS_ANDROID)
893 for (std::set<TracingUI*>::iterator it = tracing_uis_.begin(); 907 for (std::set<TracingUI*>::iterator it = tracing_uis_.begin();
894 it != tracing_uis_.end(); it++) { 908 it != tracing_uis_.end(); it++) {
895 (*it)->OnMonitoringStateChanged(is_monitoring); 909 (*it)->OnMonitoringStateChanged(is_monitoring);
896 } 910 }
897 #endif 911 #endif
898 } 912 }
899 913
900 } // namespace content 914 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/tracing/tracing_controller_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698