diff options
| author | haraken@chromium.org <haraken@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-01-14 14:55:58 +0000 |
|---|---|---|
| committer | haraken@chromium.org <haraken@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-01-14 14:55:58 +0000 |
| commit | 06d5b6e4445d0844fe858d0e3e0fd376aebf2778 (patch) | |
| tree | f2cd385f5792c9ef5098ab2fc1345efac0e572d4 /content/browser/tracing/tracing_controller_impl.cc | |
| parent | 73ba82b5e91eaca97fbd517817e2fe2c87bc97dc (diff) | |
| download | chromium_src-06d5b6e4445d0844fe858d0e3e0fd376aebf2778.zip chromium_src-06d5b6e4445d0844fe858d0e3e0fd376aebf2778.tar.gz chromium_src-06d5b6e4445d0844fe858d0e3e0fd376aebf2778.tar.bz2 | |
Add a mechanism to let TracingController invoke JavaScript via TracingUI
This CL enables TracingController to call JavaScript in about:tracing tabs
when a monitoring state is changed. If one tab changes the monitoring state, TracingController notifies
the change to all other about:tracing tabs.
That way we can keep the monitoring state displayed in all about:tracing tabs consistent.
Review URL: https://codereview.chromium.org/127703002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@244709 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser/tracing/tracing_controller_impl.cc')
| -rw-r--r-- | content/browser/tracing/tracing_controller_impl.cc | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/content/browser/tracing/tracing_controller_impl.cc b/content/browser/tracing/tracing_controller_impl.cc index 8bca4a0..185eb98 100644 --- a/content/browser/tracing/tracing_controller_impl.cc +++ b/content/browser/tracing/tracing_controller_impl.cc @@ -10,6 +10,7 @@ #include "base/json/string_escape.h" #include "base/strings/string_number_conversions.h" #include "content/browser/tracing/trace_message_filter.h" +#include "content/browser/tracing/tracing_ui.h" #include "content/common/child_process_messages.h" #include "content/public/browser/browser_message_filter.h" #include "content/public/common/content_switches.h" @@ -291,7 +292,7 @@ bool TracingControllerImpl::EnableMonitoring( if (!can_enable_monitoring()) return false; - is_monitoring_ = true; + OnMonitoringStateChanged(true); #if defined(OS_ANDROID) TraceLog::GetInstance()->AddClockSyncMetadataEvent(); @@ -353,7 +354,7 @@ void TracingControllerImpl::OnDisableMonitoringDone( const DisableMonitoringDoneCallback& callback) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - is_monitoring_ = false; + OnMonitoringStateChanged(false); // Notify all child processes. for (TraceMessageFilterSet::iterator it = trace_message_filters_.begin(); @@ -782,4 +783,32 @@ void TracingControllerImpl::OnWatchEventMatched() { watch_event_callback_.Run(); } +void TracingControllerImpl::RegisterTracingUI(TracingUI* tracing_ui) +{ + DCHECK(tracing_uis_.find(tracing_ui) == tracing_uis_.end()); + tracing_uis_.insert(tracing_ui); + tracing_ui->OnMonitoringStateChanged(is_monitoring_); +} + +void TracingControllerImpl::UnregisterTracingUI(TracingUI* tracing_ui) +{ + std::set<TracingUI*>::iterator it = tracing_uis_.find(tracing_ui); + DCHECK(it != tracing_uis_.end()); + tracing_uis_.erase(it); +} + +void TracingControllerImpl::OnMonitoringStateChanged(bool is_monitoring) +{ + if (is_monitoring_ == is_monitoring) + return; + + is_monitoring_ = is_monitoring; +#if !defined(OS_ANDROID) + for (std::set<TracingUI*>::iterator it = tracing_uis_.begin(); + it != tracing_uis_.end(); it++) { + (*it)->OnMonitoringStateChanged(is_monitoring); + } +#endif +} + } // namespace content |
